abi-compliance-checker.pl revision be558b873e36f8e28994af8fdacb08cf43b778f3
1ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#!/usr/bin/perl
2ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko###########################################################################
3be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko# ABI Compliance Checker (ACC) 1.99.7
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# =============
41ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko#  ABI Dumper >= 0.97
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
67be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenkomy $TOOL_VERSION = "1.99.7";
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,
96e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko$CheckInfo, $Quick);
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,
249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# other options
250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "test!" => \$TestTool,
251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "test-dump!" => \$TestDump,
252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "debug!" => \$Debug,
25307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  "cpp-compatible!" => \$CppCompat,
254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "p|params=s" => \$ParamNamesPath,
255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "relpath1|relpath=s" => \$RelativeDirectory{1},
256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "relpath2=s" => \$RelativeDirectory{2},
257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "dump-path=s" => \$OutputDumpPath,
25862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "sort!" => \$SortDump,
259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "report-path=s" => \$OutputReportPath,
2601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  "bin-report-path=s" => \$BinaryReportPath,
2611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  "src-report-path=s" => \$SourceReportPath,
262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "log-path=s" => \$LoggingPath,
263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "log1-path=s" => \$OutputLogPath{1},
264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "log2-path=s" => \$OutputLogPath{2},
265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "logging-mode=s" => \$LogMode,
266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "list-affected!" => \$ListAffected,
267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "l-full|lib-full=s" => \$TargetLibraryFName,
2681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  "component=s" => \$TargetComponent_Opt,
26962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "b|browse=s" => \$Browse,
27007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  "open!" => \$OpenReport,
271570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko  "extra-info=s" => \$ExtraInfo,
272570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko  "extra-dump!" => \$ExtraDump,
2738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko  "force!" => \$Force,
2748f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko  "tolerance=s" => \$Tolerance,
275177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko  "tolerant!" => \$Tolerant,
276e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko  "check!" => \$CheckInfo,
277e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko  "quick!" => \$Quick
278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko) or ERR_MESSAGE();
279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub ERR_MESSAGE()
281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("INFO", "\n".$ShortUsage);
283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    exit($ERROR_CODE{"Error"});
284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $LIB_TYPE = $UseStaticLibs?"static":"dynamic";
287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $SLIB_TYPE = $LIB_TYPE;
288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkoif($OSgroup!~/macos|windows/ and $SLIB_TYPE eq "dynamic")
289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # show as "shared" library
290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $SLIB_TYPE = "shared";
291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $LIB_EXT = getLIB_EXT($OSgroup);
293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $AR_EXT = getAR_EXT($OSgroup);
294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $BYTE_SIZE = 8;
295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $COMMON_LOG_PATH = "logs/run.log";
296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $HelpMessage="
298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoNAME:
299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  ABI Compliance Checker ($CmdName)
3000d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko  Check backward compatibility of a C/C++ library API
301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoDESCRIPTION:
3031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  ABI Compliance Checker (ACC) is a tool for checking backward binary and
3041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  source-level compatibility of a $SLIB_TYPE C/C++ library. The tool checks
3051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  header files and $SLIB_TYPE libraries (*.$LIB_EXT) of old and new versions and
3061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  analyzes changes in API and ABI (ABI=API+compiler ABI) that may break binary
3071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  and/or source-level compatibility: changes in calling stack, v-table changes,
3081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  removed symbols, renamed fields, etc. Binary incompatibility may result in
3091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  crashing or incorrect behavior of applications built with an old version of
3101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  a library if they run on a new one. Source incompatibility may result in
3111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  recompilation errors with a new library version.
312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
313dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko  The tool is intended for developers of software libraries and maintainers
314dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko  of operating systems who are interested in ensuring backward compatibility,
315dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko  i.e. allow old applications to run or to be recompiled with newer library
316dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko  versions.
317dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko
318dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko  Also the tool can be used by ISVs for checking applications portability to
319dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko  new library versions. Found issues can be taken into account when adapting
320dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko  the application to a new library version.
321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  This tool is free software: you can redistribute it and/or modify it
323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  under the terms of the GNU LGPL or GNU GPL.
324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoUSAGE:
326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  $CmdName [options]
327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoEXAMPLE:
3290d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko  $CmdName -lib NAME -old OLD.xml -new NEW.xml
330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  OLD.xml and NEW.xml are XML-descriptors:
332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <version>
334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        1.0
335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    </version>
336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <headers>
338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        /path1/to/header(s)/
339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        /path2/to/header(s)/
340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         ...
341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    </headers>
342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <libs>
344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        /path1/to/library(ies)/
345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        /path2/to/library(ies)/
346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         ...
347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    </libs>
348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoINFORMATION OPTIONS:
350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -h|-help
351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Print this help.
352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -i|-info
354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Print complete info.
355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -v|-version
357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Print version information.
358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -dumpversion
360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Print the tool version ($TOOL_VERSION) and don't do anything else.
361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoGENERAL OPTIONS:
36307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -l|-lib|-library NAME
364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Library name (without version).
365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
36607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -d1|-old|-o PATH
367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Descriptor of 1st (old) library version.
368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      It may be one of the following:
369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         1. XML-descriptor (VERSION.xml file):
371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              <version>
373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  1.0
374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              </version>
375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              <headers>
377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  /path1/to/header(s)/
378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  /path2/to/header(s)/
379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                   ...
380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              </headers>
381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              <libs>
383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  /path1/to/library(ies)/
384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  /path2/to/library(ies)/
385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                   ...
386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              </libs>
387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 ... (XML-descriptor template
389ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                         can be generated by -d option)
390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         2. ABI dump generated by -dump option
392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         3. Directory with headers and/or $SLIB_TYPE libraries
393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         4. Single header file
394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         5. Single $SLIB_TYPE library
395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         6. Comma separated list of headers and/or libraries
396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      If you are using an 2-6 descriptor types then you should
398570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      specify version numbers with -v1 and -v2 options too.
399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      For more information, please see:
4011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        http://ispras.linuxbase.org/index.php/Library_Descriptor
402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
40307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -d2|-new|-n PATH
404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Descriptor of 2nd (new) library version.
405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
40607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -dump|-dump-abi PATH
407570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      Create library ABI dump for the input XML descriptor. You can
408570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      transfer it anywhere and pass instead of the descriptor. Also
409570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      it can be used for debugging the tool.
410570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
411fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko      Supported ABI dump versions: 2.0<=V<=$ABI_DUMP_VERSION
412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -old-dumps
414fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko      Enable support for old-version ABI dumps ($OLDEST_SUPPORTED_VERSION<=V<2.0).\n";
415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub HELP_MESSAGE() {
417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("INFO", $HelpMessage."
418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoMORE INFO:
419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko     $CmdName --info\n");
420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub INFO_MESSAGE()
423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("INFO", "$HelpMessage
425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoEXTRA OPTIONS:
426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -d|-descriptor-template
427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Create XML-descriptor template ./VERSION.xml
428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
42907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -app|-application PATH
430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      This option allows to specify the application that should be checked
431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      for portability to the new library version.
432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -static-libs
434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Check static libraries instead of the shared ones. The <libs> section
435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      of the XML-descriptor should point to static libraries location.
436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
43707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -cross-gcc|-gcc-path PATH
438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Path to the cross GCC compiler to use instead of the usual (host) GCC.
439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
44007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -cross-prefix|-gcc-prefix PREFIX
441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      GCC toolchain prefix.
442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
44307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -sysroot DIR
444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Specify the alternative root directory. The tool will search for include
44507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      paths in the DIR/usr/include and DIR/usr/lib directories.
446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
44707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -v1|-version1 NUM
448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Specify 1st library version outside the descriptor. This option is needed
449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      if you have prefered an alternative descriptor type (see -d1 option).
450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      In general case you should specify it in the XML-descriptor:
452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <version>
453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              VERSION
454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </version>
455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
45607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -v2|-version2 NUM
457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Specify 2nd library version outside the descriptor.
458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -s|-strict
460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Treat all compatibility warnings as problems. Add a number of \"Low\"
461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      severity problems to the return value of the tool.
462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -headers-only
464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Check header files without $SLIB_TYPE libraries. It is easy to run, but may
465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      provide a low quality compatibility report with false positives and
466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      without detecting of added/removed symbols.
467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Alternatively you can write \"none\" word to the <libs> section
469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      in the XML-descriptor:
470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <libs>
471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              none
472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </libs>
473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -objects-only
475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Check $SLIB_TYPE libraries without header files. It is easy to run, but may
476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      provide a low quality compatibility report with false positives and
477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      without analysis of changes in parameters and data types.
478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Alternatively you can write \"none\" word to the <headers> section
480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      in the XML-descriptor:
481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <headers>
482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              none
483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </headers>
484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -check-impl|-check-implementation
486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Compare canonified disassembled binary code of $SLIB_TYPE libraries to
487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      detect changes in the implementation. Add \'Problems with Implementation\'
488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      section to the report.
489ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -show-retval
491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Show the symbol's return type in the report.
492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
49307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -symbols-list PATH
494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      This option allows to specify a file with a list of symbols (mangled
495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      names in C++) that should be checked, other symbols will not be checked.
496fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
497fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  -skip-symbols PATH
498fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko      The list of symbols that should NOT be checked.
499ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
500fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  -headers-list PATH
501fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko      The file with a list of headers, that should be checked/dumped.
502fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
50307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -skip-headers PATH
504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      The file with the list of header files, that should not be checked.
505fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
506fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  -header NAME
507fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko      Check/Dump ABI of this header only.
508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -use-dumps
510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Make dumps for two versions of a library and compare dumps. This should
511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      increase the performance of the tool and decrease the system memory usage.
512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -nostdinc
514570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      Do not search in GCC standard system directories for header files.
515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
51607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -dump-system NAME -sysroot DIR
51707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      Find all the shared libraries and header files in DIR directory,
518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      create XML descriptors and make ABI dumps for each library. The result
519ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      set of ABI dumps can be compared (--cmp-systems) with the other one
520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      created for other version of operating system in order to check them for
521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      compatibility. Do not forget to specify -cross-gcc option if your target
522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      system requires some specific version of GCC compiler (different from
523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      the host GCC). The system ABI dump will be generated to:
52407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          sys_dumps/NAME/ARCH
525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
52607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -dump-system DESCRIPTOR.xml
527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      The same as the previous option but takes an XML descriptor of the target
528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      system as input, where you should describe it:
529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          /* Primary sections */
531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <name>
533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* Name of the system */
534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </name>
535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <headers>
537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* The list of paths to header files and/or
538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 directories with header files, one per line */
539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </headers>
540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <libs>
542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* The list of paths to shared libraries and/or
543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 directories with shared libraries, one per line */
544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </libs>
545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          /* Optional sections */
547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <search_headers>
549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* List of directories to be searched
550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 for header files to automatically
551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 generate include paths, one per line */
552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </search_headers>
553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <search_libs>
555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* List of directories to be searched
556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 for shared libraries to resolve
557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 dependencies, one per line */
558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </search_libs>
559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <tools>
561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* List of directories with tools used
562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 for analysis (GCC toolchain), one per line */
563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </tools>
564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <cross_prefix>
566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* GCC toolchain prefix.
567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 Examples:
568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                     arm-linux-gnueabi
569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                     arm-none-symbianelf */
570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </cross_prefix>
571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <gcc_options>
573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* Additional GCC options, one per line */
574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </gcc_options>
575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
57607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -sysinfo DIR
577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      This option may be used with -dump-system to dump ABI of operating
578ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      systems and configure the dumping process.
579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Default:
580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          modules/Targets/{unix, symbian, windows}
581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
58207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -cmp-systems -d1 sys_dumps/NAME1/ARCH -d2 sys_dumps/NAME2/ARCH
583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Compare two system ABI dumps. Create compatibility reports for each
584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      library and the common HTML report including the summary of test
585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      results for all checked libraries. Report will be generated to:
58607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          sys_compat_reports/NAME1_to_NAME2/ARCH
587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
58807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -libs-list PATH
589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      The file with a list of libraries, that should be dumped by
590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      the -dump-system option or should be checked by the -cmp-systems option.
591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -ext|-extended
593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      If your library A is supposed to be used by other library B and you
594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      want to control the ABI of B, then you should enable this option. The
595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      tool will check for changes in all data types, even if they are not
596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      used by any function in the library A. Such data types are not part
597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      of the A library ABI, but may be a part of the ABI of the B library.
598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      The short scheme is:
600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        app C (broken) -> lib B (broken ABI) -> lib A (stable ABI)
601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -q|-quiet
603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Print all messages to the file instead of stdout and stderr.
604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Default path (can be changed by -log-path option):
605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          $COMMON_LOG_PATH
606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -stdout
608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Print analysis results (compatibility reports and ABI dumps) to stdout
609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      instead of creating a file. This would allow piping data to other programs.
610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
61107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -report-format FMT
612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Change format of compatibility report.
613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Formats:
614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        htm - HTML format (default)
615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        xml - XML format
616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
61707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -dump-format FMT
6185c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko      Change format of ABI dump.
6195c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko      Formats:
6205c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        perl - Data::Dumper format (default)
6215c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        xml - XML format
6225c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko
6231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  -xml
6245c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko      Alias for: --report-format=xml or --dump-format=xml
6251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
62607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -lang LANG
627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Set library language (C or C++). You can use this option if the tool
628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      cannot auto-detect a language. This option may be useful for checking
629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      C-library headers (--lang=C) in --headers-only or --extended modes.
630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  -binary|-bin|-abi
6321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Show \"Binary\" compatibility problems only.
6331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Generate report to:
63407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        compat_reports/LIB_NAME/V1_to_V2/abi_compat_report.html
6351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
6361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  -source|-src|-api
6371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Show \"Source\" compatibility problems only.
6381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Generate report to:
63907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        compat_reports/LIB_NAME/V1_to_V2/src_compat_report.html
6401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoOTHER OPTIONS:
642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -test
643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Run internal tests. Create two binary incompatible versions of a sample
644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      library and run the tool to check them for compatibility. This option
645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      allows to check if the tool works correctly in the current environment.
646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -test-dump
648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Test ability to create, read and compare ABI dumps.
649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -debug
651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Debugging mode. Print debug info on the screen. Save intermediate
652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      analysis stages in the debug directory:
65307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          debug/LIB_NAME/VERSION/
654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Also consider using --dump option for debugging the tool.
6561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -cpp-compatible
65807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      If your header files are written in C language and can be compiled
65907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      by the G++ compiler (i.e. don't use C++ keywords), then you can tell
66007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      the tool about this and speedup the analysis.
661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
66207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -p|-params PATH
663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Path to file with the function parameter names. It can be used
664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      for improving report view if the library header files have no
665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      parameter names. File format:
666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            func1;param1;param2;param3 ...
668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            func2;param1;param2;param3 ...
669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko             ...
670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
67107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -relpath PATH
67207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      Replace {RELPATH} macros to PATH in the XML-descriptor used
673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      for dumping the library ABI (see -dump option).
674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
67507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -relpath1 PATH
67607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      Replace {RELPATH} macros to PATH in the 1st XML-descriptor (-d1).
677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
67807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -relpath2 PATH
67907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      Replace {RELPATH} macros to PATH in the 2nd XML-descriptor (-d2).
680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
68107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -dump-path PATH
6825c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko      Specify a *.abi.$AR_EXT or *.abi file path where to generate an ABI dump.
683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Default:
68407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          abi_dumps/LIB_NAME/LIB_NAME_VERSION.abi.$AR_EXT
685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
68662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  -sort
68762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko      Enable sorting of data in ABI dumps.
68862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
68907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -report-path PATH
6900d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko      Path to compatibility report.
6911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Default:
69207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          compat_reports/LIB_NAME/V1_to_V2/compat_report.html
6931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
69407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -bin-report-path PATH
6951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Path to \"Binary\" compatibility report.
696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Default:
69707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          compat_reports/LIB_NAME/V1_to_V2/abi_compat_report.html
698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
69907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -src-report-path PATH
7001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Path to \"Source\" compatibility report.
7011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Default:
70207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          compat_reports/LIB_NAME/V1_to_V2/src_compat_report.html
7031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
70407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -log-path PATH
705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Log path for all messages.
706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Default:
70707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          logs/LIB_NAME/VERSION/log.txt
708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
70907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -log1-path PATH
710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Log path for 1st version of a library.
711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Default:
71207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          logs/LIB_NAME/V1/log.txt
713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
71407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -log2-path PATH
715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Log path for 2nd version of a library.
716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Default:
71707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          logs/LIB_NAME/V2/log.txt
718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
71907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -logging-mode MODE
720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Change logging mode.
721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Modes:
722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        w - overwrite old logs (default)
723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        a - append old logs
724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        n - do not write any logs
725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -list-affected
727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Generate file with the list of incompatible
728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      symbols beside the HTML compatibility report.
729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Use 'c++filt \@file' command from GNU binutils
730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      to unmangle C++ symbols in the generated file.
7311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Default names:
732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          abi_affected.txt
7331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko          src_affected.txt
734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
73507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -component NAME
736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      The component name in the title and summary of the HTML report.
737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Default:
738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          library
739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
74007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -l-full|-lib-full NAME
74107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      Change library name in the report title to NAME. By default
742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      will be displayed a name specified by -l option.
743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
74407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -b|-browse PROGRAM
7451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Open report(s) in the browser (firefox, opera, etc.).
7461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
74762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  -open
74862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko      Open report(s) in the default browser.
74907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
75007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -extra-info DIR
75107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      Dump extra info to DIR.
752570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
753570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko  -extra-dump
754570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      Create extended ABI dump containing all symbols
755570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      from the translation unit.
756570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
757570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko  -force
758570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      Try to use this option if the tool doesn't work.
7598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
7608f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko  -tolerance LEVEL
7618f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko      Apply a set of heuristics to successfully compile input
7628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko      header files. You can enable several tolerance levels by
7638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko      joining them into one string (e.g. 13, 124, etc.).
7648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko      Levels:
7658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko          1 - skip non-Linux headers (e.g. win32_*.h, etc.)
7668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko          2 - skip internal headers (e.g. *_p.h, impl/*.h, etc.)
7678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko          3 - skip headers that iclude non-Linux headers
7688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko          4 - skip headers included by others
7698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
7708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko  -tolerant
7718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko      Enable highest tolerance level [1234].
772177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
773177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko  -check
774177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko      Check completeness of the ABI dump.
775e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
776e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko  -quick
777e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko      Quick analysis. Disable check of some template instances.
77862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoREPORT:
780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    Compatibility report will be generated to:
78107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        compat_reports/LIB_NAME/V1_to_V2/compat_report.html
782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    Log will be generated to:
78407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        logs/LIB_NAME/V1/log.txt
78507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        logs/LIB_NAME/V2/log.txt
786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoEXIT CODES:
788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    0 - Compatible. The tool has run without any errors.
789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    non-zero - Incompatible or the tool has run with errors.
790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoREPORT BUGS TO:
7921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    Andrey Ponomarenko <aponomarenko\@rosalab.ru>
793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoMORE INFORMATION:
795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ".$HomePage{"Wiki"}."
7961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    ".$HomePage{"Dev1"}."\n");
797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $DescriptorTemplate = "
800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko<?xml version=\"1.0\" encoding=\"utf-8\"?>
801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko<descriptor>
802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko/* Primary sections */
804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko<version>
806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    /* Version of the library */
807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko</version>
808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko<headers>
810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    /* The list of paths to header files and/or
811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko       directories with header files, one per line */
812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko</headers>
813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko<libs>
815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    /* The list of paths to shared libraries (*.$LIB_EXT) and/or
816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko       directories with shared libraries, one per line */
817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko</libs>
818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko/* Optional sections */
820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko<include_paths>
822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    /* The list of include paths that will be provided
823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko       to GCC to compile library headers, one per line.
824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko       NOTE: If you define this section then the tool
825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko       will not automatically generate include paths */
826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko</include_paths>
827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko<add_include_paths>
829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    /* The list of include paths that will be added
830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko       to the automatically generated include paths, one per line */
831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko</add_include_paths>
832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko<skip_include_paths>
834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    /* The list of include paths that will be removed from the
835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko       list of automatically generated include paths, one per line */
836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko</skip_include_paths>
837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko<gcc_options>
839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    /* Additional GCC options, one per line */
840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko</gcc_options>
841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko<include_preamble>
843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    /* The list of header files that will be
84474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko       included before other headers, one per line  */
845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko</include_preamble>
846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko<defines>
848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    /* The list of defines that will be added at the
849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko       headers compiling stage, one per line:
850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          #define A B
851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          #define C D */
852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko</defines>
853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
854a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko<add_namespaces>
855a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    /* The list of namespaces that should be added to the alanysis
856a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko       if the tool cannot find them automatically, one per line */
857a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko</add_namespaces>
858a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko
859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko<skip_types>
860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    /* The list of data types, that
861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko       should not be checked, one per line */
862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko</skip_types>
863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko<skip_symbols>
865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    /* The list of functions (mangled/symbol names in C++),
866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko       that should not be checked, one per line */
867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko</skip_symbols>
868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko<skip_namespaces>
870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    /* The list of C++ namespaces, that
871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko       should not be checked, one per line */
872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko</skip_namespaces>
873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko<skip_constants>
875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    /* The list of constants that should
876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko       not be checked, one name per line */
877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko</skip_constants>
878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko<skip_headers>
880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    /* The list of header files and/or directories
881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko       with header files that should not be checked, one per line */
882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko</skip_headers>
883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko<skip_libs>
885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    /* The list of shared libraries and/or directories
886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko       with shared libraries that should not be checked, one per line */
887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko</skip_libs>
888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko<skip_including>
890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    /* The list of header files, that cannot be included
891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko       directly (or non-self compiled ones), one per line */
892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko</skip_including>
893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko<search_headers>
895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    /* List of directories to be searched
896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko       for header files to automatically
897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko       generate include paths, one per line. */
898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko</search_headers>
899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko<search_libs>
901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    /* List of directories to be searched
902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko       for shared librariess to resolve
903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko       dependencies, one per line */
904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko</search_libs>
905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko<tools>
907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    /* List of directories with tools used
908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko       for analysis (GCC toolchain), one per line */
909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko</tools>
910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko<cross_prefix>
912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    /* GCC toolchain prefix.
913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko       Examples:
914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko           arm-linux-gnueabi
915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko           arm-none-symbianelf */
916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko</cross_prefix>
917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko</descriptor>";
919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Operator_Indication = (
921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "not" => "~",
922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "assign" => "=",
923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "andassign" => "&=",
924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "orassign" => "|=",
925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "xorassign" => "^=",
926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "or" => "|",
927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "xor" => "^",
928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "addr" => "&",
929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "and" => "&",
930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "lnot" => "!",
931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "eq" => "==",
932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ne" => "!=",
933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "lt" => "<",
934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "lshift" => "<<",
935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "lshiftassign" => "<<=",
936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "rshiftassign" => ">>=",
937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "call" => "()",
938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "mod" => "%",
939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "modassign" => "%=",
940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "subs" => "[]",
941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "land" => "&&",
942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "lor" => "||",
943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "rshift" => ">>",
944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ref" => "->",
945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "le" => "<=",
946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "deref" => "*",
947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "mult" => "*",
948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "preinc" => "++",
949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "delete" => " delete",
950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "vecnew" => " new[]",
951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "vecdelete" => " delete[]",
952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "predec" => "--",
953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "postinc" => "++",
954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "postdec" => "--",
955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "plusassign" => "+=",
956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "plus" => "+",
957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "minus" => "-",
958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "minusassign" => "-=",
959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "gt" => ">",
960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ge" => ">=",
961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "new" => " new",
962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "multassign" => "*=",
963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "divassign" => "/=",
964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "div" => "/",
965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "neg" => "-",
966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "pos" => "+",
967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "memref" => "->*",
968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "compound" => "," );
969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
97062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %UnknownOperator;
97162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
97262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %NodeType= (
97362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "array_type" => "Array",
97462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "binfo" => "Other",
97562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "boolean_type" => "Intrinsic",
97662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "complex_type" => "Intrinsic",
97762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "const_decl" => "Other",
97862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "enumeral_type" => "Enum",
97962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "field_decl" => "Other",
98062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "function_decl" => "Other",
98162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "function_type" => "FunctionType",
98262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "identifier_node" => "Other",
98362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "integer_cst" => "Other",
98462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "integer_type" => "Intrinsic",
985177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko  "vector_type" => "Vector",
98662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "method_type" => "MethodType",
98762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "namespace_decl" => "Other",
98862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "parm_decl" => "Other",
98962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "pointer_type" => "Pointer",
99062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "real_cst" => "Other",
99162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "real_type" => "Intrinsic",
99262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "record_type" => "Struct",
99362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "reference_type" => "Ref",
99462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "string_cst" => "Other",
99562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "template_decl" => "Other",
996177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko  "template_type_parm" => "TemplateParam",
997177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko  "typename_type" => "TypeName",
998177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko  "sizeof_expr" => "SizeOf",
99962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "tree_list" => "Other",
100062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "tree_vec" => "Other",
100162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "type_decl" => "Other",
100262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "union_type" => "Union",
100362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "var_decl" => "Other",
100462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "void_type" => "Intrinsic",
10058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko  "nop_expr" => "Other", #
10068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko  "addr_expr" => "Other", #
100762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "offset_type" => "Other" );
100862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
1009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CppKeywords_C = map {$_=>1} (
1010ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # C++ 2003 keywords
1011ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "public",
1012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "protected",
1013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "private",
1014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "default",
1015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "template",
1016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "new",
1017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"asm",
1018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "dynamic_cast",
1019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "auto",
1020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "try",
1021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "namespace",
1022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "typename",
1023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "using",
1024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "reinterpret_cast",
1025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "friend",
1026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "class",
1027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "virtual",
1028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "const_cast",
1029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "mutable",
1030ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "static_cast",
1031ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "export",
1032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # C++0x keywords
1033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "noexcept",
1034ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "nullptr",
1035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "constexpr",
1036ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "static_assert",
1037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "explicit",
1038ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # cannot be used as a macro name
1039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # as it is an operator in C++
1040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "and",
1041ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"and_eq",
1042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "not",
1043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"not_eq",
1044ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "or"
1045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"or_eq",
1046ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"bitand",
1047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"bitor",
1048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"xor",
1049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"xor_eq",
1050ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"compl"
1051ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
1052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1053ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CppKeywords_F = map {$_=>1} (
1054ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "delete",
1055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "catch",
1056ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "alignof",
1057ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "thread_local",
1058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "decltype",
1059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "typeid"
1060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
1061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1062ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CppKeywords_O = map {$_=>1} (
1063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "bool",
1064ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "register",
1065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "inline",
1066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "operator"
1067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
1068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CppKeywords_A = map {$_=>1} (
1070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "this",
10718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    "throw",
10728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    "template"
1073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
1074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkoforeach (keys(%CppKeywords_C),
1076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkokeys(%CppKeywords_F),
1077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkokeys(%CppKeywords_O)) {
1078ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $CppKeywords_A{$_}=1;
1079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Header file extensions as described by gcc
1082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $HEADER_EXT = "h|hh|hp|hxx|hpp|h\\+\\+";
1083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %IntrinsicMangling = (
1085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "void" => "v",
1086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "bool" => "b",
1087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "wchar_t" => "w",
1088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "char" => "c",
1089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "signed char" => "a",
1090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned char" => "h",
1091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "short" => "s",
1092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned short" => "t",
1093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "int" => "i",
1094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned int" => "j",
1095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "long" => "l",
1096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned long" => "m",
1097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "long long" => "x",
1098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "__int64" => "x",
1099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned long long" => "y",
1100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "__int128" => "n",
1101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned __int128" => "o",
1102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "float" => "f",
1103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "double" => "d",
1104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "long double" => "e",
1105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "__float80" => "e",
1106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "__float128" => "g",
1107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "..." => "z"
1108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
1109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1110177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy %IntrinsicNames = map {$_=>1} keys(%IntrinsicMangling);
1111177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
1112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %StdcxxMangling = (
1113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "3std"=>"St",
1114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "3std9allocator"=>"Sa",
1115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "3std12basic_string"=>"Sb",
1116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "3std12basic_stringIcE"=>"Ss",
1117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "3std13basic_istreamIcE"=>"Si",
1118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "3std13basic_ostreamIcE"=>"So",
1119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "3std14basic_iostreamIcE"=>"Sd"
1120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
1121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1122e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenkomy $DEFAULT_STD_PARMS = "std::(allocator|less|char_traits|regex_traits|istreambuf_iterator|ostreambuf_iterator)";
1123177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy %DEFAULT_STD_ARGS = map {$_=>1} ("_Alloc", "_Compare", "_Traits", "_Rx_traits", "_InIter", "_OutIter");
1124177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
1125177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy $ADD_TMPL_INSTANCES = 1;
112607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
1127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ConstantSuffix = (
1128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned int"=>"u",
1129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "long"=>"l",
1130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned long"=>"ul",
1131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "long long"=>"ll",
1132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned long long"=>"ull"
1133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
1134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ConstantSuffixR =
1136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkoreverse(%ConstantSuffix);
1137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %OperatorMangling = (
1139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "~" => "co",
1140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "=" => "aS",
1141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "|" => "or",
1142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "^" => "eo",
1143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "&" => "an",#ad (addr)
1144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "==" => "eq",
1145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "!" => "nt",
1146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "!=" => "ne",
1147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "<" => "lt",
1148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "<=" => "le",
1149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "<<" => "ls",
1150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "<<=" => "lS",
1151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ">" => "gt",
1152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ">=" => "ge",
1153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ">>" => "rs",
1154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ">>=" => "rS",
1155ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "()" => "cl",
1156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "%" => "rm",
1157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "[]" => "ix",
1158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "&&" => "aa",
1159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "||" => "oo",
1160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "*" => "ml",#de (deref)
1161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "++" => "pp",#
1162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "--" => "mm",#
1163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "new" => "nw",
1164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "delete" => "dl",
1165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "new[]" => "na",
1166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "delete[]" => "da",
1167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "+=" => "pL",
1168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "+" => "pl",#ps (pos)
1169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "-" => "mi",#ng (neg)
1170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "-=" => "mI",
1171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "*=" => "mL",
1172ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "/=" => "dV",
1173ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "&=" => "aN",
1174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "|=" => "oR",
1175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "%=" => "rM",
1176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "^=" => "eO",
1177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "/" => "dv",
1178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "->*" => "pm",
1179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "->" => "pt",#rf (ref)
1180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "," => "cm",
1181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "?" => "qu",
1182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "." => "dt",
1183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sizeof"=> "sz"#st
1184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
1185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
118662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %Intrinsic_Keywords = map {$_=>1} (
118762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "true",
118862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "false",
118962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "_Bool",
119062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "_Complex",
119162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "const",
119262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "int",
119362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "long",
119462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "void",
119562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "short",
119662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "float",
119762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "volatile",
119862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "restrict",
119962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "unsigned",
120062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "signed",
120162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "char",
120262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "double",
120362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "class",
120462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "struct",
120562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "union",
120662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "enum"
120762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko);
120862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
1209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %GlibcHeader = map {$_=>1} (
1210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "aliases.h",
1211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "argp.h",
1212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "argz.h",
1213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "assert.h",
1214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "cpio.h",
1215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ctype.h",
1216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "dirent.h",
1217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "envz.h",
1218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "errno.h",
1219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "error.h",
1220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "execinfo.h",
1221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "fcntl.h",
1222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "fstab.h",
1223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ftw.h",
1224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "glob.h",
1225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "grp.h",
1226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "iconv.h",
1227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ifaddrs.h",
1228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "inttypes.h",
1229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "langinfo.h",
1230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "limits.h",
1231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "link.h",
1232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "locale.h",
1233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "malloc.h",
1234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "math.h",
1235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "mntent.h",
1236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "monetary.h",
1237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "nl_types.h",
1238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "obstack.h",
1239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "printf.h",
1240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "pwd.h",
1241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "regex.h",
1242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sched.h",
1243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "search.h",
1244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "setjmp.h",
1245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "shadow.h",
1246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "signal.h",
1247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "spawn.h",
1248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "stdarg.h",
1249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "stdint.h",
1250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "stdio.h",
1251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "stdlib.h",
1252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "string.h",
12539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "strings.h",
1254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "tar.h",
1255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "termios.h",
1256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "time.h",
1257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ulimit.h",
1258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unistd.h",
1259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "utime.h",
1260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "wchar.h",
1261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "wctype.h",
1262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "wordexp.h" );
1263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %GlibcDir = map {$_=>1} (
1265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "arpa",
1266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "bits",
1267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "gnu",
1268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "netinet",
1269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "net",
1270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "nfs",
1271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "rpc",
1272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sys",
1273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "linux" );
1274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
12759927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %WinHeaders = map {$_=>1} (
12769927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "dos.h",
12779927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "process.h",
12789927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "winsock.h",
12799927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "config-win.h",
12809927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "mem.h",
12819927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "windows.h",
12829927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "winsock2.h",
12839927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "crtdbg.h",
12849927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "ws2tcpip.h"
12859927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko);
12869927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
12879927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %ObsoleteHeaders = map {$_=>1} (
12889927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "iostream.h",
12899927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "fstream.h"
12909927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko);
12919927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
129274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkomy %AlienHeaders = map {$_=>1} (
129374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko # Solaris
129474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "thread.h",
129574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "sys/atomic.h",
129674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko # HPUX
129774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "sys/stream.h",
129874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko # Symbian
129974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "AknDoc.h",
130074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko # Atari ST
130174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "ext.h",
130274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "tos.h",
130374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko # MS-DOS
130474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "alloc.h",
130574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko # Sparc
130674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "sys/atomic.h"
130774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko);
130874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
13099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %ConfHeaders = map {$_=>1} (
13109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "atomic",
13119927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "conf.h",
13129927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "config.h",
13139927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "configure.h",
13149927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "build.h",
13159927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "setup.h"
13169927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko);
13179927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
1318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %LocalIncludes = map {$_=>1} (
1319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "/usr/local/include",
1320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "/usr/local" );
1321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %OS_AddPath=(
1323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# These paths are needed if the tool cannot detect them automatically
1324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "macos"=>{
1325570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        "include"=>[
1326570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/Library",
1327570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/Developer/usr/include"
1328570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        ],
1329570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        "lib"=>[
1330570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/Library",
1331570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/Developer/usr/lib"
1332570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        ],
1333570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        "bin"=>[
1334570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/Developer/usr/bin"
1335570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        ]
1336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    },
1337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "beos"=>{
1338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Haiku has GCC 2.95.3 by default
1339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # try to find GCC>=3.0 in /boot/develop/abi
1340570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        "include"=>[
1341570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/common",
1342570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/develop"
1343570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        ],
1344570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        "lib"=>[
1345570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/common/lib",
1346570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/system/lib",
1347570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/apps"
1348570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        ],
1349570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        "bin"=>[
1350570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/common/bin",
1351570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/system/bin",
1352570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/develop/abi"
1353570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        ]
1354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
1356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Slash_Type=(
1358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "default"=>"/",
1359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "windows"=>"\\"
1360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
1361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $SLASH = $Slash_Type{$OSgroup}?$Slash_Type{$OSgroup}:$Slash_Type{"default"};
1363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Global Variables
1365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %COMMON_LANGUAGE=(
1366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  1 => "C",
1367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  2 => "C" );
1368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $MAX_COMMAND_LINE_ARGUMENTS = 4096;
13709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy $MAX_CPPFILT_FILE_SIZE = 50000;
13719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy $CPPFILT_SUPPORT_FILE;
13729927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
1373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy (%WORD_SIZE, %CPU_ARCH, %GCC_VERSION);
1374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $STDCXX_TESTING = 0;
1376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $GLIBC_TESTING = 0;
13778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkomy $CPP_HEADERS = 0;
1378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $CheckHeadersOnly = $CheckHeadersOnly_Opt;
1380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $CheckObjectsOnly = $CheckObjectsOnly_Opt;
13818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
1382dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenkomy $TargetComponent;
1383dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko
1384570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy $CheckUndefined = 0;
1385570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
1386dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko# Set Target Component Name
1387dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenkoif($TargetComponent_Opt) {
1388dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    $TargetComponent = lc($TargetComponent_Opt);
1389dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko}
1390dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenkoelse
1391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # default: library
1392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # other components: header, system, ...
1393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $TargetComponent = "library";
1394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
13961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkomy $TOP_REF = "<a style='font-size:11px;' href='#Top'>to the top</a>";
13971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
1398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $SystemRoot;
1399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $MAIN_CPP_DIR;
14011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkomy %RESULT;
1402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %LOG_PATH;
1403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %DEBUG_PATH;
1404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Cache;
1405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %LibInfo;
1406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $COMPILE_ERRORS = 0;
1407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CompilerOptions;
1408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CheckedDyLib;
1409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $TargetLibraryShortName = parse_libname($TargetLibraryName, "shortest", $OSgroup);
1410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Constants (#defines)
1412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Constants;
1413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SkipConstants;
141482bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenkomy %EnumConstants;
1415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
141674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko# Extra Info
141774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkomy %SymbolHeader;
141874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkomy %KnownLibs;
141974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1420177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko# Templates
1421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TemplateInstance;
1422177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy %BasicTemplate;
1423177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy %TemplateArg;
1424850437949b65b213696469223d749c1f74c29601Andrey Ponomarenkomy %TemplateDecl;
1425177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy %TemplateMap;
1426177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
1427177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko# Types
1428177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy %TypeInfo;
1429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SkipTypes = (
1430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>{},
1431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>{} );
1432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CheckedTypes;
1433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TName_Tid;
1434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %EnumMembName_Id;
1435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %NestedNameSpaces = (
1436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>{},
1437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>{} );
1438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %VirtualTable;
14391693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkomy %VirtualTable_Model;
1440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ClassVTable;
1441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ClassVTable_Content;
1442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %VTableClass;
1443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %AllocableClass;
1444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ClassMethods;
14451693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkomy %ClassNames;
1446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Class_SubClasses;
1447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %OverriddenMethods;
14484b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenkomy %TypedefToAnon;
144962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy $MAX_ID = 0;
1450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1451177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy %CheckedTypeInfo;
1452177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
1453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Typedefs
1454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Typedef_BaseName;
1455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Typedef_Tr;
1456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Typedef_Eq;
1457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %StdCxxTypedef;
1458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %MissedTypedef;
145962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %MissedBase;
146062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %MissedBase_R;
14619927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %TypeTypedef;
1462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Symbols
1464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SymbolInfo;
1465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %tr_name;
1466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %mangled_name_gcc;
1467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %mangled_name;
1468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SkipSymbols = (
1469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>{},
1470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>{} );
1471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SkipNameSpaces = (
1472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>{},
1473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>{} );
1474a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenkomy %AddNameSpaces = (
1475a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko  "1"=>{},
1476a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko  "2"=>{} );
1477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SymbolsList;
1478fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkomy %SkipSymbolsList;
1479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SymbolsList_App;
1480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CheckedSymbols;
148162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %Symbol_Library = (
148262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "1"=>{},
148362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "2"=>{} );
148462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %Library_Symbol = (
148562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "1"=>{},
148662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "2"=>{} );
148762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %DepSymbol_Library = (
148862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "1"=>{},
148962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "2"=>{} );
149062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %DepLibrary_Symbol = (
1491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>{},
1492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>{} );
1493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %MangledNames;
14949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %Func_ShortName;
1495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %AddIntParams;
1496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Interface_Impl;
149762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %GlobalDataObject;
149807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenkomy %WeakSymbols;
1499fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkomy %Library_Needed= (
1500fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  "1"=>{},
1501fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  "2"=>{} );
1502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1503570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko# Extra Info
1504570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %UndefinedSymbols;
150574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkomy %PreprocessedHeaders;
1506570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
1507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Headers
1508570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %Include_Preamble = (
1509570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "1"=>[],
1510570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "2"=>[] );
1511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Registered_Headers;
1512fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkomy %Registered_Sources;
1513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %HeaderName_Paths;
1514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Header_Dependency;
1515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Include_Neighbors;
1516570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %Include_Paths = (
1517570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "1"=>[],
1518570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "2"=>[] );
1519ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %INC_PATH_AUTODETECT = (
1520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>1,
1521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>1 );
1522570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %Add_Include_Paths = (
1523570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "1"=>[],
1524570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "2"=>[] );
1525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Skip_Include_Paths;
1526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %RegisteredDirs;
1527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Header_ErrorRedirect;
1528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Header_Includes;
15298f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkomy %Header_Includes_R;
1530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Header_ShouldNotBeUsed;
1531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %RecursiveIncludes;
1532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Header_Include_Prefix;
1533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SkipHeaders;
1534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SkipHeadersList=(
1535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>{},
1536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>{} );
1537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SkipLibs;
1538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Include_Order;
1539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TUnit_NameSpaces;
1540f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenkomy %TUnit_Classes;
15419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %TUnit_Funcs;
15429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %TUnit_Vars;
1543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
154407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenkomy %CppMode = (
1545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>0,
1546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>0 );
1547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %AutoPreambleMode = (
1548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>0,
1549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>0 );
1550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %MinGWMode = (
1551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>0,
1552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>0 );
155301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenkomy %Cpp0xMode = (
155401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko  "1"=>0,
155501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko  "2"=>0 );
1556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Shared Objects
15589927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %RegisteredObjects;
155907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenkomy %RegisteredObjects_Short;
15609927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %RegisteredSONAMEs;
15619927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %RegisteredObject_Dirs;
1562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# System Objects
1564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SystemObjects;
1565570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy @DefaultLibPaths;
15669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %DyLib_DefaultPath;
1567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# System Headers
1569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SystemHeaders;
1570570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy @DefaultCppPaths;
1571570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy @DefaultGccPaths;
1572570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy @DefaultIncPaths;
1573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %DefaultCppHeader;
1574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %DefaultGccHeader;
1575570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy @UsersIncPath;
1576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Merging
1578ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CompleteSignature;
1579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $Version;
1580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %AddedInt;
1581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %RemovedInt;
1582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %AddedInt_Virt;
1583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %RemovedInt_Virt;
1584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %VirtualReplacement;
1585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ChangedTypedef;
1586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CompatRules;
1587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %IncompleteRules;
1588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %UnknownRules;
15891693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkomy %VTableChanged_M;
159062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %ExtendedSymbols;
1591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ReturnedClass;
1592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ParamClass;
15931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkomy %SourceAlternative;
15941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkomy %SourceAlternative_B;
15951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkomy %SourceReplacement;
1596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1597f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko# Calling Conventions
1598f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenkomy %UseConv_Real = (
1599fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  1=>{ "R"=>0, "P"=>0 },
1600fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  2=>{ "R"=>0, "P"=>0 }
1601fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko);
1602fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
1603fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko# ABI Dump
1604fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkomy %UsedDump;
1605f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
1606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# OS Compliance
1607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TargetLibs;
1608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TargetHeaders;
1609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# OS Specifics
1611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $OStarget = $OSgroup;
1612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TargetTools;
1613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Compliance Report
1615dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenkomy %Type_MaxSeverity;
1616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Recursion locks
1618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy @RecurLib;
1619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy @RecurTypes;
16208f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkomy @RecurTypes_Diff;
1621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy @RecurInclude;
1622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy @RecurConstant;
1623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# System
1625570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %SystemPaths = (
1626570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "include"=>[],
1627570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "lib"=>[],
1628570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "bin"=>[]
1629570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko);
1630570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy @DefaultBinPaths;
1631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $GCC_PATH;
1632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Symbols versioning
1634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SymVer = (
1635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>{},
1636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>{} );
1637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Problem descriptions
1639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CompatProblems;
16408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkomy %CompatProblems_Constants;
16418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkomy %CompatProblems_Impl;
1642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TotalAffected;
1643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko# Reports
1645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $ContentID = 1;
1646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $ContentSpanStart = "<span class=\"section\" onclick=\"javascript:showContent(this, 'CONTENT_ID')\">\n";
1647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $ContentSpanStart_Affected = "<span class=\"section_affected\" onclick=\"javascript:showContent(this, 'CONTENT_ID')\">\n";
1648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $ContentSpanStart_Info = "<span class=\"section_info\" onclick=\"javascript:showContent(this, 'CONTENT_ID')\">\n";
1649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $ContentSpanEnd = "</span>\n";
1650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $ContentDivStart = "<div id=\"CONTENT_ID\" style=\"display:none;\">\n";
1651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $ContentDivEnd = "</div>\n";
1652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $Content_Counter = 0;
1653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko# Modes
16551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkomy $JoinReport = 1;
16561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkomy $DoubleReport = 0;
1657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_Modules()
1659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TOOL_DIR = get_dirname($0);
1661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $TOOL_DIR)
1662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # patch for MS Windows
1663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TOOL_DIR = ".";
1664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @SEARCH_DIRS = (
1666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # tool's directory
1667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        abs_path($TOOL_DIR),
1668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # relative path to modules
1669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        abs_path($TOOL_DIR)."/../share/abi-compliance-checker",
167074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        # install path
167174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        'MODULES_INSTALL_PATH'
1672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
1673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $DIR (@SEARCH_DIRS)
1674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not is_abs($DIR))
1676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # relative path
1677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $DIR = abs_path($TOOL_DIR)."/".$DIR;
1678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-d $DIR."/modules") {
1680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $DIR."/modules";
1681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    exitStatus("Module_Error", "can't find modules");
1684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
168601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenkomy %LoadedModules = ();
168701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
1688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub loadModule($)
1689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
169101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(defined $LoadedModules{$Name}) {
169201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        return;
169301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    }
1694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $MODULES_DIR."/Internals/$Name.pm";
1695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not -f $Path) {
1696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Module_Error", "can't access \'$Path\'");
1697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    require $Path;
169901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $LoadedModules{$Name} = 1;
1700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1702570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub readModule($$)
1703570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko{
1704570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my ($Module, $Name) = @_;
1705570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my $Path = $MODULES_DIR."/Internals/$Module/".$Name;
1706570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(not -f $Path) {
1707570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        exitStatus("Module_Error", "can't access \'$Path\'");
1708570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
1709570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    return readFile($Path);
1710570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko}
1711570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
17120d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub showPos($)
1713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1714dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my $Number = $_[0];
1715dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if(not $Number) {
1716dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        $Number = 1;
1717dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
1718dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    else {
1719dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        $Number = int($Number)+1;
1720dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
1721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Number>3) {
1722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Number."th";
1723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Number==1) {
1725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "1st";
1726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Number==2) {
1728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "2nd";
1729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Number==3) {
1731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "3rd";
1732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
1734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Number;
1735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub search_Tools($)
1739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
1741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Name);
1742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my @Paths = keys(%TargetTools))
1743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Path (@Paths)
1745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
174674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(-f join_P($Path, $Name)) {
174774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                return join_P($Path, $Name);
1748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CrossPrefix)
1750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # user-defined prefix (arm-none-symbianelf, ...)
175174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                my $Candidate = join_P($Path, $CrossPrefix."-".$Name);
1752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(-f $Candidate) {
1753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    return $Candidate;
1754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1758ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
1759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
1760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub synch_Cmd($)
1764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
1766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $GCC_PATH)
1767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # GCC was not found yet
1768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
1769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Candidate = $GCC_PATH;
177162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($Candidate=~s/\bgcc(|\.\w+)\Z/$Name$1/) {
1772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Candidate;
1773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
1775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_CmdPath($)
1778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
1780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Name);
1781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Cache{"get_CmdPath"}{$Name}) {
1782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"get_CmdPath"}{$Name};
1783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %BinUtils = map {$_=>1} (
1785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "c++filt",
1786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "objdump",
1787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "readelf"
1788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
178962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($BinUtils{$Name} and $GCC_PATH)
179062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
1791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $Dir = get_dirname($GCC_PATH)) {
1792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TargetTools{$Dir}=1;
1793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = search_Tools($Name);
1796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Path and $OSgroup eq "windows") {
1797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = search_Tools($Name.".exe");
1798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Path and $BinUtils{$Name})
1800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CrossPrefix)
1802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # user-defined prefix
1803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Path = search_Cmd($CrossPrefix."-".$Name);
1804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Path and $BinUtils{$Name})
1807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $Candidate = synch_Cmd($Name))
1809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # synch with GCC
1810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Candidate=~/[\/\\]/)
18111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # command path
1812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(-f $Candidate) {
1813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Path = $Candidate;
1814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Candidate = search_Cmd($Candidate))
18171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # command name
1818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Path = $Candidate;
1819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Path) {
1823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = search_Cmd($Name);
1824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Path and $OSgroup eq "windows")
18261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # search for *.exe file
1827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path=search_Cmd($Name.".exe");
1828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Path=~/\s/) {
1830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = "\"".$Path."\"";
1831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"get_CmdPath"}{$Name}=$Path);
1833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub search_Cmd($)
1836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
1838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Name);
1839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Cache{"search_Cmd"}{$Name}) {
1840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"search_Cmd"}{$Name};
1841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $DefaultPath = get_CmdPath_Default($Name)) {
1843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ($Cache{"search_Cmd"}{$Name} = $DefaultPath);
1844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1845570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Path (@{$SystemPaths{"bin"}})
1846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
184774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my $CmdPath = join_P($Path,$Name);
1848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-f $CmdPath)
1849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Name=~/gcc/) {
185162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                next if(not check_gcc($CmdPath, "3"));
1852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return ($Cache{"search_Cmd"}{$Name} = $CmdPath);
1854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"search_Cmd"}{$Name} = "");
1857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_CmdPath_Default($)
1860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # search in PATH
186162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "" if(not $_[0]);
186262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"get_CmdPath_Default"}{$_[0]}) {
186362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"get_CmdPath_Default"}{$_[0]};
1864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
186562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return ($Cache{"get_CmdPath_Default"}{$_[0]} = get_CmdPath_Default_I($_[0]));
186662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
186762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
186862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub get_CmdPath_Default_I($)
186962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{ # search in PATH
187062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $Name = $_[0];
1871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Name=~/find/)
1872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # special case: search for "find" utility
1873a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if(`find \"$TMP_DIR\" -maxdepth 0 2>\"$TMP_DIR/null\"`) {
187462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return "find";
1875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Name=~/gcc/) {
187862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return check_gcc($Name, "3");
1879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1880570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(checkCmd($Name)) {
188162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Name;
1882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
188362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($OSgroup eq "windows")
188462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
1885a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if(`$Name /? 2>\"$TMP_DIR/null\"`) {
188662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $Name;
188762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1889570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Path (@DefaultBinPaths)
1890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-f $Path."/".$Name) {
189274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            return join_P($Path, $Name);
1893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
189562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
1896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub classifyPath($)
1899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
1901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Path=~/[\*\[]/)
1902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # wildcard
1903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path=~s/\*/.*/g;
1904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path=~s/\\/\\\\/g;
1905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ($Path, "Pattern");
1906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Path=~/[\/\\]/)
1908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # directory or relative path
1909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return (path_format($Path, $OSgroup), "Path");
1910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
1912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ($Path, "Name");
1913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub readDescriptor($$)
1917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($LibVersion, $Content) = @_;
1919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(not $LibVersion);
1920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $DName = $DumpAPI?"descriptor":"descriptor \"d$LibVersion\"";
1921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Content) {
1922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Error", "$DName is empty");
1923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Content!~/\</) {
19255c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        exitStatus("Error", "incorrect descriptor (see -d1 option)");
1926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s/\/\*(.|\n)+?\*\///g;
1928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s/<\!--(.|\n)+?-->//g;
1929570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
1930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Descriptor{$LibVersion}{"Version"} = parseTag(\$Content, "version");
1931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TargetVersion{$LibVersion}) {
1932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Descriptor{$LibVersion}{"Version"} = $TargetVersion{$LibVersion};
1933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Descriptor{$LibVersion}{"Version"}) {
1935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Error", "version in the $DName is not specified (<version> section)");
1936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Content=~/{RELPATH}/)
1938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $RelDir = $RelativeDirectory{$LibVersion}) {
1940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Content =~ s/{RELPATH}/$RelDir/g;
1941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
1943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $NeedRelpath = $DumpAPI?"-relpath":"-relpath$LibVersion";
1945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "you have not specified $NeedRelpath option, but the $DName contains {RELPATH} macro");
1946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $CheckObjectsOnly_Opt)
1950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $DHeaders = parseTag(\$Content, "headers");
1952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $DHeaders) {
1953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "header files in the $DName are not specified (<headers> section)");
1954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(lc($DHeaders) ne "none")
1956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # append the descriptor headers list
1957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Descriptor{$LibVersion}{"Headers"})
1958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # multiple descriptors
1959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Descriptor{$LibVersion}{"Headers"} .= "\n".$DHeaders;
1960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
1962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Descriptor{$LibVersion}{"Headers"} = $DHeaders;
1963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Path (split(/\s*\n\s*/, $DHeaders))
1965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
1966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not -e $Path) {
1967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    exitStatus("Access_Error", "can't access \'$Path\'");
1968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $CheckHeadersOnly_Opt)
1973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $DObjects = parseTag(\$Content, "libs");
1975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $DObjects) {
1976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "$SLIB_TYPE libraries in the $DName are not specified (<libs> section)");
1977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(lc($DObjects) ne "none")
1979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # append the descriptor libraries list
1980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Descriptor{$LibVersion}{"Libs"})
1981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # multiple descriptors
1982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Descriptor{$LibVersion}{"Libs"} .= "\n".$DObjects;
1983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
1985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Descriptor{$LibVersion}{"Libs"} .= $DObjects;
1986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Path (split(/\s*\n\s*/, $DObjects))
1988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
1989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not -e $Path) {
1990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    exitStatus("Access_Error", "can't access \'$Path\'");
1991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, parseTag(\$Content, "search_headers")))
1996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -d $Path) {
1998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access directory \'$Path\'");
1999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20008f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Path = get_abs_path($Path);
2001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = path_format($Path, $OSgroup);
2002570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push_U($SystemPaths{"include"}, $Path);
2003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, parseTag(\$Content, "search_libs")))
2005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -d $Path) {
2007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access directory \'$Path\'");
2008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Path = get_abs_path($Path);
2010ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = path_format($Path, $OSgroup);
2011570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push_U($SystemPaths{"lib"}, $Path);
2012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, parseTag(\$Content, "tools")))
2014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -d $Path) {
2016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access directory \'$Path\'");
2017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20188f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Path = get_abs_path($Path);
2019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = path_format($Path, $OSgroup);
2020570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push_U($SystemPaths{"bin"}, $Path);
2021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TargetTools{$Path}=1;
2022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Prefix = parseTag(\$Content, "cross_prefix")) {
2024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $CrossPrefix = $Prefix;
2025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2026570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $Descriptor{$LibVersion}{"IncludePaths"} = [] if(not defined $Descriptor{$LibVersion}{"IncludePaths"}); # perl 5.8 doesn't support //=
2027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, parseTag(\$Content, "include_paths")))
2028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -d $Path) {
2030ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access directory \'$Path\'");
2031ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Path = get_abs_path($Path);
2033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = path_format($Path, $OSgroup);
2034570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push(@{$Descriptor{$LibVersion}{"IncludePaths"}}, $Path);
2035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2036570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $Descriptor{$LibVersion}{"AddIncludePaths"} = [] if(not defined $Descriptor{$LibVersion}{"AddIncludePaths"});
2037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, parseTag(\$Content, "add_include_paths")))
2038ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -d $Path) {
2040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access directory \'$Path\'");
2041ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Path = get_abs_path($Path);
2043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = path_format($Path, $OSgroup);
2044570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push(@{$Descriptor{$LibVersion}{"AddIncludePaths"}}, $Path);
2045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2046ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, parseTag(\$Content, "skip_include_paths")))
20478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # skip some auto-generated include paths
20488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not is_abs($Path))
20498f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
20508f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(my $P = abs_path($Path)) {
20518f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $Path = $P;
20528f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
20538f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
2054570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        $Skip_Include_Paths{$LibVersion}{path_format($Path)} = 1;
2055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2056ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, parseTag(\$Content, "skip_including")))
20578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # skip direct including of some headers
2058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($CPath, $Type) = classifyPath($Path);
2059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SkipHeaders{$LibVersion}{$Type}{$CPath} = 2;
2060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Descriptor{$LibVersion}{"GccOptions"} = parseTag(\$Content, "gcc_options");
206274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    foreach my $Option (split(/\s*\n\s*/, $Descriptor{$LibVersion}{"GccOptions"}))
206374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    {
20648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Option!~/\A\-(Wl|l|L)/)
20658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # skip linker options
206674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $CompilerOptions{$LibVersion} .= " ".$Option;
206774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
2068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Descriptor{$LibVersion}{"SkipHeaders"} = parseTag(\$Content, "skip_headers");
2070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, $Descriptor{$LibVersion}{"SkipHeaders"}))
2071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SkipHeadersList{$LibVersion}{$Path} = 1;
2073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($CPath, $Type) = classifyPath($Path);
2074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SkipHeaders{$LibVersion}{$Type}{$CPath} = 1;
2075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Descriptor{$LibVersion}{"SkipLibs"} = parseTag(\$Content, "skip_libs");
2077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, $Descriptor{$LibVersion}{"SkipLibs"}))
2078ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($CPath, $Type) = classifyPath($Path);
2080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SkipLibs{$LibVersion}{$Type}{$CPath} = 1;
2081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $DDefines = parseTag(\$Content, "defines"))
2083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Descriptor{$LibVersion}{"Defines"})
2085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # multiple descriptors
2086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Descriptor{$LibVersion}{"Defines"} .= "\n".$DDefines;
2087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
2089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Descriptor{$LibVersion}{"Defines"} = $DDefines;
2090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Order (split(/\s*\n\s*/, parseTag(\$Content, "include_order")))
2093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Order=~/\A(.+):(.+)\Z/) {
2095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Include_Order{$LibVersion}{$1} = $2;
2096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Type_Name (split(/\s*\n\s*/, parseTag(\$Content, "opaque_types")),
2099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    split(/\s*\n\s*/, parseTag(\$Content, "skip_types")))
21001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # opaque_types renamed to skip_types (1.23.4)
2101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SkipTypes{$LibVersion}{$Type_Name} = 1;
2102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Symbol (split(/\s*\n\s*/, parseTag(\$Content, "skip_interfaces")),
2104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    split(/\s*\n\s*/, parseTag(\$Content, "skip_symbols")))
21051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # skip_interfaces renamed to skip_symbols (1.22.1)
2106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SkipSymbols{$LibVersion}{$Symbol} = 1;
2107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $NameSpace (split(/\s*\n\s*/, parseTag(\$Content, "skip_namespaces"))) {
2109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SkipNameSpaces{$LibVersion}{$NameSpace} = 1;
2110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2111a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    foreach my $NameSpace (split(/\s*\n\s*/, parseTag(\$Content, "add_namespaces"))) {
2112a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        $AddNameSpaces{$LibVersion}{$NameSpace} = 1;
2113a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    }
2114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Constant (split(/\s*\n\s*/, parseTag(\$Content, "skip_constants"))) {
2115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SkipConstants{$LibVersion}{$Constant} = 1;
2116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $DIncPreamble = parseTag(\$Content, "include_preamble"))
2118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Descriptor{$LibVersion}{"IncludePreamble"})
21201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # multiple descriptors
2121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Descriptor{$LibVersion}{"IncludePreamble"} .= "\n".$DIncPreamble;
2122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
2124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Descriptor{$LibVersion}{"IncludePreamble"} = $DIncPreamble;
2125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
212901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenkosub parseTag(@)
2130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
213101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $CodeRef = shift(@_);
213201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $Tag = shift(@_);
213301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(not $Tag or not $CodeRef) {
213401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        return undef;
213501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    }
213601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $Sp = 0;
213701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(@_) {
213801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $Sp = shift(@_);
213901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    }
214001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $Start = index(${$CodeRef}, "<$Tag>");
214101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if($Start!=-1)
2142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
214301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        my $End = index(${$CodeRef}, "</$Tag>");
214401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if($End!=-1)
214501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        {
214601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            my $TS = length($Tag)+3;
214701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            my $Content = substr(${$CodeRef}, $Start, $End-$Start+$TS, "");
214801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            substr($Content, 0, $TS-1, ""); # cut start tag
214901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            substr($Content, -$TS, $TS, ""); # cut end tag
215001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if(not $Sp)
215101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            {
215201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $Content=~s/\A\s+//g;
215301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $Content=~s/\s+\Z//g;
215401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
215501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if(substr($Content, 0, 1) ne "<") {
215601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $Content = xmlSpecChars_R($Content);
215701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
215801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            return $Content;
215901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
2160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
216101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    return undef;
216201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko}
216301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
2164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getInfo($)
2165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2166850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my $DumpPath = $_[0];
2167850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return if(not $DumpPath or not -f $DumpPath);
2168850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2169850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    readTUDump($DumpPath);
2170850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # processing info
2172ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    setTemplateParams_All();
21734b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko
217474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraDump) {
21754b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        setAnonTypedef_All();
21764b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    }
21774b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko
2178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    getTypeInfo_All();
2179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    simplifyNames();
218082bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    simplifyConstants();
2181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    getVarInfo_All();
218201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    getSymbolInfo_All();
2183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2184850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
2185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    %LibInfo = ();
2186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    %TemplateInstance = ();
2187177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    %BasicTemplate = ();
2188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    %MangledNames = ();
2189850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %TemplateDecl = ();
2190850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %StdCxxTypedef = ();
2191850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %MissedTypedef = ();
2192850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %Typedef_Tr = ();
2193850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %Typedef_Eq = ();
21944b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    %TypedefToAnon = ();
2195850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
219662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    # clean cache
219762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    delete($Cache{"getTypeAttr"});
219862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    delete($Cache{"getTypeDeclId"});
219962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
220074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraDump)
2201570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
2202177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        remove_Unused($Version, "Extra");
220374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
220474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    else
220574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    { # remove unused types
2206570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if($BinaryOnly and not $ExtendedCheck)
2207570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        { # --binary
2208177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            remove_Unused($Version, "All");
2209570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
2210570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        else {
2211177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            remove_Unused($Version, "Extended");
2212177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2213177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2214177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2215177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($CheckInfo)
2216177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
2217177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Tid (keys(%{$TypeInfo{$Version}})) {
2218177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            check_Completeness($TypeInfo{$Version}{$Tid}, $Version);
2219177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2220177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2221177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Sid (keys(%{$SymbolInfo{$Version}})) {
2222177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            check_Completeness($SymbolInfo{$Version}{$Sid}, $Version);
2223570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
222462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
222562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
2226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Debug) {
2227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # debugMangling($Version);
2228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2231850437949b65b213696469223d749c1f74c29601Andrey Ponomarenkosub readTUDump($)
2232850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko{
2233850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my $DumpPath = $_[0];
2234850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2235850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    open(TU_DUMP, $DumpPath);
2236850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    local $/ = undef;
2237850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my $Content = <TU_DUMP>;
2238850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    close(TU_DUMP);
2239850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2240850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    unlink($DumpPath);
2241850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2242850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    $Content=~s/\n[ ]+/ /g;
2243850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my @Lines = split("\n", $Content);
2244850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2245850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
2246850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    undef $Content;
2247850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2248177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    $MAX_ID = $#Lines+1; # number of lines == number of nodes
2249850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2250850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    foreach (0 .. $#Lines)
2251850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
225262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Lines[$_]=~/\A\@(\d+)[ ]+([a-z_]+)[ ]+(.+)\Z/i)
2253850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # get a number and attributes of a node
2254850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            next if(not $NodeType{$2});
2255850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            $LibInfo{$Version}{"info_type"}{$1}=$2;
2256850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            $LibInfo{$Version}{"info"}{$1}=$3;
2257850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
2258850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2259850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        # clean memory
2260850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        delete($Lines[$_]);
2261850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
2262850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2263850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
2264850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    undef @Lines;
2265850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko}
2266850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
226782bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenkosub simplifyConstants()
226882bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko{
226982bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    foreach my $Constant (keys(%{$Constants{$Version}}))
227082bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    {
2271fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(defined $Constants{$Version}{$Constant}{"Header"})
2272fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
2273fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my $Value = $Constants{$Version}{$Constant}{"Value"};
2274fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(defined $EnumConstants{$Version}{$Value}) {
2275fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $Constants{$Version}{$Constant}{"Value"} = $EnumConstants{$Version}{$Value}{"Value"};
2276fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
227782bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko        }
227882bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    }
227982bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko}
228082bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko
2281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub simplifyNames()
2282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Base (keys(%{$Typedef_Tr{$Version}}))
2284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2285f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($Typedef_Eq{$Version}{$Base}) {
2286f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            next;
2287f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
2288f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my @Translations = sort keys(%{$Typedef_Tr{$Version}{$Base}});
2289f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($#Translations==0)
2290f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        {
2291f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if(length($Translations[0])<=length($Base)) {
2292f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                $Typedef_Eq{$Version}{$Base} = $Translations[0];
2293f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
2294f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
2295f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        else
2296f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        { # select most appropriate
2297f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            foreach my $Tr (@Translations)
2298f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            {
2299f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                if($Base=~/\A\Q$Tr\E/)
2300f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
2301f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    $Typedef_Eq{$Version}{$Base} = $Tr;
2302f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    last;
2303f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                }
2304f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
2305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2307b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    foreach my $TypeId (keys(%{$TypeInfo{$Version}}))
2308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2309b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        my $TypeName = $TypeInfo{$Version}{$TypeId}{"Name"};
231062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $TypeName) {
231162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            next;
231262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
231362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        next if(index($TypeName,"<")==-1);# template instances only
231462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($TypeName=~/>(::\w+)+\Z/)
231562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # skip unused types
231662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            next;
2317f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
231862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $Base (sort {length($b)<=>length($a)}
231962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        sort {$b cmp $a} keys(%{$Typedef_Eq{$Version}}))
232062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
232162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            next if(not $Base);
232262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            next if(index($TypeName,$Base)==-1);
232362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            next if(length($TypeName) - length($Base) <= 3);
2324f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if(my $Typedef = $Typedef_Eq{$Version}{$Base})
2325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
2326f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                $TypeName=~s/(\<|\,)\Q$Base\E(\W|\Z)/$1$Typedef$2/g;
2327f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                $TypeName=~s/(\<|\,)\Q$Base\E(\w|\Z)/$1$Typedef $2/g;
2328f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                if(defined $TypeInfo{$Version}{$TypeId}{"TParam"})
2329850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                {
2330f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    foreach my $TPos (keys(%{$TypeInfo{$Version}{$TypeId}{"TParam"}}))
2331f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    {
2332f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if(my $TPName = $TypeInfo{$Version}{$TypeId}{"TParam"}{$TPos}{"name"})
2333f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        {
2334f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            $TPName=~s/\A\Q$Base\E(\W|\Z)/$Typedef$1/g;
2335f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            $TPName=~s/\A\Q$Base\E(\w|\Z)/$Typedef $1/g;
23369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            $TypeInfo{$Version}{$TypeId}{"TParam"}{$TPos}{"name"} = formatName($TPName, "T");
2337f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
2338f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    }
2339850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
2340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
23429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $TypeName = formatName($TypeName, "T");
2343b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        $TypeInfo{$Version}{$TypeId}{"Name"} = $TypeName;
2344b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        $TName_Tid{$Version}{$TypeName} = $TypeId;
2345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
23484b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenkosub setAnonTypedef_All()
23494b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko{
23504b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    foreach my $InfoId (keys(%{$LibInfo{$Version}{"info"}}))
23514b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    {
23524b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$InfoId} eq "type_decl")
23534b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        {
23544b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            if(isAnon(getNameByInfo($InfoId))) {
23554b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                $TypedefToAnon{getTypeId($InfoId)} = 1;
23564b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            }
23574b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        }
23584b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    }
23594b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko}
23604b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko
2361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setTemplateParams_All()
2362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (keys(%{$LibInfo{$Version}{"info"}}))
2364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$_} eq "template_decl") {
2366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            setTemplateParams($_);
2367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setTemplateParams($)
2372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2373177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $Tid = getTypeId($_[0]);
2374989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$_[0]})
2375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2376989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/(inst|spcs)[ ]*:[ ]*@(\d+) /)
2377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
237862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $TmplInst_Id = $2;
2379177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            setTemplateInstParams($_[0], $TmplInst_Id);
238062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            while($TmplInst_Id = getNextElem($TmplInst_Id)) {
2381177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                setTemplateInstParams($_[0], $TmplInst_Id);
2382177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2383177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2384177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2385177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $BasicTemplate{$Version}{$Tid} = $_[0];
2386177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2387177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $Prms = getTreeAttr_Prms($_[0]))
2388177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2389177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(my $Valu = getTreeAttr_Valu($Prms))
2390177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
2391177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                my $Vector = getTreeVec($Valu);
2392177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach my $Pos (sort {int($a)<=>int($b)} keys(%{$Vector}))
2393177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
2394177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if(my $Val = getTreeAttr_Valu($Vector->{$Pos}))
2395177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
2396177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        if(my $Name = getNameByInfo($Val))
2397177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        {
2398177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            $TemplateArg{$Version}{$_[0]}{$Pos} = $Name;
2399177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            if($LibInfo{$Version}{"info_type"}{$Val} eq "parm_decl") {
2400177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                                $TemplateInstance{$Version}{"Type"}{$Tid}{$Pos} = $Val;
2401177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            }
2402177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            else {
2403177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                                $TemplateInstance{$Version}{"Type"}{$Tid}{$Pos} = getTreeAttr_Type($Val);
2404177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            }
2405177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        }
2406177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
2407177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
2408989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
2409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
241162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $TypeId = getTreeAttr_Type($_[0]))
2412850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
2413850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(my $IType = $LibInfo{$Version}{"info_type"}{$TypeId})
2414850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
2415850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($IType eq "record_type") {
2416177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $TemplateDecl{$Version}{$TypeId} = 1;
2417850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
2418850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
2419850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
2420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2422177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub setTemplateInstParams($$)
2423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2424177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($Tmpl, $Inst) = @_;
2425177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2426177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$Inst})
2427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2428989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        my ($Params_InfoId, $ElemId) = ();
2429989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/purp[ ]*:[ ]*@(\d+) /) {
2430989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            $Params_InfoId = $1;
2431989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
2432989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/valu[ ]*:[ ]*@(\d+) /) {
2433989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            $ElemId = $1;
2434989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
2435989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Params_InfoId and $ElemId)
2436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
2437989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            my $Params_Info = $LibInfo{$Version}{"info"}{$Params_InfoId};
2438989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            while($Params_Info=~s/ (\d+)[ ]*:[ ]*\@(\d+) / /)
2439989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
2440989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                my ($PPos, $PTypeId) = ($1, $2);
2441989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                if(my $PType = $LibInfo{$Version}{"info_type"}{$PTypeId})
2442989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                {
2443177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if($PType eq "template_type_parm") {
2444177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $TemplateDecl{$Version}{$ElemId} = 1;
2445989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    }
2446989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
2447850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($LibInfo{$Version}{"info_type"}{$ElemId} eq "function_decl")
2448850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # functions
244962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $TemplateInstance{$Version}{"Func"}{$ElemId}{$PPos} = $PTypeId;
2450177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $BasicTemplate{$Version}{$ElemId} = $Tmpl;
2451989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
2452850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                else
2453850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # types
245462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $TemplateInstance{$Version}{"Type"}{$ElemId}{$PPos} = $PTypeId;
2455177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $BasicTemplate{$Version}{$ElemId} = $Tmpl;
2456989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
2457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTypeDeclId($)
2463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
246462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0])
2465dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
246662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(defined $Cache{"getTypeDeclId"}{$Version}{$_[0]}) {
246762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $Cache{"getTypeDeclId"}{$Version}{$_[0]};
246862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
246962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $Info = $LibInfo{$Version}{"info"}{$_[0]})
247062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
247162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($Info=~/name[ ]*:[ ]*@(\d+)/) {
247262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return ($Cache{"getTypeDeclId"}{$Version}{$_[0]} = $1);
247362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2474dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
2475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
247662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return ($Cache{"getTypeDeclId"}{$Version}{$_[0]} = 0);
2477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTypeInfo_All()
2480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
248162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not check_gcc($GCC_PATH, "4.5"))
2482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for GCC < 4.5
2483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # missed typedefs: QStyle::State is typedef to QFlags<QStyle::StateFlag>
2484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # but QStyleOption.state is of type QFlags<QStyle::StateFlag> in the TU dump
2485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # FIXME: check GCC versions
2486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        addMissedTypes_Pre();
2487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
248862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
2489ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (sort {int($a)<=>int($b)} keys(%{$LibInfo{$Version}{"info"}}))
24900d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # forward order only
2491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $IType = $LibInfo{$Version}{"info_type"}{$_};
2492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($IType=~/_type\Z/ and $IType ne "function_type"
2493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $IType ne "method_type") {
249462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            getTypeInfo("$_");
2495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
249762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
249862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    # add "..." type
249901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $TypeInfo{$Version}{"-1"} = {
250062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        "Name" => "...",
250162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        "Type" => "Intrinsic",
250201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        "Tid" => "-1"
250362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    };
250401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $TName_Tid{$Version}{"..."} = "-1";
250562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
250662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not check_gcc($GCC_PATH, "4.5"))
2507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for GCC < 4.5
2508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        addMissedTypes_Post();
2509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2510177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2511177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($ADD_TMPL_INSTANCES)
2512177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
2513177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        # templates
2514177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Tid (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$Version}}))
2515177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2516177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $TemplateMap{$Version}{$Tid}
2517177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            and not defined $TypeInfo{$Version}{$Tid}{"Template"})
2518177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
2519177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(defined $TypeInfo{$Version}{$Tid}{"Memb"})
2520177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
2521177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    foreach my $Pos (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$Version}{$Tid}{"Memb"}}))
2522177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
2523177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        if(my $MembTypeId = $TypeInfo{$Version}{$Tid}{"Memb"}{$Pos}{"type"})
2524177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        {
2525177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            if(my %MAttr = getTypeAttr($MembTypeId))
2526177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            {
2527177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                                $TypeInfo{$Version}{$Tid}{"Memb"}{$Pos}{"algn"} = $MAttr{"Algn"};
2528177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                                $MembTypeId = $TypeInfo{$Version}{$Tid}{"Memb"}{$Pos}{"type"} = instType($TemplateMap{$Version}{$Tid}, $MembTypeId, $Version);
2529177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            }
2530177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        }
2531177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
2532177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
2533177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(defined $TypeInfo{$Version}{$Tid}{"Base"})
2534177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
2535177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    foreach my $Bid (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$Version}{$Tid}{"Base"}}))
2536177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
2537177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        my $NBid = instType($TemplateMap{$Version}{$Tid}, $Bid, $Version);
2538177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2539177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        if($NBid ne $Bid)
2540177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        {
2541177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            %{$TypeInfo{$Version}{$Tid}{"Base"}{$NBid}} = %{$TypeInfo{$Version}{$Tid}{"Base"}{$Bid}};
2542177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            delete($TypeInfo{$Version}{$Tid}{"Base"}{$Bid});
2543177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        }
2544177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
2545177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
2546177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2547177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2548177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2549177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
2550177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2551177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub createType($$)
2552177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{
2553177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($Attr, $LibVersion) = @_;
2554177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $NewId = ++$MAX_ID;
2555177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2556082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko    $Attr->{"Tid"} = $NewId;
2557177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    $TypeInfo{$Version}{$NewId} = $Attr;
2558e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    $TName_Tid{$Version}{formatName($Attr->{"Name"}, "T")} = $NewId;
2559177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2560177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    return "$NewId";
2561177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
2562177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2563177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub instType($$$)
2564177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{ # create template instances
2565177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($Map, $Tid, $LibVersion) = @_;
2566be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko
2567be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko    if(not $TypeInfo{$LibVersion}{$Tid}) {
2568be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko        return undef;
2569be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko    }
2570177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $Attr = dclone($TypeInfo{$LibVersion}{$Tid});
2571177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2572177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $Key (sort keys(%{$Map}))
2573177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
2574177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $Val = $Map->{$Key})
2575177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2576177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $Attr->{"Name"}=~s/\b$Key\b/$Val/g;
2577177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2578177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $Attr->{"NameSpace"}) {
2579177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $Attr->{"NameSpace"}=~s/\b$Key\b/$Val/g;
2580177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2581177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            foreach (keys(%{$Attr->{"TParam"}})) {
2582177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $Attr->{"TParam"}{$_}{"name"}=~s/\b$Key\b/$Val/g;
2583177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2584177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2585177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        else
2586177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # remove absent
2587177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko          # _Traits, etc.
2588177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $Attr->{"Name"}=~s/,\s*\b$Key(,|>)/$1/g;
2589e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            if(defined $Attr->{"NameSpace"}) {
2590177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $Attr->{"NameSpace"}=~s/,\s*\b$Key(,|>)/$1/g;
2591177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2592177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            foreach (keys(%{$Attr->{"TParam"}}))
2593177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
2594177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if($Attr->{"TParam"}{$_}{"name"} eq $Key) {
2595177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    delete($Attr->{"TParam"}{$_});
2596177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
2597e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                else {
2598177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $Attr->{"TParam"}{$_}{"name"}=~s/,\s*\b$Key(,|>)/$1/g;
2599177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
2600177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2601177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2602177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2603177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2604177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $Tmpl = 0;
2605177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2606177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Attr->{"TParam"})
2607177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
2608177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach (sort {int($a)<=>int($b)} keys(%{$Attr->{"TParam"}}))
2609177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2610177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            my $PName = $Attr->{"TParam"}{$_}{"name"};
2611177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2612177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(my $PTid = $TName_Tid{$LibVersion}{$PName})
2613177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
2614177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                my %Base = get_BaseType($PTid, $LibVersion);
2615177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2616177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if($Base{"Type"} eq "TemplateParam"
2617177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                or defined $Base{"Template"})
2618177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
2619177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $Tmpl = 1;
2620177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    last
2621177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
2622177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2623177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2624177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2625177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2626177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $Id = getTypeIdByName($Attr->{"Name"}, $LibVersion)) {
2627177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return "$Id";
2628177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2629177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    else
2630177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
2631177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not $Tmpl) {
2632177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            delete($Attr->{"Template"});
2633177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2634177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2635e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        my $New = createType($Attr, $LibVersion);
2636e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
2637177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        my %EMap = ();
2638177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(defined $TemplateMap{$LibVersion}{$Tid}) {
2639177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            %EMap = %{$TemplateMap{$LibVersion}{$Tid}};
2640177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2641177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach (keys(%{$Map})) {
2642177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $EMap{$_} = $Map->{$_};
2643177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2644177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2645e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        if(defined $TypeInfo{$LibVersion}{$New}{"BaseType"}) {
2646e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            $TypeInfo{$LibVersion}{$New}{"BaseType"} = instType(\%EMap, $TypeInfo{$LibVersion}{$New}{"BaseType"}, $LibVersion);
2647177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2648e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        if(defined $TypeInfo{$LibVersion}{$New}{"Base"})
2649177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2650e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            foreach my $Bid (keys(%{$TypeInfo{$LibVersion}{$New}{"Base"}}))
2651177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
2652177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                my $NBid = instType(\%EMap, $Bid, $LibVersion);
2653177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2654177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if($NBid ne $Bid)
2655177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
2656e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    %{$TypeInfo{$LibVersion}{$New}{"Base"}{$NBid}} = %{$TypeInfo{$LibVersion}{$New}{"Base"}{$Bid}};
2657e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    delete($TypeInfo{$LibVersion}{$New}{"Base"}{$Bid});
2658177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
2659177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2660177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2661177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2662e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        if(defined $TypeInfo{$LibVersion}{$New}{"Memb"})
2663177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2664be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko            foreach (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}{$New}{"Memb"}}))
2665be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko            {
2666be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko                if(defined $TypeInfo{$LibVersion}{$New}{"Memb"}{$_}{"type"}) {
2667be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko                    $TypeInfo{$LibVersion}{$New}{"Memb"}{$_}{"type"} = instType(\%EMap, $TypeInfo{$LibVersion}{$New}{"Memb"}{$_}{"type"}, $LibVersion);
2668be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko                }
2669177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2670177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2671177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2672e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        if(defined $TypeInfo{$LibVersion}{$New}{"Param"})
2673177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2674e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            foreach (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}{$New}{"Param"}})) {
2675e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                $TypeInfo{$LibVersion}{$New}{"Param"}{$_}{"type"} = instType(\%EMap, $TypeInfo{$LibVersion}{$New}{"Param"}{$_}{"type"}, $LibVersion);
2676177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2677177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2678177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2679e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        if(defined $TypeInfo{$LibVersion}{$New}{"Return"}) {
2680e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            $TypeInfo{$LibVersion}{$New}{"Return"} = instType(\%EMap, $TypeInfo{$LibVersion}{$New}{"Return"}, $LibVersion);
2681177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2682177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2683e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        return $New;
2684177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub addMissedTypes_Pre()
2688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
268962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %MissedTypes = ();
2690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $MissedTDid (sort {int($a)<=>int($b)} keys(%{$LibInfo{$Version}{"info"}}))
2691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # detecting missed typedefs
2692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$MissedTDid} eq "type_decl")
2693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
269462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $TypeId = getTreeAttr_Type($MissedTDid);
2695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(not $TypeId);
269662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $TypeType = getTypeType($TypeId);
2697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($TypeType eq "Unknown")
2698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # template_type_parm
2699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
2700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $TypeDeclId = getTypeDeclId($TypeId);
2702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if($TypeDeclId eq $MissedTDid);#or not $TypeDeclId
2703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $TypedefName = getNameByInfo($MissedTDid);
2704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(not $TypedefName);
2705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if($TypedefName eq "__float80");
2706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(isAnon($TypedefName));
2707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $TypeDeclId
2708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            or getNameByInfo($TypeDeclId) ne $TypedefName) {
270962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $MissedTypes{$Version}{$TypeId}{$MissedTDid} = 1;
2710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2713b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    my %AddTypes = ();
271462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $Tid (keys(%{$MissedTypes{$Version}}))
2715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # add missed typedefs
271662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my @Missed = keys(%{$MissedTypes{$Version}{$Tid}});
2717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not @Missed or $#Missed>=1) {
2718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
2719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $MissedTDid = $Missed[0];
2721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($TypedefName, $TypedefNS) = getTrivialName($MissedTDid, $Tid);
2722b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        if(not $TypedefName) {
2723b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            next;
2724b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        }
2725177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        my $NewId = ++$MAX_ID;
2726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my %MissedInfo = ( # typedef info
2727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "Name" => $TypedefName,
2728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "NameSpace" => $TypedefNS,
2729fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            "BaseType" => $Tid,
2730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "Type" => "Typedef",
2731177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            "Tid" => "$NewId" );
2732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($H, $L) = getLocation($MissedTDid);
2733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MissedInfo{"Header"} = $H;
2734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MissedInfo{"Line"} = $L;
2735b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        if($TypedefName=~/\*|\&|\s/)
2736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # other types
2737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
2738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2739b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        if($TypedefName=~/>(::\w+)+\Z/)
2740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # QFlags<Qt::DropAction>::enum_type
2741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
2742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
274362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(getTypeType($Tid)=~/\A(Intrinsic|Union|Struct|Enum|Class)\Z/)
2744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # double-check for the name of typedef
274562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my ($TName, $TNS) = getTrivialName(getTypeDeclId($Tid), $Tid); # base type info
2746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(not $TName);
2747b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if(length($TypedefName)>=length($TName))
2748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # too long typedef
2749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
2750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2751b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if($TName=~/\A\Q$TypedefName\E</) {
2752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
2753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2754b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if($TypedefName=~/\A\Q$TName\E/)
2755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # QDateTimeEdit::Section and QDateTimeEdit::Sections::enum_type
2756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
2757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2758b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if(get_depth($TypedefName)==0 and get_depth($TName)!=0)
2759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # std::_Vector_base and std::vector::_Base
2760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
2761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2763b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko
2764b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        $AddTypes{$MissedInfo{"Tid"}} = \%MissedInfo;
2765b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko
2766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # register typedef
2767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MissedTypedef{$Version}{$Tid}{"Tid"} = $MissedInfo{"Tid"};
276862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $MissedTypedef{$Version}{$Tid}{"TDid"} = $MissedTDid;
2769b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        $TName_Tid{$Version}{$TypedefName} = $MissedInfo{"Tid"};
2770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2771b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko
2772b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    # add missed & remove other
2773b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    $TypeInfo{$Version} = \%AddTypes;
2774b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    delete($Cache{"getTypeAttr"}{$Version});
2775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub addMissedTypes_Post()
2778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $BaseId (keys(%{$MissedTypedef{$Version}}))
2780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
278162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $Tid = $MissedTypedef{$Version}{$BaseId}{"Tid"})
278262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
278362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $TypeInfo{$Version}{$Tid}{"Size"} = $TypeInfo{$Version}{$BaseId}{"Size"};
278462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $TName = $TypeInfo{$Version}{$Tid}{"Name"}) {
278562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $Typedef_BaseName{$Version}{$TName} = $TypeInfo{$Version}{$BaseId}{"Name"};
278662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
278762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
279162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTypeInfo($)
2792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2793b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    my $TypeId = $_[0];
2794b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    %{$TypeInfo{$Version}{$TypeId}} = getTypeAttr($TypeId);
2795b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    my $TName = $TypeInfo{$Version}{$TypeId}{"Name"};
2796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $TName) {
2797b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        delete($TypeInfo{$Version}{$TypeId});
2798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getArraySize($$)
2802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeId, $BaseName) = @_;
280462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $Size = getSize($TypeId))
2805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
280662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $Elems = $Size/$BYTE_SIZE;
280762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        while($BaseName=~s/\s*\[(\d+)\]//) {
280862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $Elems/=$1;
2809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
281062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $BasicId = $TName_Tid{$Version}{$BaseName})
281162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
281262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $BasicSize = $TypeInfo{$Version}{$BasicId}{"Size"}) {
281362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $Elems/=$BasicSize;
281462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
281662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Elems;
2817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
281862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return 0;
2819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTParams($$)
2822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
282362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $Kind) = @_;
282462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my @TmplParams = ();
282562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my @Positions = sort {int($a)<=>int($b)} keys(%{$TemplateInstance{$Version}{$Kind}{$TypeId}});
282662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $Pos (@Positions)
2827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
282862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $Param_TypeId = $TemplateInstance{$Version}{$Kind}{$TypeId}{$Pos};
282962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $NodeType = $LibInfo{$Version}{"info_type"}{$Param_TypeId};
283062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $NodeType)
283162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # typename_type
2832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return ();
2833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
283462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($NodeType eq "tree_vec")
283562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
283662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($Pos!=$#Positions)
283762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            { # select last vector of parameters ( ns<P1>::type<P2> )
283862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                next;
283962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
284062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
284162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my @Params = get_TemplateParam($Pos, $Param_TypeId);
284262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $P (@Params)
284362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
284462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($P eq "") {
284562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return ();
284662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
284762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            elsif($P ne "\@skip\@") {
284862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                @TmplParams = (@TmplParams, $P);
284962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
285262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return @TmplParams;
2853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
285562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTypeAttr($)
2856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
285762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $TypeId = $_[0];
28580d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my %TypeAttr = ();
285962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $TypeInfo{$Version}{$TypeId}
286062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and $TypeInfo{$Version}{$TypeId}{"Name"})
286162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # already created
286262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return %{$TypeInfo{$Version}{$TypeId}};
2863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
286462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif($Cache{"getTypeAttr"}{$Version}{$TypeId})
286562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # incomplete type
286662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return ();
286762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
286862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    $Cache{"getTypeAttr"}{$Version}{$TypeId} = 1;
286962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
287062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $TypeDeclId = getTypeDeclId($TypeId);
2871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $TypeAttr{"Tid"} = $TypeId;
287262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
287362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not $MissedBase{$Version}{$TypeId} and isTypedef($TypeId))
287462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
287562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $Info = $LibInfo{$Version}{"info"}{$TypeId})
287662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
287762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($Info=~/qual[ ]*:/)
287862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
2879177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                my $NewId = ++$MAX_ID;
2880177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2881177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $MissedBase{$Version}{$TypeId} = "$NewId";
2882177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $MissedBase_R{$Version}{$NewId} = $TypeId;
2883177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $LibInfo{$Version}{"info"}{$NewId} = $LibInfo{$Version}{"info"}{$TypeId};
2884177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $LibInfo{$Version}{"info_type"}{$NewId} = $LibInfo{$Version}{"info_type"}{$TypeId};
288562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
288662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
288762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $TypeAttr{"Type"} = "Typedef";
288862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
288962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    else {
289062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $TypeAttr{"Type"} = getTypeType($TypeId);
289162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
289262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
2893177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $ScopeId = getTreeAttr_Scpe($TypeDeclId))
2894177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
2895177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$ScopeId} eq "function_decl")
2896177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # local code
2897177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return ();
2898177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2899177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2900177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TypeAttr{"Type"} eq "Unknown") {
2902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ();
2903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($TypeAttr{"Type"}=~/(Func|Method|Field)Ptr/)
2905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
290662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        %TypeAttr = getMemPtrAttr(pointTo($TypeId), $TypeId, $TypeAttr{"Type"});
2907989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if(my $TName = $TypeAttr{"Name"})
2908989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        {
290962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            %{$TypeInfo{$Version}{$TypeId}} = %TypeAttr;
2910989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            $TName_Tid{$Version}{$TName} = $TypeId;
2911989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            return %TypeAttr;
2912989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
2913989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        else {
2914989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            return ();
2915989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
2916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($TypeAttr{"Type"} eq "Array")
2918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
291962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my ($BTid, $BTSpec) = selectBaseType($TypeId);
292062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $BTid) {
29210d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return ();
29220d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
2923f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if(my $Algn = getAlgn($TypeId)) {
2924f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $TypeAttr{"Algn"} = $Algn/$BYTE_SIZE;
2925f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
2926fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $TypeAttr{"BaseType"} = $BTid;
292762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my %BTAttr = getTypeAttr($BTid))
2928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
292962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(not $BTAttr{"Name"}) {
293062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return ();
293162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
29320d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(my $NElems = getArraySize($TypeId, $BTAttr{"Name"}))
2933989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
293462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(my $Size = getSize($TypeId)) {
293562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $TypeAttr{"Size"} = $Size/$BYTE_SIZE;
293662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
29370d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if($BTAttr{"Name"}=~/\A([^\[\]]+)(\[(\d+|)\].*)\Z/) {
2938989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    $TypeAttr{"Name"} = $1."[$NElems]".$2;
2939989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
2940989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                else {
29410d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    $TypeAttr{"Name"} = $BTAttr{"Name"}."[$NElems]";
2942989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
2943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2944989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            else
2945989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
2946989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                $TypeAttr{"Size"} = $WORD_SIZE{$Version}; # pointer
29470d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if($BTAttr{"Name"}=~/\A([^\[\]]+)(\[(\d+|)\].*)\Z/) {
2948989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    $TypeAttr{"Name"} = $1."[]".$2;
2949989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
2950989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                else {
29510d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    $TypeAttr{"Name"} = $BTAttr{"Name"}."[]";
2952989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
2953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
29549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $TypeAttr{"Name"} = formatName($TypeAttr{"Name"}, "T");
29550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if($BTAttr{"Header"})  {
29560d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $TypeAttr{"Header"} = $BTAttr{"Header"};
2957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
295862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            %{$TypeInfo{$Version}{$TypeId}} = %TypeAttr;
2959989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            $TName_Tid{$Version}{$TypeAttr{"Name"}} = $TypeId;
2960989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            return %TypeAttr;
2961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
29620d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return ();
2963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2964177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    elsif($TypeAttr{"Type"}=~/\A(Intrinsic|Union|Struct|Enum|Class|Vector)\Z/)
2965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
296662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        %TypeAttr = getTrivialTypeAttr($TypeId);
29670d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($TypeAttr{"Name"})
29680d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
296962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            %{$TypeInfo{$Version}{$TypeId}} = %TypeAttr;
2970177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2971177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(not defined $IntrinsicNames{$TypeAttr{"Name"}}
2972177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            or getTypeDeclId($TypeAttr{"Tid"}))
29730d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            { # NOTE: register only one int: with built-in decl
29740d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if(not $TName_Tid{$Version}{$TypeAttr{"Name"}}) {
29750d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    $TName_Tid{$Version}{$TypeAttr{"Name"}} = $TypeId;
29760d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
29770d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
29780d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return %TypeAttr;
29790d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
29800d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        else {
29810d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return ();
29820d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
2983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2984177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    elsif($TypeAttr{"Type"}=~/TemplateParam|TypeName/)
2985177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
2986177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        %TypeAttr = getTrivialTypeAttr($TypeId);
2987177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($TypeAttr{"Name"})
2988177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2989177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            %{$TypeInfo{$Version}{$TypeId}} = %TypeAttr;
2990177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(not $TName_Tid{$Version}{$TypeAttr{"Name"}}) {
2991177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $TName_Tid{$Version}{$TypeAttr{"Name"}} = $TypeId;
2992177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2993177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return %TypeAttr;
2994177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2995177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        else {
2996177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return ();
2997177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2998177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2999177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    elsif($TypeAttr{"Type"} eq "SizeOf")
3000177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
3001177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $TypeAttr{"BaseType"} = getTreeAttr_Type($TypeId);
3002177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        my %BTAttr = getTypeAttr($TypeAttr{"BaseType"});
3003177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $TypeAttr{"Name"} = "sizeof(".$BTAttr{"Name"}.")";
3004177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($TypeAttr{"Name"})
3005177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
3006177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            %{$TypeInfo{$Version}{$TypeId}} = %TypeAttr;
3007177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return %TypeAttr;
3008177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
3009177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        else {
3010177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return ();
3011177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
3012177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
3013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
3014989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    { # derived types
301562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my ($BTid, $BTSpec) = selectBaseType($TypeId);
301662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $BTid) {
30170d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return ();
30180d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
3019fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $TypeAttr{"BaseType"} = $BTid;
302062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(defined $MissedTypedef{$Version}{$BTid})
3021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
302262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $MissedTDid = $MissedTypedef{$Version}{$BTid}{"TDid"})
3023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
302462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($MissedTDid ne $TypeDeclId) {
3025fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $TypeAttr{"BaseType"} = $MissedTypedef{$Version}{$BTid}{"Tid"};
302662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
3027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3029fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        my %BTAttr = getTypeAttr($TypeAttr{"BaseType"});
30300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(not $BTAttr{"Name"})
303162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # templates
3032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return ();
3033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
30340d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($BTAttr{"Type"} eq "Typedef")
3035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # relinking typedefs
3036fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my %BaseBase = get_Type($BTAttr{"BaseType"}, $Version);
303762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($BTAttr{"Name"} eq $BaseBase{"Name"}) {
3038fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $TypeAttr{"BaseType"} = $BaseBase{"Tid"};
3039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
30410d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($BTSpec)
3042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
3043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($TypeAttr{"Type"} eq "Pointer"
30440d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and $BTAttr{"Name"}=~/\([\*]+\)/)
3045989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
30460d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $TypeAttr{"Name"} = $BTAttr{"Name"};
3047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $TypeAttr{"Name"}=~s/\(([*]+)\)/($1*)/g;
3048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
30500d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $TypeAttr{"Name"} = $BTAttr{"Name"}." ".$BTSpec;
3051ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3053ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
30540d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $TypeAttr{"Name"} = $BTAttr{"Name"};
3055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3056ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($TypeAttr{"Type"} eq "Typedef")
3057ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
3058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TypeAttr{"Name"} = getNameByInfo($TypeDeclId);
305974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
306074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(index($TypeAttr{"Name"}, "tmp_add_type")==0) {
306174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                return ();
306274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
306374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
3064850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if(isAnon($TypeAttr{"Name"}))
3065850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # anon typedef to anon type: ._N
3066850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                return ();
3067850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
30688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
30698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($LibInfo{$Version}{"info"}{$TypeDeclId}=~/ artificial /i)
30708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # artificial typedef of "struct X" to "X"
30718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $TypeAttr{"Artificial"} = 1;
30728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
30738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
3074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my $NS = getNameSpace($TypeDeclId))
3075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
3076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $TypeName = $TypeAttr{"Name"};
3077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($NS=~/\A(struct |union |class |)((.+)::|)\Q$TypeName\E\Z/)
3078ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # "some_type" is the typedef to "struct some_type" in C++
3079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($3) {
3080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $TypeAttr{"Name"} = $3."::".$TypeName;
3081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
3082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
3083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else
3084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
3085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $TypeAttr{"NameSpace"} = $NS;
3086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $TypeAttr{"Name"} = $TypeAttr{"NameSpace"}."::".$TypeAttr{"Name"};
3087989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko
3088989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    if($TypeAttr{"NameSpace"}=~/\Astd(::|\Z)/
3089989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    and $TypeAttr{"Name"}!~/>(::\w+)+\Z/)
3090989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    {
30910d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        if($BTAttr{"NameSpace"}
30920d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        and $BTAttr{"NameSpace"}=~/\Astd(::|\Z)/ and $BTAttr{"Name"}=~/</)
3093989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                        { # types like "std::fpos<__mbstate_t>" are
3094989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                          # not covered by typedefs in the TU dump
3095989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                          # so trying to add such typedefs manually
30960d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            $StdCxxTypedef{$Version}{$BTAttr{"Name"}}{$TypeAttr{"Name"}} = 1;
30970d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            if(length($TypeAttr{"Name"})<=length($BTAttr{"Name"}))
3098989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                            {
30990d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                if(($BTAttr{"Name"}!~/\A(std|boost)::/ or $TypeAttr{"Name"}!~/\A[a-z]+\Z/))
3100989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                                { # skip "other" in "std" and "type" in "boost"
31010d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                    $Typedef_Eq{$Version}{$BTAttr{"Name"}} = $TypeAttr{"Name"};
3102989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                                }
3103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
3104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
3105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
3106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
3107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
31088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($TypeAttr{"Name"} ne $BTAttr{"Name"} and not $TypeAttr{"Artificial"}
31090d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and $TypeAttr{"Name"}!~/>(::\w+)+\Z/ and $BTAttr{"Name"}!~/>(::\w+)+\Z/)
3110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
31110d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if(not defined $Typedef_BaseName{$Version}{$TypeAttr{"Name"}})
31120d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                { # typedef int*const TYPEDEF; // first
31130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                  # int foo(TYPEDEF p); // const is optimized out
31140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    $Typedef_BaseName{$Version}{$TypeAttr{"Name"}} = $BTAttr{"Name"};
31150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    if($BTAttr{"Name"}=~/</)
31160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    {
31170d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        if(($BTAttr{"Name"}!~/\A(std|boost)::/ or $TypeAttr{"Name"}!~/\A[a-z]+\Z/)) {
31180d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            $Typedef_Tr{$Version}{$BTAttr{"Name"}}{$TypeAttr{"Name"}} = 1;
31190d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        }
3120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
3121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
3122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            ($TypeAttr{"Header"}, $TypeAttr{"Line"}) = getLocation($TypeDeclId);
3124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $TypeAttr{"Size"})
3126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
3127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($TypeAttr{"Type"} eq "Pointer") {
3128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $TypeAttr{"Size"} = $WORD_SIZE{$Version};
3129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
31300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            elsif($BTAttr{"Size"}) {
31310d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $TypeAttr{"Size"} = $BTAttr{"Size"};
3132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3134f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if(my $Algn = getAlgn($TypeId)) {
3135f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $TypeAttr{"Algn"} = $Algn/$BYTE_SIZE;
3136f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
31379927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $TypeAttr{"Name"} = formatName($TypeAttr{"Name"}, "T");
31380d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(not $TypeAttr{"Header"} and $BTAttr{"Header"})  {
31390d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $TypeAttr{"Header"} = $BTAttr{"Header"};
3140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
314162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        %{$TypeInfo{$Version}{$TypeId}} = %TypeAttr;
31420d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($TypeAttr{"Name"} ne $BTAttr{"Name"})
3143989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        { # typedef to "class Class"
3144989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko          # should not be registered in TName_Tid
3145989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if(not $TName_Tid{$Version}{$TypeAttr{"Name"}}) {
3146989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                $TName_Tid{$Version}{$TypeAttr{"Name"}} = $TypeId;
3147989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
3148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return %TypeAttr;
3150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
315362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeVec($)
315462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
315562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Vector = ();
315662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
315762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
315862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        while($Info=~s/ (\d+)[ ]*:[ ]*\@(\d+) / /)
315962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # string length is N-1 because of the null terminator
316062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $Vector{$1} = $2;
316162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
316262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
316362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return \%Vector;
316462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
316562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
3166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_TemplateParam($$)
3167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Pos, $Type_Id) = @_;
316962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return () if(not $Type_Id);
317062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $NodeType = $LibInfo{$Version}{"info_type"}{$Type_Id};
317162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return () if(not $NodeType);
317262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($NodeType eq "integer_cst")
3173ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # int (1), unsigned (2u), char ('c' as 99), ...
317462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $CstTid = getTreeAttr_Type($Type_Id);
3175b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        my %CstType = getTypeAttr($CstTid); # without recursion
3176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Num = getNodeIntCst($Type_Id);
3177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $CstSuffix = $ConstantSuffix{$CstType{"Name"}}) {
317862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ($Num.$CstSuffix);
3179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
318162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ("(".$CstType{"Name"}.")".$Num);
3182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
318462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif($NodeType eq "string_cst") {
318562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return (getNodeStrCst($Type_Id));
3186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
318762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif($NodeType eq "tree_vec")
318862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
318962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $Vector = getTreeVec($Type_Id);
319062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my @Params = ();
319162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $P1 (sort {int($a)<=>int($b)} keys(%{$Vector}))
319262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
319362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            foreach my $P2 (get_TemplateParam($Pos, $Vector->{$P1})) {
319462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                push(@Params, $P2);
319562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
319662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
319762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return @Params;
3198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3199177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    elsif($NodeType eq "parm_decl")
3200177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
3201177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        (getNameByInfo($Type_Id));
3202177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
3203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
3204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
320562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %ParamAttr = getTypeAttr($Type_Id);
3206b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        my $PName = $ParamAttr{"Name"};
3207b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        if(not $PName) {
320862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ();
3209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3210b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        if($PName=~/\>/)
3211b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        {
3212b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if(my $Cover = cover_stdcxx_typedef($PName)) {
3213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $PName = $Cover;
3214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Pos>=1 and
32171477d2c1a4df8ea5c19b19604da6d4c5b7016d72Andrey Ponomarenko        $PName=~/\A$DEFAULT_STD_PARMS\</)
3218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # template<typename _Tp, typename _Alloc = std::allocator<_Tp> >
3219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # template<typename _Key, typename _Compare = std::less<_Key>
3220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # template<typename _CharT, typename _Traits = std::char_traits<_CharT> >
3221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # template<typename _Ch_type, typename _Rx_traits = regex_traits<_Ch_type> >
3222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # template<typename _CharT, typename _InIter = istreambuf_iterator<_CharT> >
3223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # template<typename _CharT, typename _OutIter = ostreambuf_iterator<_CharT> >
322462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ("\@skip\@");
3225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
322662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return ($PName);
3227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub cover_stdcxx_typedef($)
3231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TypeName = $_[0];
3233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my @Covers = sort {length($a)<=>length($b)}
3234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    sort keys(%{$StdCxxTypedef{$Version}{$TypeName}}))
3235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # take the shortest typedef
3236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # FIXME: there may be more than
3237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # one typedefs to the same type
3238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Covers[0];
3239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3240f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my $Covered = $TypeName;
3241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($TypeName=~s/(>)[ ]*(const|volatile|restrict| |\*|\&)\Z/$1/g){};
3242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my @Covers = sort {length($a)<=>length($b)} sort keys(%{$StdCxxTypedef{$Version}{$TypeName}}))
3243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3244f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if(my $Cover = $Covers[0])
3245f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        {
3246f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $Covered=~s/\b\Q$TypeName\E(\W|\Z)/$Cover$1/g;
3247f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $Covered=~s/\b\Q$TypeName\E(\w|\Z)/$Cover $1/g;
3248f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
3249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
32509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return formatName($Covered, "T");
3251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getNodeIntCst($)
3254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $CstId = $_[0];
325662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $CstTypeId = getTreeAttr_Type($CstId);
3257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($EnumMembName_Id{$Version}{$CstId}) {
3258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $EnumMembName_Id{$Version}{$CstId};
3259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif((my $Value = getTreeValue($CstId)) ne "")
3261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3262dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Value eq "0")
3263dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
326462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($LibInfo{$Version}{"info_type"}{$CstTypeId} eq "boolean_type") {
3265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "false";
3266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
3268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "0";
3269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3271dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Value eq "1")
3272dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
327362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($LibInfo{$Version}{"info_type"}{$CstTypeId} eq "boolean_type") {
3274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "true";
3275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
3277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "1";
3278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
3281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $Value;
3282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3284dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
3285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getNodeStrCst($)
3288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3289dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
3290dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
3291dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/strg[ ]*: (.+) lngt:[ ]*(\d+)/)
329201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        {
329301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if($LibInfo{$Version}{"info_type"}{$_[0]} eq "string_cst")
329401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # string length is N-1 because of the null terminator
329501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                return substr($1, 0, $2-1);
329601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
329701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            else
329801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # identifier_node
329901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                return substr($1, 0, $2);
330001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
3301dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
3302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3303dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
3304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
330662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getMemPtrAttr($$$)
3307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # function, method and field pointers
330862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($PtrId, $TypeId, $Type) = @_;
3309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $MemInfo = $LibInfo{$Version}{"info"}{$PtrId};
3310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type eq "FieldPtr") {
3311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MemInfo = $LibInfo{$Version}{"info"}{$TypeId};
3312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $MemInfo_Type = $LibInfo{$Version}{"info_type"}{$PtrId};
3314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $MemPtrName = "";
331562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %TypeAttr = ("Size"=>$WORD_SIZE{$Version}, "Type"=>$Type, "Tid"=>$TypeId);
3316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type eq "MethodPtr")
3317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # size of "method pointer" may be greater than WORD size
331801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(my $Size = getSize($TypeId))
331901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        {
332001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            $Size/=$BYTE_SIZE;
332101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            $TypeAttr{"Size"} = "$Size";
332262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
3323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3324f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(my $Algn = getAlgn($TypeId)) {
3325f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        $TypeAttr{"Algn"} = $Algn/$BYTE_SIZE;
3326f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
3327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Return
3328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type eq "FieldPtr")
3329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
333062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %ReturnAttr = getTypeAttr($PtrId);
3331989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($ReturnAttr{"Name"}) {
3332989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            $MemPtrName .= $ReturnAttr{"Name"};
3333989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
3334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr{"Return"} = $PtrId;
3335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
3337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MemInfo=~/retn[ ]*:[ ]*\@(\d+) /)
3339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
3340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $ReturnTypeId = $1;
334162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my %ReturnAttr = getTypeAttr($ReturnTypeId);
334262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(not $ReturnAttr{"Name"})
334362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            { # templates
334462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return ();
3345989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
334662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $MemPtrName .= $ReturnAttr{"Name"};
3347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TypeAttr{"Return"} = $ReturnTypeId;
3348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Class
3351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($MemInfo=~/(clas|cls)[ ]*:[ ]*@(\d+) /)
3352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr{"Class"} = $2;
335462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Class = getTypeAttr($TypeAttr{"Class"});
3355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Class{"Name"}) {
3356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MemPtrName .= " (".$Class{"Name"}."\:\:*)";
3357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
3359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MemPtrName .= " (*)";
3360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
3363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MemPtrName .= " (*)";
3364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Parameters
3366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type eq "FuncPtr"
3367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $Type eq "MethodPtr")
3368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @ParamTypeName = ();
3370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MemInfo=~/prms[ ]*:[ ]*@(\d+) /)
3371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
3372989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            my $PTypeInfoId = $1;
337301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            my ($Pos, $PPos) = (0, 0);
3374989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            while($PTypeInfoId)
3375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
3376989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                my $PTypeInfo = $LibInfo{$Version}{"info"}{$PTypeInfoId};
3377989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                if($PTypeInfo=~/valu[ ]*:[ ]*@(\d+) /)
3378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
337962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $PTypeId = $1;
338062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my %ParamAttr = getTypeAttr($PTypeId);
3381989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    if(not $ParamAttr{"Name"})
3382989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    { # templates (template_type_parm), etc.
3383989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                        return ();
3384989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    }
3385989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    if($ParamAttr{"Name"} eq "void") {
3386989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                        last;
3387989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    }
338862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($Pos!=0 or $Type ne "MethodPtr")
3389989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    {
339001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                        $TypeAttr{"Param"}{$PPos++}{"type"} = $PTypeId;
3391989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                        push(@ParamTypeName, $ParamAttr{"Name"});
3392989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    }
339362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($PTypeInfoId = getNextElem($PTypeInfoId)) {
339462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $Pos+=1;
3395989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    }
3396989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    else {
3397989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                        last;
3398989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    }
3399989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
3400989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                else {
3401989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    last;
3402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
3403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MemPtrName .= " (".join(", ", @ParamTypeName).")";
3406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
34079927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    $TypeAttr{"Name"} = formatName($MemPtrName, "T");
3408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return %TypeAttr;
3409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTreeTypeName($)
3412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
34130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $TypeId = $_[0];
34140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$TypeId})
3415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
34160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$_[0]} eq "integer_type")
3417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
34180d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(my $Name = getNameByInfo($TypeId))
34190d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            { # bit_size_type
34200d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                return $Name;
34210d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
34220d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            elsif($Info=~/unsigned/) {
3423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "unsigned int";
3424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
3426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "int";
3427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
34294b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        elsif($Info=~/name[ ]*:[ ]*@(\d+) /) {
34300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return getNameByInfo($1);
34310d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
3432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3433dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
3434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
34360d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub isFuncPtr($)
3437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
34380d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $Ptd = pointTo($_[0]);
34390d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return 0 if(not $Ptd);
34400d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$_[0]})
34410d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
34420d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($Info=~/unql[ ]*:/ and $Info!~/qual[ ]*:/) {
34430d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return 0;
34440d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
3445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
34460d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $InfoT1 = $LibInfo{$Version}{"info_type"}{$_[0]}
34470d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    and my $InfoT2 = $LibInfo{$Version}{"info_type"}{$Ptd})
3448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
34490d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($InfoT1 eq "pointer_type"
34500d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $InfoT2 eq "function_type") {
34510d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return 1;
3452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
34530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
34540d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return 0;
34550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
34560d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
34570d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub isMethodPtr($)
34580d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
34590d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $Ptd = pointTo($_[0]);
34600d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return 0 if(not $Ptd);
34610d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$_[0]})
34620d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
34630d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$_[0]} eq "record_type"
34640d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $LibInfo{$Version}{"info_type"}{$Ptd} eq "method_type"
34650d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $Info=~/ ptrmem /) {
34660d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return 1;
3467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
34690d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return 0;
34700d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
34710d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
34720d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub isFieldPtr($)
34730d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
34740d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
3475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
34760d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$_[0]} eq "offset_type"
34770d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $Info=~/ ptrmem /) {
34780d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return 1;
3479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
34800d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
34810d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return 0;
34820d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
34830d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
34840d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub pointTo($)
34850d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
34860d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
34870d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
34880d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($Info=~/ptd[ ]*:[ ]*@(\d+)/) {
34890d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return $1;
3490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
34920d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return "";
34930d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
34940d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
34950d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub getTypeTypeByTypeId($)
34960d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
34970d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $TypeId = $_[0];
34980d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $TType = $LibInfo{$Version}{"info_type"}{$TypeId})
34990d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
35000d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        my $NType = $NodeType{$TType};
35010d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($NType eq "Intrinsic") {
35020d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return $NType;
35030d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
35040d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        elsif(isFuncPtr($TypeId)) {
35050d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return "FuncPtr";
35060d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
35070d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        elsif(isMethodPtr($TypeId)) {
35080d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return "MethodPtr";
35090d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
35100d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        elsif(isFieldPtr($TypeId)) {
35110d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return "FieldPtr";
35120d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
35130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        elsif($NType ne "Other") {
35140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return $NType;
35150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
3516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
35170d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return "Unknown";
3518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3519ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
352074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkomy %UnQual = (
352174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "r"=>"restrict",
352274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "v"=>"volatile",
352374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "c"=>"const",
352474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "cv"=>"const volatile"
352574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko);
352674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
3527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getQual($)
3528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TypeId = $_[0];
3530dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$TypeId})
3531dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
3532dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        my ($Qual, $To) = ();
3533dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/qual[ ]*:[ ]*(r|c|v|cv) /) {
3534dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $Qual = $UnQual{$1};
3535dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
3536dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/unql[ ]*:[ ]*\@(\d+)/) {
3537dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $To = $1;
3538dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
3539dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Qual and $To) {
3540dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return ($Qual, $To);
3541dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
3542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ();
3544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
35460d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub getQualType($)
35470d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
35480d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($_[0] eq "const volatile") {
35490d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return "ConstVolatile";
35500d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
35510d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return ucfirst($_[0]);
35520d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
35530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
355462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTypeType($)
35550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
355662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $TypeId = $_[0];
355762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $TypeDeclId = getTypeDeclId($TypeId);
355862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $MissedTypedef{$Version}{$TypeId})
35590d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # support for old GCC versions
356062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($MissedTypedef{$Version}{$TypeId}{"TDid"} eq $TypeDeclId) {
356162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return "Typedef";
356262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
35630d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
35640d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $Info = $LibInfo{$Version}{"info"}{$TypeId};
35650d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Qual, $To) = getQual($TypeId);
35669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(($Qual or $To) and $TypeDeclId
35679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    and (getTypeId($TypeDeclId) ne $TypeId))
35680d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # qualified types (special)
356962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return getQualType($Qual);
35700d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
357162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif(not $MissedBase_R{$Version}{$TypeId}
357262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and isTypedef($TypeId)) {
35730d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return "Typedef";
35740d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
35750d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    elsif($Qual)
35760d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # qualified types
35770d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return getQualType($Qual);
35780d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
35799927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
35809927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($Info=~/unql[ ]*:[ ]*\@(\d+)/)
35819927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # typedef struct { ... } name
35829927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $TypeTypedef{$Version}{$TypeId} = $1;
35839927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
35849927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
35850d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $TypeType = getTypeTypeByTypeId($TypeId);
35860d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($TypeType eq "Struct")
35870d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
35880d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($TypeDeclId
35890d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $LibInfo{$Version}{"info_type"}{$TypeDeclId} eq "template_decl") {
35900d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return "Template";
35910d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
35920d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
35930d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return $TypeType;
35940d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
35950d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
359662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub isTypedef($)
359762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
3598177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($_[0])
359962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
3600177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$_[0]} eq "vector_type")
3601177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # typedef float La_x86_64_xmm __attribute__ ((__vector_size__ (16)));
3602177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return 0;
3603177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
3604177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $Info = $LibInfo{$Version}{"info"}{$_[0]})
3605177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
3606e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            if(my $TDid = getTypeDeclId($_[0]))
3607e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            {
3608e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                if(getTypeId($TDid) eq $_[0]
3609e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                and getNameByInfo($TDid))
3610e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                {
3611e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    if($Info=~/unql[ ]*:[ ]*\@(\d+) /) {
3612e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                        return $1;
3613e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    }
3614e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                }
3615177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
361662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
361762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
361862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return 0;
361962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
362062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
362162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub selectBaseType($)
3622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
362362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $TypeId = $_[0];
362462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $MissedTypedef{$Version}{$TypeId})
362562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # add missed typedefs
362662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($MissedTypedef{$Version}{$TypeId}{"TDid"} eq getTypeDeclId($TypeId)) {
362762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ($TypeId, "");
362862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
3629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
36300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $Info = $LibInfo{$Version}{"info"}{$TypeId};
36310d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $InfoType = $LibInfo{$Version}{"info_type"}{$TypeId};
363262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
363362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $MB_R = $MissedBase_R{$Version}{$TypeId};
363462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $MB = $MissedBase{$Version}{$TypeId};
363562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
3636dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my ($Qual, $To) = getQual($TypeId);
36370d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(($Qual or $To) and $Info=~/name[ ]*:[ ]*\@(\d+) /
363862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and (getTypeId($1) ne $TypeId)
363962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and (not $MB_R or getTypeId($1) ne $MB_R))
36400d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # qualified types (special)
364162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return (getTypeId($1), $Qual);
364262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
364362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif($MB)
364462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # add base
364562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return ($MB, "");
3646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
364762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif(not $MB_R and my $Bid = isTypedef($TypeId))
3648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # typedefs
364962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return ($Bid, "");
3650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
36510d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    elsif($Qual or $To)
36520d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # qualified types
365362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return ($To, $Qual);
3654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
36550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    elsif($InfoType eq "reference_type")
3656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
36570d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($Info=~/refd[ ]*:[ ]*@(\d+) /) {
365862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ($1, "&");
3659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
36610d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    elsif($InfoType eq "array_type")
3662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
36630d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($Info=~/elts[ ]*:[ ]*@(\d+) /) {
366462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ($1, "");
3665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
36670d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    elsif($InfoType eq "pointer_type")
3668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
36690d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($Info=~/ptd[ ]*:[ ]*@(\d+) /) {
367062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ($1, "*");
3671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3673177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3674177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    return (0, "");
3675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getSymbolInfo_All()
3678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (sort {int($b)<=>int($a)} keys(%{$LibInfo{$Version}{"info"}}))
3680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # reverse order
3681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$_} eq "function_decl") {
368262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            getSymbolInfo($_);
3683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3685177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3686177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($ADD_TMPL_INSTANCES)
3687177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
3688177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        # templates
3689177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Sid (sort {int($a)<=>int($b)} keys(%{$SymbolInfo{$Version}}))
3690177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
3691177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            my %Map = ();
3692177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3693177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(my $ClassId = $SymbolInfo{$Version}{$Sid}{"Class"})
3694177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
3695177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(defined $TemplateMap{$Version}{$ClassId})
3696177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
3697177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    foreach (keys(%{$TemplateMap{$Version}{$ClassId}})) {
3698177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $Map{$_} = $TemplateMap{$Version}{$ClassId}{$_};
3699177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
3700177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
3701177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
3702177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3703177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $TemplateMap{$Version}{$Sid})
3704177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
3705177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach (keys(%{$TemplateMap{$Version}{$Sid}})) {
3706177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $Map{$_} = $TemplateMap{$Version}{$Sid}{$_};
3707177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
3708177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
3709177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3710177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $SymbolInfo{$Version}{$Sid}{"Param"})
3711177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
3712177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach (keys(%{$SymbolInfo{$Version}{$Sid}{"Param"}}))
3713177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
3714177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    my $PTid = $SymbolInfo{$Version}{$Sid}{"Param"}{$_}{"type"};
3715177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $SymbolInfo{$Version}{$Sid}{"Param"}{$_}{"type"} = instType(\%Map, $PTid, $Version);
3716177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
3717177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
3718177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(my $Return = $SymbolInfo{$Version}{$Sid}{"Return"}) {
3719177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $SymbolInfo{$Version}{$Sid}{"Return"} = instType(\%Map, $Return, $Version);
3720177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
3721177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
3722177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
3723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getVarInfo_All()
3726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (sort {int($b)<=>int($a)} keys(%{$LibInfo{$Version}{"info"}}))
3728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # reverse order
3729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$_} eq "var_decl") {
373062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            getVarInfo($_);
3731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isBuiltIn($) {
3736dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return ($_[0] and $_[0]=~/\<built\-in\>|\<internal\>|\A\./);
3737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getVarInfo($)
3740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $InfoId = $_[0];
374201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(my $NSid = getTreeAttr_Scpe($InfoId))
3743dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
3744dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        my $NSInfoType = $LibInfo{$Version}{"info_type"}{$NSid};
3745dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($NSInfoType and $NSInfoType eq "function_decl") {
3746dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return;
3747dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
3748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ($SymbolInfo{$Version}{$InfoId}{"Header"}, $SymbolInfo{$Version}{$InfoId}{"Line"}) = getLocation($InfoId);
3750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"Header"}
3751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or isBuiltIn($SymbolInfo{$Version}{$InfoId}{"Header"})) {
3752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
3753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
3754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
375562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $ShortName = getTreeStr(getTreeAttr_Name($InfoId));
3756850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(not $ShortName) {
3757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
3758ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
3759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3760850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($ShortName=~/\Atmp_add_class_\d+\Z/) {
3761850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
3762850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return;
3763850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
3764850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    $SymbolInfo{$Version}{$InfoId}{"ShortName"} = $ShortName;
3765f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(my $MnglName = getTreeStr(getTreeAttr_Mngl($InfoId)))
3766f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    {
3767f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($OSgroup eq "windows")
3768f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        { # cut the offset
3769f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $MnglName=~s/\@\d+\Z//g;
3770f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
3771f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $MnglName;
3772f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
3773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"MnglName"}
37749927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    and index($SymbolInfo{$Version}{$InfoId}{"MnglName"}, "_Z")!=0)
3775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # validate mangled name
3776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
3777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
3778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
37790d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"MnglName"}
37809927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    and index($ShortName, "_Z")==0)
37810d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # _ZTS, etc.
3782850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $ShortName;
37830d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
37840d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(isPrivateData($SymbolInfo{$Version}{$InfoId}{"MnglName"}))
37850d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # non-public global data
37860d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
37870d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return;
37880d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
3789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $SymbolInfo{$Version}{$InfoId}{"Data"} = 1;
379062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $Rid = getTypeId($InfoId))
37910d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
3792177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not defined $TypeInfo{$Version}{$Rid}
3793177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        or not $TypeInfo{$Version}{$Rid}{"Name"})
3794177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
37950d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
37960d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return;
37970d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
379862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Return"} = $Rid;
379962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $Val = getDataVal($InfoId, $Rid);
38000d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(defined $Val) {
38010d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"Value"} = $Val;
38020d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
3803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    set_Class_And_Namespace($InfoId);
380562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $ClassId = $SymbolInfo{$Version}{$InfoId}{"Class"})
380662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
3807177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not defined $TypeInfo{$Version}{$ClassId}
3808177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        or not $TypeInfo{$Version}{$ClassId}{"Name"})
3809177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
381062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
381162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return;
381262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
381362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
381435c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    if($LibInfo{$Version}{"info"}{$InfoId}=~/ lang:[ ]*C /i)
381535c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    { # extern "C"
3816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Lang"} = "C";
381735c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $ShortName;
3818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3819dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($UserLang and $UserLang eq "C")
3820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --lang=C option
3821850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $ShortName;
3822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
38235c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if(not $CheckHeadersOnly)
38245c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    {
38255c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        if(not $SymbolInfo{$Version}{$InfoId}{"Class"})
38265c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        {
38275c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            if(not $SymbolInfo{$Version}{$InfoId}{"MnglName"}
38285c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            or not link_symbol($SymbolInfo{$Version}{$InfoId}{"MnglName"}, $Version, "-Deps"))
38295c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            {
38305c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                if(link_symbol($ShortName, $Version, "-Deps"))
38315c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                { # "const" global data is mangled as _ZL... in the TU dump
38325c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                  # but not mangled when compiling a C shared library
38335c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                    $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $ShortName;
38345c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                }
38355c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            }
38365c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
38375c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
3838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($COMMON_LANGUAGE{$Version} eq "C++")
3839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $SymbolInfo{$Version}{$InfoId}{"MnglName"})
3841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # for some symbols (_ZTI) the short name is the mangled name
38429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(index($ShortName, "_Z")==0) {
3843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $ShortName;
3844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $SymbolInfo{$Version}{$InfoId}{"MnglName"})
3847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # try to mangle symbol (link with libraries)
3848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"MnglName"} = linkSymbol($InfoId);
3849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($OStarget eq "windows")
3851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
3852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my $Mangled = $mangled_name{$Version}{modelUnmangled($InfoId, "MSVC")})
3853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # link MS C++ symbols from library with GCC symbols from headers
3854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $Mangled;
3855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"MnglName"}) {
3859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $ShortName;
3860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3861850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(my $Symbol = $SymbolInfo{$Version}{$InfoId}{"MnglName"})
3862850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
3863850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(not selectSymbol($Symbol, $SymbolInfo{$Version}{$InfoId}, "Dump", $Version))
3864850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # non-target symbols
3865850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
3866850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            return;
3867850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
3868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
386962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $Rid = $SymbolInfo{$Version}{$InfoId}{"Return"})
387062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
387162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(defined $MissedTypedef{$Version}{$Rid})
387262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
387362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $AddedTid = $MissedTypedef{$Version}{$Rid}{"Tid"}) {
387462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"Return"} = $AddedTid;
387562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
387662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
3877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    setFuncAccess($InfoId);
38799927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(index($SymbolInfo{$Version}{$InfoId}{"MnglName"}, "_ZTV")==0) {
3880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId}{"Return"});
3881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ShortName=~/\A(_Z|\?)/) {
3883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId}{"ShortName"});
3884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
388574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
388674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraDump) {
388774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Header"} = guessHeader($InfoId);
388874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
3889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3891850437949b65b213696469223d749c1f74c29601Andrey Ponomarenkosub isConstType($$)
3892850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko{
3893850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
389462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Base = get_Type($TypeId, $LibVersion);
3895850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    while(defined $Base{"Type"} and $Base{"Type"} eq "Typedef") {
3896f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        %Base = get_OneStep_BaseType($Base{"Tid"}, $TypeInfo{$LibVersion});
3897850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
3898850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return ($Base{"Type"} eq "Const");
3899850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko}
3900850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
3901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTrivialName($$)
3902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeInfoId, $TypeId) = @_;
3904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %TypeAttr = ();
3905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $TypeAttr{"Name"} = getNameByInfo($TypeInfoId);
3906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $TypeAttr{"Name"}) {
3907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr{"Name"} = getTreeTypeName($TypeId);
3908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3909dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    ($TypeAttr{"Header"}, $TypeAttr{"Line"}) = getLocation($TypeInfoId);
391062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    $TypeAttr{"Type"} = getTypeType($TypeId);
3911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $TypeAttr{"Name"}=~s/<(.+)\Z//g; # GCC 3.4.4 add template params to the name
39121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(isAnon($TypeAttr{"Name"}))
39131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
39141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $NameSpaceId = $TypeId;
391501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        while(my $NSId = getTreeAttr_Scpe(getTypeDeclId($NameSpaceId)))
39161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # searching for a first not anon scope
39171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($NSId eq $NameSpaceId) {
39181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                last;
39191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
39201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            else
39211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
39221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $TypeAttr{"NameSpace"} = getNameSpace(getTypeDeclId($TypeId));
39231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if(not $TypeAttr{"NameSpace"}
39242956b9768547150679a9fde09a13d85bb4f8c972Andrey Ponomarenko                or not isAnon($TypeAttr{"NameSpace"})) {
39251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    last;
39261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
39271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
3928177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $NameSpaceId = $NSId;
39291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
39301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
39311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
39321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
393301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(my $NameSpaceId = getTreeAttr_Scpe($TypeInfoId))
39341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
39351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($NameSpaceId ne $TypeId) {
39361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $TypeAttr{"NameSpace"} = getNameSpace($TypeInfoId);
39371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
3938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
39402956b9768547150679a9fde09a13d85bb4f8c972Andrey Ponomarenko    if($TypeAttr{"NameSpace"} and not isAnon($TypeAttr{"Name"})) {
3941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr{"Name"} = $TypeAttr{"NameSpace"}."::".$TypeAttr{"Name"};
3942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
39439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    $TypeAttr{"Name"} = formatName($TypeAttr{"Name"}, "T");
3944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(isAnon($TypeAttr{"Name"}))
39451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # anon-struct-header.h-line
3946dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        $TypeAttr{"Name"} = "anon-".lc($TypeAttr{"Type"})."-";
3947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr{"Name"} .= $TypeAttr{"Header"}."-".$TypeAttr{"Line"};
3948dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($TypeAttr{"NameSpace"}) {
3949dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $TypeAttr{"Name"} = $TypeAttr{"NameSpace"}."::".$TypeAttr{"Name"};
3950dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
3951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3952b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    if(defined $TemplateInstance{$Version}{"Type"}{$TypeId}
3953b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    and getTypeDeclId($TypeId) eq $TypeInfoId)
3954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
395562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my @TParams = getTParams($TypeId, "Type");
39569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $TypeAttr{"Name"} = formatName($TypeAttr{"Name"}."< ".join(", ", @TParams)." >", "T");
3957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($TypeAttr{"Name"}, $TypeAttr{"NameSpace"});
3959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
396162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTrivialTypeAttr($)
3962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
396362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $TypeId = $_[0];
396462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $TypeInfoId = getTypeDeclId($_[0]);
3965850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
3966177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my %TypeAttr = ();
3967177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3968850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($TemplateDecl{$Version}{$TypeId})
3969850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    { # template_decl
3970177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $TypeAttr{"Template"} = 1;
397162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
3972850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
3973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    setTypeAccess($TypeId, \%TypeAttr);
3974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ($TypeAttr{"Header"}, $TypeAttr{"Line"}) = getLocation($TypeInfoId);
3975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(isBuiltIn($TypeAttr{"Header"}))
3976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($TypeAttr{"Header"});
3978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($TypeAttr{"Line"});
3979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
398062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    $TypeAttr{"Type"} = getTypeType($TypeId);
3981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ($TypeAttr{"Name"}, $TypeAttr{"NameSpace"}) = getTrivialName($TypeInfoId, $TypeId);
3982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $TypeAttr{"Name"}) {
3983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ();
3984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $TypeAttr{"NameSpace"}) {
3986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($TypeAttr{"NameSpace"});
3987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3988177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3989177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $Tmpl = undef;
3990177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
399162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $TemplateInstance{$Version}{"Type"}{$TypeId})
39921693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    {
3993177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $Tmpl = $BasicTemplate{$Version}{$TypeId};
3994177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
399562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my @TParams = getTParams($TypeId, "Type"))
39961693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
3997177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            foreach my $Pos (0 .. $#TParams)
3998177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
3999177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                my $Val = $TParams[$Pos];
4000177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $TypeAttr{"TParam"}{$Pos}{"name"} = $Val;
4001177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
4002177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(not defined $TypeAttr{"Template"})
4003177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
4004177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    my %Base = get_BaseType($TemplateInstance{$Version}{"Type"}{$TypeId}{$Pos}, $Version);
4005177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
4006177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if($Base{"Type"} eq "TemplateParam"
4007177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    or defined $Base{"Template"}) {
4008177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $TypeAttr{"Template"} = 1;
4009177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
4010177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
4011177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
4012177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if($Tmpl)
4013177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
4014177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if(my $Arg = $TemplateArg{$Version}{$Tmpl}{$Pos})
4015177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
4016177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $TemplateMap{$Version}{$TypeId}{$Arg} = $Val;
4017177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
4018177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        if($Val eq $Arg) {
4019177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            $TypeAttr{"Template"} = 1;
4020177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        }
4021177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
4022177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
4023177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
4024177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
4025177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($Tmpl)
4026177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
4027177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach my $Pos (sort {int($a)<=>int($b)} keys(%{$TemplateArg{$Version}{$Tmpl}}))
4028177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
4029177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if($Pos>$#TParams)
4030177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
4031177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        my $Arg = $TemplateArg{$Version}{$Tmpl}{$Pos};
4032177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $TemplateMap{$Version}{$TypeId}{$Arg} = "";
4033177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
4034177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
4035177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
4036177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
4037177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
4038177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($ADD_TMPL_INSTANCES)
4039177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
4040e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            if($Tmpl)
4041177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
4042e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                if(my $MainInst = getTreeAttr_Type($Tmpl))
4043177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
4044e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    if(not getTreeAttr_Flds($TypeId))
4045177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
4046177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        if(my $Flds = getTreeAttr_Flds($MainInst)) {
4047177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            $LibInfo{$Version}{"info"}{$TypeId} .= " flds: \@$Flds ";
4048177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        }
4049e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    }
4050e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    if(not getTreeAttr_Binf($TypeId))
4051e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    {
4052177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        if(my $Binf = getTreeAttr_Binf($MainInst)) {
4053177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            $LibInfo{$Version}{"info"}{$TypeId} .= " binf: \@$Binf ";
4054177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        }
4055177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
4056177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
40571693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
40581693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
40591693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
4060177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
4061177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $StaticFields = setTypeMemb($TypeId, \%TypeAttr);
4062177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
406301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(my $Size = getSize($TypeId))
406401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    {
406501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $Size = $Size/$BYTE_SIZE;
406601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $TypeAttr{"Size"} = "$Size";
4067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
40689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    else
4069177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
4070177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($ExtraDump)
4071177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
4072177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(not defined $TypeAttr{"Memb"}
4073177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            and not $Tmpl)
4074177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            { # declaration only
4075177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $TypeAttr{"Forward"} = 1;
4076177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
4077177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
40789927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
407974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
4080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TypeAttr{"Type"} eq "Struct"
408174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    and ($StaticFields or detect_lang($TypeId)))
4082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr{"Type"} = "Class";
4084850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $TypeAttr{"Copied"} = 1; # default, will be changed in getSymbolInfo()
4085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TypeAttr{"Type"} eq "Struct"
4087850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    or $TypeAttr{"Type"} eq "Class")
4088850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
408962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $Skip = setBaseClasses($TypeId, \%TypeAttr);
4090850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Skip) {
4091850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            return ();
4092850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
4093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4094f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(my $Algn = getAlgn($TypeId)) {
4095f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        $TypeAttr{"Algn"} = $Algn/$BYTE_SIZE;
4096f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
4097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    setSpec($TypeId, \%TypeAttr);
409874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
409974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($TypeAttr{"Type"}=~/\A(Struct|Union|Enum)\Z/)
410074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    {
410174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(not $TypedefToAnon{$TypeId}
4102177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        and not defined $TemplateInstance{$Version}{"Type"}{$TypeId})
410374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        {
410474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(not isAnon($TypeAttr{"Name"})) {
410574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $TypeAttr{"Name"} = lc($TypeAttr{"Type"})." ".$TypeAttr{"Name"};
410674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
410774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
410874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
410974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
4110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $TypeAttr{"Tid"} = $TypeId;
4111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $VTable = $ClassVTable_Content{$Version}{$TypeAttr{"Name"}})
4112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Entries = split(/\n/, $VTable);
4114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach (1 .. $#Entries)
4115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Entry = $Entries[$_];
4117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Entry=~/\A(\d+)\s+(.+)\Z/) {
4118177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $TypeAttr{"VTable"}{$1} = simplifyVTable($2);
4119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
412282bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko
412382bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    if($TypeAttr{"Type"} eq "Enum")
412482bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    {
412582bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko        if(not $TypeAttr{"NameSpace"})
412682bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko        {
412782bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko            foreach my $Pos (keys(%{$TypeAttr{"Memb"}}))
412882bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko            {
412982bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko                my $MName = $TypeAttr{"Memb"}{$Pos}{"name"};
41308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                my $MVal = $TypeAttr{"Memb"}{$Pos}{"value"};
413182bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko                $EnumConstants{$Version}{$MName} = {
41328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    "Value"=>$MVal,
413382bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko                    "Header"=>$TypeAttr{"Header"}
413482bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko                };
41358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if(isAnon($TypeAttr{"Name"}))
41368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                {
4137177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if($ExtraDump
4138177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    or is_target_header($TypeAttr{"Header"}, $Version))
4139177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
4140177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        %{$Constants{$Version}{$MName}} = (
4141177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            "Value" => $MVal,
4142177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            "Header" => $TypeAttr{"Header"}
4143177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        );
4144177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
41458f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
414682bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko            }
414782bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko        }
414882bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    }
414974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraDump)
41504b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    {
41514b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        if(defined $TypedefToAnon{$TypeId}) {
41524b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            $TypeAttr{"AnonTypedef"} = 1;
41534b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        }
41544b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    }
415582bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko
4156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return %TypeAttr;
4157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4159177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub simplifyVTable($)
4160177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{
4161177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $Content = $_[0];
4162177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($Content=~s/ \[with (.+)]//)
4163177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    { # std::basic_streambuf<_CharT, _Traits>::imbue [with _CharT = char, _Traits = std::char_traits<char>]
4164177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my @Elems = separate_Params($1, 0, 0))
4165177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
4166177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            foreach my $Elem (@Elems)
4167177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
4168177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if($Elem=~/\A(.+?)\s*=\s*(.+?)\Z/)
4169177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
4170177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    my ($Arg, $Val) = ($1, $2);
4171177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
4172177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if(defined $DEFAULT_STD_ARGS{$Arg}) {
4173177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $Content=~s/,\s*$Arg\b//g;
4174177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
4175177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    else {
4176177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $Content=~s/\b$Arg\b/$Val/g;
4177177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
4178177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
4179177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
4180177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
4181177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
4182177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
4183177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    return $Content;
4184177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
4185177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
4186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_lang($)
4187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TypeId = $_[0];
4189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Info = $LibInfo{$Version}{"info"}{$TypeId};
419062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(check_gcc($GCC_PATH, "4"))
41911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # GCC 4 fncs-node points to only non-artificial methods
4192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ($Info=~/(fncs)[ ]*:[ ]*@(\d+) /);
4193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
41951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # GCC 3
419662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $Fncs = getTreeAttr_Fncs($TypeId);
4197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while($Fncs)
4198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
419962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($LibInfo{$Version}{"info"}{$Fncs}!~/artificial/) {
4200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return 1;
4201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
420262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $Fncs = getTreeAttr_Chan($Fncs);
4203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
4206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4208ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setSpec($$)
4209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeId, $TypeAttr) = @_;
4211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Info = $LibInfo{$Version}{"info"}{$TypeId};
4212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Info=~/\s+spec\s+/) {
4213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr->{"Spec"} = 1;
4214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
421762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub setBaseClasses($$)
4218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
421962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $TypeAttr) = @_;
4220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Info = $LibInfo{$Version}{"info"}{$TypeId};
4221177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $Binf = getTreeAttr_Binf($TypeId))
4222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4223177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        my $Info = $LibInfo{$Version}{"info"}{$Binf};
4224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Pos = 0;
4225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while($Info=~s/(pub|public|prot|protected|priv|private|)[ ]+binf[ ]*:[ ]*@(\d+) //)
4226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my ($Access, $BInfoId) = ($1, $2);
4228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $ClassId = getBinfClassId($BInfoId);
4229850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            my $CType = $LibInfo{$Version}{"info_type"}{$ClassId};
4230850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if(not $CType or $CType eq "template_type_parm"
4231850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            or $CType eq "typename_type")
4232850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # skip
4233177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                # return 1;
4234850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
4235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $BaseInfo = $LibInfo{$Version}{"info"}{$BInfoId};
42364b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            if($Access=~/prot/) {
4237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $TypeAttr->{"Base"}{$ClassId}{"access"} = "protected";
4238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
42394b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            elsif($Access=~/priv/) {
4240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $TypeAttr->{"Base"}{$ClassId}{"access"} = "private";
4241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
424201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            $TypeAttr->{"Base"}{$ClassId}{"pos"} = "$Pos";
4243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($BaseInfo=~/virt/)
42441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # virtual base
4245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $TypeAttr->{"Base"}{$ClassId}{"virtual"} = 1;
4246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Class_SubClasses{$Version}{$ClassId}{$TypeId}=1;
42484b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            $Pos += 1;
4249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4251850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return 0;
4252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getBinfClassId($)
4255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Info = $LibInfo{$Version}{"info"}{$_[0]};
4257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Info=~/type[ ]*:[ ]*@(\d+) /;
4258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $1;
4259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub unmangledFormat($$)
4262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Name, $LibVersion) = @_;
4264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Name = uncover_typedefs($Name, $LibVersion);
4265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($Name=~s/([^\w>*])(const|volatile)(,|>|\Z)/$1$3/g){};
4266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Name=~s/\(\w+\)(\d)/$1/;
4267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Name;
4268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub modelUnmangled($$)
4271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($InfoId, $Compiler) = @_;
4273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Cache{"modelUnmangled"}{$Version}{$Compiler}{$InfoId}) {
4274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"modelUnmangled"}{$Version}{$Compiler}{$InfoId};
4275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $PureSignature = $SymbolInfo{$Version}{$InfoId}{"ShortName"};
4277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"Destructor"}) {
4278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $PureSignature = "~".$PureSignature;
4279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"Data"})
4281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my (@Params, @ParamTypes) = ();
4283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(defined $SymbolInfo{$Version}{$InfoId}{"Param"}
4284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and not $SymbolInfo{$Version}{$InfoId}{"Destructor"}) {
4285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @Params = keys(%{$SymbolInfo{$Version}{$InfoId}{"Param"}});
4286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $ParamPos (sort {int($a) <=> int($b)} @Params)
4288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # checking parameters
4289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $PId = $SymbolInfo{$Version}{$InfoId}{"Param"}{$ParamPos}{"type"};
4290f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            my %PType = get_PureType($PId, $TypeInfo{$Version});
4291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $PTName = unmangledFormat($PType{"Name"}, $Version);
429262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $PTName=~s/\b(restrict|register)\b//g;
4293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Compiler eq "MSVC") {
429462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $PTName=~s/\blong long\b/__int64/;
4295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @ParamTypes = (@ParamTypes, $PTName);
4297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(@ParamTypes) {
4299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $PureSignature .= "(".join(", ", @ParamTypes).")";
4300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
4302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Compiler eq "MSVC")
4304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
4305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $PureSignature .= "(void)";
4306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
4308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # GCC
4309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $PureSignature .= "()";
4310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $PureSignature = delete_keywords($PureSignature);
4313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $ClassId = $SymbolInfo{$Version}{$InfoId}{"Class"})
4315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
431662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ClassName = unmangledFormat($TypeInfo{$Version}{$ClassId}{"Name"}, $Version);
4317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $PureSignature = $ClassName."::".$PureSignature;
4318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif(my $NS = $SymbolInfo{$Version}{$InfoId}{"NameSpace"}) {
4320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $PureSignature = $NS."::".$PureSignature;
4321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"Const"}) {
4323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $PureSignature .= " const";
4324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"Volatile"}) {
4326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $PureSignature .= " volatile";
4327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $ShowReturn = 0;
4329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Compiler eq "MSVC"
4330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $SymbolInfo{$Version}{$InfoId}{"Data"})
4331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ShowReturn=1;
4333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
433462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif(defined $TemplateInstance{$Version}{"Func"}{$InfoId}
433562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and keys(%{$TemplateInstance{$Version}{"Func"}{$InfoId}}))
4336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ShowReturn=1;
4338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ShowReturn)
4340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # mangled names for template function specializations include return value
4341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $ReturnId = $SymbolInfo{$Version}{$InfoId}{"Return"})
4342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4343f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            my %RType = get_PureType($ReturnId, $TypeInfo{$Version});
4344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $ReturnName = unmangledFormat($RType{"Name"}, $Version);
4345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $PureSignature = $ReturnName." ".$PureSignature;
4346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
43489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return ($Cache{"modelUnmangled"}{$Version}{$Compiler}{$InfoId} = formatName($PureSignature, "S"));
4349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub mangle_symbol($$$)
4352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # mangling for simple methods
4353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # see gcc-4.6.0/gcc/cp/mangle.c
4354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($InfoId, $LibVersion, $Compiler) = @_;
4355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Cache{"mangle_symbol"}{$LibVersion}{$InfoId}{$Compiler}) {
4356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"mangle_symbol"}{$LibVersion}{$InfoId}{$Compiler};
4357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Mangled = "";
4359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Compiler eq "GCC") {
43601693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Mangled = mangle_symbol_GCC($InfoId, $LibVersion);
4361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Compiler eq "MSVC") {
43631693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Mangled = mangle_symbol_MSVC($InfoId, $LibVersion);
4364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"mangle_symbol"}{$LibVersion}{$InfoId}{$Compiler} = $Mangled);
4366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
43681693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub mangle_symbol_MSVC($$)
4369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($InfoId, $LibVersion) = @_;
4371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
4372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
43741693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub mangle_symbol_GCC($$)
4375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # see gcc-4.6.0/gcc/cp/mangle.c
4376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($InfoId, $LibVersion) = @_;
4377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Mangled, $ClassId, $NameSpace) = ("_Z", 0, "");
43781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Return = $SymbolInfo{$LibVersion}{$InfoId}{"Return"};
4379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %Repl = ();# SN_ replacements
4380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ClassId = $SymbolInfo{$LibVersion}{$InfoId}{"Class"})
4381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $MangledClass = mangle_param($ClassId, $LibVersion, \%Repl);
4383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MangledClass!~/\AN/) {
4384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledClass = "N".$MangledClass;
4385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
4387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledClass=~s/E\Z//;
4388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4389ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SymbolInfo{$LibVersion}{$InfoId}{"Volatile"}) {
4390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledClass=~s/\AN/NV/;
4391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SymbolInfo{$LibVersion}{$InfoId}{"Const"}) {
4393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledClass=~s/\AN/NK/;
4394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= $MangledClass;
4396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($NameSpace = $SymbolInfo{$LibVersion}{$InfoId}{"NameSpace"})
4398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # mangled by name due to the absence of structured info
4399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $MangledNS = mangle_ns($NameSpace, $LibVersion, \%Repl);
4400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MangledNS!~/\AN/) {
4401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledNS = "N".$MangledNS;
4402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
4404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledNS=~s/E\Z//;
4405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= $MangledNS;
4407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
440807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    my ($ShortName, $TmplParams) = template_Base($SymbolInfo{$LibVersion}{$InfoId}{"ShortName"});
44091693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my @TParams = ();
441035c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    if(my @TPos = keys(%{$SymbolInfo{$LibVersion}{$InfoId}{"TParam"}}))
44111693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # parsing mode
441235c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        foreach (@TPos) {
441335c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            push(@TParams, $SymbolInfo{$LibVersion}{$InfoId}{"TParam"}{$_}{"name"});
441435c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        }
44151693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
44161693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    elsif($TmplParams)
44171693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # remangling mode
44181693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko      # support for old ABI dumps
441907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        @TParams = separate_Params($TmplParams, 0, 0);
4420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolInfo{$LibVersion}{$InfoId}{"Constructor"}) {
4422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= "C1";
4423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($SymbolInfo{$LibVersion}{$InfoId}{"Destructor"}) {
4425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= "D0";
4426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($ShortName)
4428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
44291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SymbolInfo{$LibVersion}{$InfoId}{"Data"})
44301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
44311693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if(not $SymbolInfo{$LibVersion}{$InfoId}{"Class"}
4432850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            and isConstType($Return, $LibVersion))
44331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # "const" global data is mangled as _ZL...
44341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Mangled .= "L";
44351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
44361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
4437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($ShortName=~/\Aoperator(\W.*)\Z/)
4438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Op = $1;
4440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Op=~s/\A[ ]+//g;
4441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my $OpMngl = $OperatorMangling{$Op}) {
4442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled .= $OpMngl;
4443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else { # conversion operator
4445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled .= "cv".mangle_param(getTypeIdByName($Op, $LibVersion), $LibVersion, \%Repl);
4446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
4449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= length($ShortName).$ShortName;
4450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(@TParams)
4452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # templates
4453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "I";
44541477d2c1a4df8ea5c19b19604da6d4c5b7016d72Andrey Ponomarenko            foreach my $TParam (@TParams) {
4455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled .= mangle_template_param($TParam, $LibVersion, \%Repl);
4456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "E";
4458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $ClassId and @TParams) {
4460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            add_substitution($ShortName, \%Repl, 0);
4461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ClassId or $NameSpace) {
4464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= "E";
4465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4466850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(@TParams)
4467850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
44681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Return) {
4469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= mangle_param($Return, $LibVersion, \%Repl);
4470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SymbolInfo{$LibVersion}{$InfoId}{"Data"})
4473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Params = ();
4475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(defined $SymbolInfo{$LibVersion}{$InfoId}{"Param"}
4476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and not $SymbolInfo{$LibVersion}{$InfoId}{"Destructor"}) {
4477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @Params = keys(%{$SymbolInfo{$LibVersion}{$InfoId}{"Param"}});
4478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $ParamPos (sort {int($a) <=> int($b)} @Params)
4480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # checking parameters
4481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $ParamType_Id = $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{$ParamPos}{"type"};
4482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= mangle_param($ParamType_Id, $LibVersion, \%Repl);
4483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not @Params) {
4485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "v";
4486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Mangled = correct_incharge($InfoId, $LibVersion, $Mangled);
4489ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Mangled = write_stdcxx_substitution($Mangled);
4490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Mangled eq "_Z") {
4491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
4492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Mangled;
4494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub correct_incharge($$$)
4497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($InfoId, $LibVersion, $Mangled) = @_;
4499ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolInfo{$LibVersion}{$InfoId}{"Constructor"})
4500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MangledNames{$LibVersion}{$Mangled}) {
4502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled=~s/C1E/C2E/;
4503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($SymbolInfo{$LibVersion}{$InfoId}{"Destructor"})
4506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MangledNames{$LibVersion}{$Mangled}) {
4508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled=~s/D0E/D1E/;
4509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MangledNames{$LibVersion}{$Mangled}) {
4511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled=~s/D1E/D2E/;
4512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Mangled;
4515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
451707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenkosub template_Base($)
4518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # NOTE: std::_Vector_base<mysqlpp::mysql_type_info>::_Vector_impl
45191693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko  # NOTE: operators: >>, <<
4520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
45211693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($Name!~/>\Z/ or $Name!~/</) {
4522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Name;
4523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TParams = $Name;
45251693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    while(my $CPos = find_center($TParams, "<"))
45261693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # search for the last <T>
4527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TParams = substr($TParams, $CPos);
4528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
45291693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($TParams=~s/\A<(.+)>\Z/$1/) {
45301693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Name=~s/<\Q$TParams\E>\Z//;
45311693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
45321693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    else
45331693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # error
45341693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $TParams = "";
45351693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
4536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Name, $TParams);
4537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_sub_ns($)
4540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
4542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @NS = ();
45431693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    while(my $CPos = find_center($Name, ":"))
4544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        push(@NS, substr($Name, 0, $CPos));
4546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Name = substr($Name, $CPos);
4547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Name=~s/\A:://;
4548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return (join("::", @NS), $Name);
4550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub mangle_ns($$$)
4553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Name, $LibVersion, $Repl) = @_;
4555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Tid = $TName_Tid{$LibVersion}{$Name})
4556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Mangled = mangle_param($Tid, $LibVersion, $Repl);
4558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled=~s/\AN(.+)E\Z/$1/;
4559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Mangled;
4560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
4563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($MangledNS, $SubNS) = ("", "");
4565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        ($SubNS, $Name) = get_sub_ns($Name);
4566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SubNS) {
4567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledNS .= mangle_ns($SubNS, $LibVersion, $Repl);
4568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MangledNS .= length($Name).$Name;
4570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        add_substitution($MangledNS, $Repl, 0);
4571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $MangledNS;
4572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub mangle_param($$$)
4576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($PTid, $LibVersion, $Repl) = @_;
4578ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($MPrefix, $Mangled) = ("", "");
4579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %ReplCopy = %{$Repl};
458062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %BaseType = get_BaseType($PTid, $LibVersion);
4581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $BaseType_Name = $BaseType{"Name"};
458274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    $BaseType_Name=~s/\A(struct|union|enum) //g;
4583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $BaseType_Name) {
4584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
4585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
458607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    my ($ShortName, $TmplParams) = template_Base($BaseType_Name);
458762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $Suffix = get_BaseTypeQual($PTid, $LibVersion);
4588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($Suffix=~s/\s*(const|volatile|restrict)\Z//g){};
4589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($Suffix=~/(&|\*|const)\Z/)
4590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Suffix=~s/[ ]*&\Z//) {
4592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MPrefix .= "R";
4593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Suffix=~s/[ ]*\*\Z//) {
4595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MPrefix .= "P";
4596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Suffix=~s/[ ]*const\Z//)
4598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($MPrefix=~/R|P/
4600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            or $Suffix=~/&|\*/) {
4601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $MPrefix .= "K";
4602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Suffix=~s/[ ]*volatile\Z//) {
4605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MPrefix .= "V";
4606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        #if($Suffix=~s/[ ]*restrict\Z//) {
4608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            #$MPrefix .= "r";
4609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        #}
4610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Token = $IntrinsicMangling{$BaseType_Name}) {
4612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= $Token;
4613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($BaseType{"Type"}=~/(Class|Struct|Union|Enum)/)
4615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
46161693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my @TParams = ();
461735c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        if(my @TPos = keys(%{$BaseType{"TParam"}}))
46181693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # parsing mode
461935c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            foreach (@TPos) {
462035c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                push(@TParams, $BaseType{"TParam"}{$_}{"name"});
462135c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            }
46221693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
46231693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        elsif($TmplParams)
46241693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # remangling mode
46251693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko          # support for old ABI dumps
462607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            @TParams = separate_Params($TmplParams, 0, 0);
4627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $MangledNS = "";
4629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($SubNS, $SName) = get_sub_ns($ShortName);
4630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SubNS) {
4631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledNS .= mangle_ns($SubNS, $LibVersion, $Repl);
4632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MangledNS .= length($SName).$SName;
4634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(@TParams) {
4635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            add_substitution($MangledNS, $Repl, 0);
4636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= "N".$MangledNS;
4638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(@TParams)
4639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # templates
4640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "I";
4641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $TParam (@TParams) {
4642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled .= mangle_template_param($TParam, $LibVersion, $Repl);
4643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "E";
4645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= "E";
4647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($BaseType{"Type"}=~/(FuncPtr|MethodPtr)/)
4649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($BaseType{"Type"} eq "MethodPtr") {
4651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "M".mangle_param($BaseType{"Class"}, $LibVersion, $Repl)."F";
4652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
4654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "PF";
4655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= mangle_param($BaseType{"Return"}, $LibVersion, $Repl);
4657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Params = keys(%{$BaseType{"Param"}});
4658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Num (sort {int($a)<=>int($b)} @Params) {
4659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= mangle_param($BaseType{"Param"}{$Num}{"type"}, $LibVersion, $Repl);
4660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not @Params) {
4662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "v";
4663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= "E";
4665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($BaseType{"Type"} eq "FieldPtr")
4667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= "M".mangle_param($BaseType{"Class"}, $LibVersion, $Repl);
4669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= mangle_param($BaseType{"Return"}, $LibVersion, $Repl);
4670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Mangled = $MPrefix.$Mangled;# add prefix (RPK)
4672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Optimized = write_substitution($Mangled, \%ReplCopy))
4673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Mangled eq $Optimized)
4675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ShortName!~/::/)
4677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # remove "N ... E"
4678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($MPrefix) {
4679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Mangled=~s/\A($MPrefix)N(.+)E\Z/$1$2/g;
4680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
4681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
4682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Mangled=~s/\AN(.+)E\Z/$1/g;
4683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
4684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
4687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled = $Optimized;
4688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    add_substitution($Mangled, $Repl, 1);
4691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Mangled;
4692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub mangle_template_param($$$)
4695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # types + literals
4696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TParam, $LibVersion, $Repl) = @_;
4697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $TPTid = $TName_Tid{$LibVersion}{$TParam}) {
4698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return mangle_param($TPTid, $LibVersion, $Repl);
4699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($TParam=~/\A(\d+)(\w+)\Z/)
4701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # class_name<1u>::method(...)
4702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "L".$IntrinsicMangling{$ConstantSuffixR{$2}}.$1."E";
4703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($TParam=~/\A\(([\w ]+)\)(\d+)\Z/)
4705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # class_name<(signed char)1>::method(...)
4706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "L".$IntrinsicMangling{$1}.$2."E";
4707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($TParam eq "true")
4709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # class_name<true>::method(...)
4710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "Lb1E";
4711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($TParam eq "false")
4713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # class_name<true>::method(...)
4714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "Lb0E";
4715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else { # internal error
4717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return length($TParam).$TParam;
4718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub add_substitution($$$)
4722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Value, $Repl, $Rec) = @_;
4724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Rec)
4725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # subtypes
4726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Subs = ($Value);
4727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while($Value=~s/\A(R|P|K)//) {
4728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            push(@Subs, $Value);
4729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach (reverse(@Subs)) {
4731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            add_substitution($_, $Repl, 0);
4732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
4734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if($Value=~/\AS(\d*)_\Z/);
4736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Value=~s/\AN(.+)E\Z/$1/g;
4737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(defined $Repl->{$Value});
4738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(length($Value)<=1);
4739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if($StdcxxMangling{$Value});
4740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # check for duplicates
4741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Base = $Value;
4742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Type (sort {$Repl->{$a}<=>$Repl->{$b}} sort keys(%{$Repl}))
4743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Num = $Repl->{$Type};
4745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Replace = macro_mangle($Num);
4746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Base=~s/\Q$Replace\E/$Type/;
4747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $OldNum = $Repl->{$Base})
4749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Repl->{$Value} = $OldNum;
4751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
4752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Repls = sort {$b<=>$a} values(%{$Repl});
4754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(@Repls) {
4755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Repl->{$Value} = $Repls[0]+1;
4756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
4758ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Repl->{$Value} = -1;
4759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # register duplicates
4761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # upward
4762dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    $Base = $Value;
4763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Type (sort {$Repl->{$a}<=>$Repl->{$b}} sort keys(%{$Repl}))
4764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($Base eq $Type);
4766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Num = $Repl->{$Type};
4767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Replace = macro_mangle($Num);
4768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Base=~s/\Q$Type\E/$Replace/;
4769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Repl->{$Base} = $Repl->{$Value};
4770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub macro_mangle($)
4774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Num = $_[0];
4776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Num==-1) {
4777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "S_";
4778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
4780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Code = "";
4782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Num<10)
4783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # S0_, S1_, S2_, ...
4784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Code = $Num;
4785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Num>=10 and $Num<=35)
4787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # SA_, SB_, SC_, ...
4788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Code = chr(55+$Num);
4789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
4791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # S10_, S11_, S12_
4792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Code = $Num-26; # 26 is length of english alphabet
4793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "S".$Code."_";
4795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub write_stdcxx_substitution($)
4799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Mangled = $_[0];
4801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($StdcxxMangling{$Mangled}) {
4802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $StdcxxMangling{$Mangled};
4803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
4805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Repls = keys(%StdcxxMangling);
4807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        @Repls = sort {length($b)<=>length($a)} sort {$b cmp $a} @Repls;
4808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $MangledType (@Repls)
4809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Replace = $StdcxxMangling{$MangledType};
4811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            #if($Mangled!~/$Replace/) {
4812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled=~s/N\Q$MangledType\EE/$Replace/g;
4813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled=~s/\Q$MangledType\E/$Replace/g;
4814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            #}
4815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Mangled;
4818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub write_substitution($$)
4821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Mangled, $Repl) = @_;
4823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Repl->{$Mangled}
4824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and my $MnglNum = $Repl->{$Mangled}) {
4825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled = macro_mangle($MnglNum);
4826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
4828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Repls = keys(%{$Repl});
4830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        #@Repls = sort {$Repl->{$a}<=>$Repl->{$b}} @Repls;
4831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # FIXME: how to apply replacements? by num or by pos
4832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        @Repls = sort {length($b)<=>length($a)} sort {$b cmp $a} @Repls;
4833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $MangledType (@Repls)
4834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Replace = macro_mangle($Repl->{$MangledType});
4836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Mangled!~/$Replace/) {
4837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled=~s/N\Q$MangledType\EE/$Replace/g;
4838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled=~s/\Q$MangledType\E/$Replace/g;
4839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Mangled;
4843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub delete_keywords($)
4846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TypeName = $_[0];
484862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    $TypeName=~s/\b(enum|struct|union|class) //g;
4849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $TypeName;
4850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub uncover_typedefs($$)
4853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeName, $LibVersion) = @_;
4855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $TypeName);
4856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Cache{"uncover_typedefs"}{$LibVersion}{$TypeName}) {
4857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"uncover_typedefs"}{$LibVersion}{$TypeName};
4858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
48599927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my ($TypeName_New, $TypeName_Pre) = (formatName($TypeName, "T"), "");
4860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($TypeName_New ne $TypeName_Pre)
4861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeName_Pre = $TypeName_New;
4863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $TypeName_Copy = $TypeName_New;
4864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my %Words = ();
486562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        while($TypeName_Copy=~s/\b([a-z_]([\w:]*\w|))\b//io)
4866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
486762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(not $Intrinsic_Keywords{$1}) {
486862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $Words{$1} = 1;
486962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
4870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Word (keys(%Words))
4872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $BaseType_Name = $Typedef_BaseName{$LibVersion}{$Word};
4874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(not $BaseType_Name);
487562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            next if($TypeName_New=~/\b(struct|union|enum)\s\Q$Word\E\b/);
4876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($BaseType_Name=~/\([\*]+\)/)
4877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # FuncPtr
4878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($TypeName_New=~/\Q$Word\E(.*)\Z/)
4879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
4880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $Type_Suffix = $1;
4881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $TypeName_New = $BaseType_Name;
4882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($TypeName_New=~s/\(([\*]+)\)/($1 $Type_Suffix)/) {
48839927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        $TypeName_New = formatName($TypeName_New, "T");
4884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
4885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
4886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
4888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
488962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($TypeName_New=~s/\b\Q$Word\E\b/$BaseType_Name/g) {
48909927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $TypeName_New = formatName($TypeName_New, "T");
4891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
4892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"uncover_typedefs"}{$LibVersion}{$TypeName} = $TypeName_New);
4896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isInternal($)
4899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4900989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
4901989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    {
4902989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/mngl[ ]*:[ ]*@(\d+) /)
4903989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        {
4904989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if($LibInfo{$Version}{"info"}{$1}=~/\*[ ]*INTERNAL[ ]*\*/)
4905989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            { # _ZN7mysqlpp8DateTimeC1ERKS0_ *INTERNAL*
4906989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                return 1;
4907989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
4908989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
4909989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
4910989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return 0;
4911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
49130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub getDataVal($$)
49140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
49150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($InfoId, $TypeId) = @_;
49160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$InfoId})
49170d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
49180d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($Info=~/init[ ]*:[ ]*@(\d+) /)
49190d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
49200d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(defined $LibInfo{$Version}{"info_type"}{$1}
49210d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and $LibInfo{$Version}{"info_type"}{$1} eq "nop_expr")
49228f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
49238f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if(my $Nop = getTreeAttr_Op($1))
49240d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                {
49258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    if(defined $LibInfo{$Version}{"info_type"}{$Nop}
49268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    and $LibInfo{$Version}{"info_type"}{$Nop} eq "addr_expr")
49270d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    {
49288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        if(my $Addr = getTreeAttr_Op($1)) {
49298f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                            return getInitVal($Addr, $TypeId);
49300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        }
49310d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
49320d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
49330d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
49340d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            else {
49350d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                return getInitVal($1, $TypeId);
49360d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
49370d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
49380d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
49390d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return undef;
49400d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
49410d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
49420d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub getInitVal($$)
49430d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
49440d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($InfoId, $TypeId) = @_;
49450d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$InfoId})
49460d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
49470d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(my $InfoType = $LibInfo{$Version}{"info_type"}{$InfoId})
49480d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
49490d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if($InfoType eq "integer_cst")
49500d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
49510d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                my $Val = getNodeIntCst($InfoId);
495262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($TypeId and $TypeInfo{$Version}{$TypeId}{"Name"}=~/\Achar(| const)\Z/)
49530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                { # characters
49540d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    $Val = chr($Val);
49550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
49560d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                return $Val;
49570d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
49580d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            elsif($InfoType eq "string_cst") {
49590d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                return getNodeStrCst($InfoId);
49600d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
496101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            elsif($InfoType eq "var_decl")
496201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            {
496301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                if(my $Name = getNodeStrCst(getTreeAttr_Mngl($InfoId))) {
496401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    return $Name;
496501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                }
496601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
49670d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
49680d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
49690d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return undef;
49700d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
49710d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
4972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub set_Class_And_Namespace($)
4973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $InfoId = $_[0];
4975989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$InfoId})
4976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4977989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/scpe[ ]*:[ ]*@(\d+) /)
4978dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
4979989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            my $NSInfoId = $1;
4980989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if(my $InfoType = $LibInfo{$Version}{"info_type"}{$NSInfoId})
4981989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
4982989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                if($InfoType eq "namespace_decl") {
4983989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    $SymbolInfo{$Version}{$InfoId}{"NameSpace"} = getNameSpace($InfoId);
4984989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
4985989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                elsif($InfoType eq "record_type") {
4986989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    $SymbolInfo{$Version}{$InfoId}{"Class"} = $NSInfoId;
4987989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
4988dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
4989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"Class"}
4992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $SymbolInfo{$Version}{$InfoId}{"NameSpace"})
4993fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
4994570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if($COMMON_LANGUAGE{$Version} ne "C++")
4995fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # skip
4996fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            return 1;
4997570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
4998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4999fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
5000fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return 0;
5001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5002ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub debugMangling($)
5004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
5006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %Mangled = ();
5007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $InfoId (keys(%{$SymbolInfo{$LibVersion}}))
5008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
5009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $Mngl = $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"})
5010ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
5011ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Mngl=~/\A(_Z|\?)/) {
5012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled{$Mngl}=$InfoId;
5013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    translateSymbols(keys(%Mangled), $LibVersion);
5017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Mngl (keys(%Mangled))
5018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
5019850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $U1 = modelUnmangled($Mangled{$Mngl}, "GCC");
5020850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $U2 = $tr_name{$Mngl};
5021850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($U1 ne $U2) {
5022850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            printMsg("INFO", "INCORRECT MANGLING:\n  $Mngl\n  $U1\n  $U2\n");
5023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub linkSymbol($)
5028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # link symbols from shared libraries
5029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # with the symbols from header files
5030ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $InfoId = $_[0];
5031ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # try to mangle symbol
503262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if((not check_gcc($GCC_PATH, "4") and $SymbolInfo{$Version}{$InfoId}{"Class"})
503362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    or (check_gcc($GCC_PATH, "4") and not $SymbolInfo{$Version}{$InfoId}{"Class"}))
5034ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # 1. GCC 3.x doesn't mangle class methods names in the TU dump (only functions and global data)
5035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # 2. GCC 4.x doesn't mangle C++ functions in the TU dump (only class methods) except extern "C" functions
50361693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(not $CheckHeadersOnly)
5037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
5038ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my $Mangled = $mangled_name_gcc{modelUnmangled($InfoId, "GCC")}) {
5039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return correct_incharge($InfoId, $Version, $Mangled);
5040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5041ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
50421693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($CheckHeadersOnly
50431693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        or not $BinaryOnly)
50441693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # 1. --headers-only mode
50451693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko          # 2. not mangled src-only symbols
50461693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if(my $Mangled = mangle_symbol($InfoId, $Version, "GCC")) {
50471693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                return $Mangled;
50481693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
50491693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
5050ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5051ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
5052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5053ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5054ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setLanguage($$)
5055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5056ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($LibVersion, $Lang) = @_;
5057ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $UserLang) {
5058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $COMMON_LANGUAGE{$LibVersion} = $Lang;
5059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5062ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getSymbolInfo($)
5063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
50641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $InfoId = $_[0];
5065989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(isInternal($InfoId)) {
5066989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        return;
5067989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
50681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    ($SymbolInfo{$Version}{$InfoId}{"Header"}, $SymbolInfo{$Version}{$InfoId}{"Line"}) = getLocation($InfoId);
50691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"Header"}
5070a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    or isBuiltIn($SymbolInfo{$Version}{$InfoId}{"Header"}))
5071a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    {
50721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
5073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
5074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
50751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    setFuncAccess($InfoId);
50761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    setFuncKind($InfoId);
5077a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"PseudoTemplate"})
5078a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    {
50791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
5080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
5081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
508274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
50831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $SymbolInfo{$Version}{$InfoId}{"Type"} = getFuncType($InfoId);
5084177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $Return = getFuncReturn($InfoId))
508562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
5086177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not defined $TypeInfo{$Version}{$Return}
5087177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        or not $TypeInfo{$Version}{$Return}{"Name"})
5088177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
508962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
509062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return;
509162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
5092177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Return"} = $Return;
509362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
509462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $Rid = $SymbolInfo{$Version}{$InfoId}{"Return"})
509562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
509662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(defined $MissedTypedef{$Version}{$Rid})
509762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
509862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $AddedTid = $MissedTypedef{$Version}{$Rid}{"Tid"}) {
509962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"Return"} = $AddedTid;
510062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
510162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
5102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
51031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"Return"}) {
51041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId}{"Return"});
5105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5106a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    my $Orig = getFuncOrig($InfoId);
5107a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    $SymbolInfo{$Version}{$InfoId}{"ShortName"} = getFuncShortName($Orig);
510874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(index($SymbolInfo{$Version}{$InfoId}{"ShortName"}, "\._")!=-1)
510974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    {
511074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
511174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        return;
511274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
511374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
511474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(index($SymbolInfo{$Version}{$InfoId}{"ShortName"}, "tmp_add_func")==0)
5115a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    {
51161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
5117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
5118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5119a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko
5120a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    if(defined $TemplateInstance{$Version}{"Func"}{$Orig})
5121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
5122177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        my $Tmpl = $BasicTemplate{$Version}{$InfoId};
5123177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
5124a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        my @TParams = getTParams($Orig, "Func");
5125a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if(not @TParams)
5126a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        {
51271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
5128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return;
5129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5130177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Pos (0 .. $#TParams)
5131177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
5132177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            my $Val = $TParams[$Pos];
5133177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"TParam"}{$Pos}{"name"} = $Val;
5134177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
5135177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($Tmpl)
5136177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
5137177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(my $Arg = $TemplateArg{$Version}{$Tmpl}{$Pos})
5138177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
5139177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $TemplateMap{$Version}{$InfoId}{$Arg} = $Val;
5140177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
5141177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
5142177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
5143177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
5144177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($Tmpl)
5145177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
5146177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            foreach my $Pos (sort {int($a)<=>int($b)} keys(%{$TemplateArg{$Version}{$Tmpl}}))
5147177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
5148177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if($Pos>$#TParams)
5149177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
5150177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    my $Arg = $TemplateArg{$Version}{$Tmpl}{$Pos};
5151177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $TemplateMap{$Version}{$InfoId}{$Arg} = "";
5152177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
5153177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
51541693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
5155177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
5156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $PrmsInLine = join(", ", @TParams);
51571693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($SymbolInfo{$Version}{$InfoId}{"ShortName"}=~/\Aoperator\W+\Z/)
51581693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # operator<< <T>, operator>> <T>
51591693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"ShortName"} .= " ";
51601693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
51611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"ShortName"} .= "<".$PrmsInLine.">";
51629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"ShortName"} = formatName($SymbolInfo{$Version}{$InfoId}{"ShortName"}, "S");
5163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
5165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for GCC 3.4
51661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"ShortName"}=~s/<.+>\Z//;
5167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5168f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(my $MnglName = getTreeStr(getTreeAttr_Mngl($InfoId)))
5169f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    {
5170f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($OSgroup eq "windows")
5171f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        { # cut the offset
5172f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $MnglName=~s/\@\d+\Z//g;
5173f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
5174f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $MnglName;
5175f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
5176f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        # NOTE: mangling of some symbols may change depending on GCC version
5177f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        # GCC 4.6: _ZN28QExplicitlySharedDataPointerI11QPixmapDataEC2IT_EERKS_IT_E
5178f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        # GCC 4.7: _ZN28QExplicitlySharedDataPointerI11QPixmapDataEC2ERKS1_
5179f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
5180989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko
51811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"MnglName"}
51829927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    and index($SymbolInfo{$Version}{$InfoId}{"MnglName"}, "_Z")!=0)
5183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
51841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
5185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
5186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
51871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"Destructor"})
5188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # destructors have an empty parameter list
51891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $Skip = setFuncParams($InfoId);
519007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        if($Skip)
519107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        {
51921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
5193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return;
5194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5196fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($LibInfo{$Version}{"info"}{$InfoId}=~/ artificial /i) {
5197fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Artificial"} = 1;
5198fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
5199fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
5200fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(set_Class_And_Namespace($InfoId))
5201fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
5202fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
5203fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return;
5204fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
5205fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
520662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $ClassId = $SymbolInfo{$Version}{$InfoId}{"Class"})
520762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
5208177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not defined $TypeInfo{$Version}{$ClassId}
5209177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        or not $TypeInfo{$Version}{$ClassId}{"Name"})
5210177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
521162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
521262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return;
521362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
521462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
521535c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    if($LibInfo{$Version}{"info"}{$InfoId}=~/ lang:[ ]*C /i)
521635c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    { # extern "C"
52171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Lang"} = "C";
521835c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $SymbolInfo{$Version}{$InfoId}{"ShortName"};
5219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5220dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($UserLang and $UserLang eq "C")
5221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --lang=C option
52221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $SymbolInfo{$Version}{$InfoId}{"ShortName"};
5223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($COMMON_LANGUAGE{$Version} eq "C++")
5225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # correct mangled & short names
52261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      # C++ or --headers-only mode
52271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SymbolInfo{$Version}{$InfoId}{"ShortName"}=~/\A__(comp|base|deleting)_(c|d)tor\Z/)
5228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # support for old GCC versions: reconstruct real names for constructors and destructors
52291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"ShortName"} = getNameByInfo(getTypeDeclId($SymbolInfo{$Version}{$InfoId}{"Class"}));
52301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"ShortName"}=~s/<.+>\Z//;
5231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
52321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $SymbolInfo{$Version}{$InfoId}{"MnglName"})
5233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # try to mangle symbol (link with libraries)
52341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if(my $Mangled = linkSymbol($InfoId)) {
52351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $Mangled;
5236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($OStarget eq "windows")
5239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # link MS C++ symbols from library with GCC symbols from headers
5240dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(my $Mangled1 = $mangled_name{$Version}{modelUnmangled($InfoId, "MSVC")})
5241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # exported symbols
5242dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $Mangled1;
5243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5244dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            elsif(my $Mangled2 = mangle_symbol($InfoId, $Version, "MSVC"))
5245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # pure virtual symbols
5246dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $Mangled2;
5247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5250fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    else
5251fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # not mangled in C
5252fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $SymbolInfo{$Version}{$InfoId}{"ShortName"};
5253fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
52548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(not $CheckHeadersOnly
52558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    and $SymbolInfo{$Version}{$InfoId}{"Type"} eq "Function"
52568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    and not $SymbolInfo{$Version}{$InfoId}{"Class"})
52578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
52588f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $Incorrect = 0;
52598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
52608f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($SymbolInfo{$Version}{$InfoId}{"MnglName"})
52618f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
52628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(index($SymbolInfo{$Version}{$InfoId}{"MnglName"}, "_Z")==0
52638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            and not link_symbol($SymbolInfo{$Version}{$InfoId}{"MnglName"}, $Version, "-Deps"))
52648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # mangled in the TU dump, but not mangled in the library
52658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $Incorrect = 1;
52668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
52678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
52688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        else
52698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
52708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($SymbolInfo{$Version}{$InfoId}{"Lang"} ne "C")
52718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # all C++ functions are not mangled in the TU dump
52728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $Incorrect = 1;
52738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
52748f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
52758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Incorrect)
52768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
52778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(link_symbol($SymbolInfo{$Version}{$InfoId}{"ShortName"}, $Version, "-Deps")) {
52788f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $SymbolInfo{$Version}{$InfoId}{"ShortName"};
52798f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
52808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
52818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
52821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"MnglName"})
5283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # can't detect symbol name
52841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
5285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
5286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5287989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"Constructor"}
5288a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    and my $Spec = getVirtSpec($Orig))
5289989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    { # identify virtual and pure virtual functions
5290989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko      # NOTE: constructors cannot be virtual
5291989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko      # NOTE: in GCC 4.7 D1 destructors have no virtual spec
5292989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko      # in the TU dump, so taking it from the original symbol
5293989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if(not ($SymbolInfo{$Version}{$InfoId}{"Destructor"}
5294989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        and $SymbolInfo{$Version}{$InfoId}{"MnglName"}=~/D2E/))
5295989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        { # NOTE: D2 destructors are not present in a v-table
5296989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{$Spec} = 1;
5297989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
5298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
52991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(isInline($InfoId)) {
53001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"InLine"} = 1;
5301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
530282bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    if(hasThrow($InfoId)) {
5303e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Throw"} = 1;
5304e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    }
53051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"Constructor"}
53061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    and my $ClassId = $SymbolInfo{$Version}{$InfoId}{"Class"})
5307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
53081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $SymbolInfo{$Version}{$InfoId}{"InLine"}
5309b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        and not $SymbolInfo{$Version}{$InfoId}{"Artificial"})
5310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # inline or auto-generated constructor
531162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            delete($TypeInfo{$Version}{$ClassId}{"Copied"});
5312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5314850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(my $Symbol = $SymbolInfo{$Version}{$InfoId}{"MnglName"})
5315850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
5316570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(not $ExtraDump)
5317570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
5318570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(not selectSymbol($Symbol, $SymbolInfo{$Version}{$InfoId}, "Dump", $Version))
5319570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            { # non-target symbols
5320570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                delete($SymbolInfo{$Version}{$InfoId});
5321570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                return;
5322570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
5323850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
5324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
53251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"Type"} eq "Method"
53261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $SymbolInfo{$Version}{$InfoId}{"Constructor"}
53271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $SymbolInfo{$Version}{$InfoId}{"Destructor"}
53281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $SymbolInfo{$Version}{$InfoId}{"Class"})
5329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
53309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($SymbolInfo{$Version}{$InfoId}{"MnglName"}!~/\A(_Z|\?)/)
53319927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
53321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
5333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return;
5334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
53361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"MnglName"})
5337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
53381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($MangledNames{$Version}{$SymbolInfo{$Version}{$InfoId}{"MnglName"}})
5339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # one instance for one mangled name only
53401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
5341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return;
5342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
53441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $MangledNames{$Version}{$SymbolInfo{$Version}{$InfoId}{"MnglName"}} = 1;
5345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
53471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"Constructor"}
53481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $SymbolInfo{$Version}{$InfoId}{"Destructor"}) {
53491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId}{"Return"});
5350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
53511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"MnglName"}=~/\A(_Z|\?)/
53521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    and $SymbolInfo{$Version}{$InfoId}{"Class"})
5353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
53541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SymbolInfo{$Version}{$InfoId}{"Type"} eq "Function")
5355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # static methods
53561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"Static"} = 1;
5357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
53591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(getFuncLink($InfoId) eq "Static") {
53601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Static"} = 1;
5361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5362dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"MnglName"}=~/\A(_Z|\?)/)
5363dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
5364dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if(my $Unmangled = $tr_name{$SymbolInfo{$Version}{$InfoId}{"MnglName"}})
5365dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
53669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($Unmangled=~/\.\_\d/)
53679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
5368dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                delete($SymbolInfo{$Version}{$InfoId});
5369dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                return;
5370dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
5371dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
53731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    delete($SymbolInfo{$Version}{$InfoId}{"Type"});
53741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"MnglName"}=~/\A_ZN(V|)K/) {
53751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Const"} = 1;
5376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
53771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"MnglName"}=~/\A_ZN(K|)V/) {
53781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Volatile"} = 1;
5379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
538007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
538107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if($WeakSymbols{$Version}{$SymbolInfo{$Version}{$InfoId}{"MnglName"}}) {
538207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Weak"} = 1;
538307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    }
538474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
538574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraDump) {
538674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Header"} = guessHeader($InfoId);
538774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
538874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko}
538974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
539074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkosub guessHeader($)
539174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko{
539274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $InfoId = $_[0];
539374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $ShortName = $SymbolInfo{$Version}{$InfoId}{"ShortName"};
539474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $ClassId = $SymbolInfo{$Version}{$InfoId}{"Class"};
539574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $ClassName = $ClassId?get_ShortClass($ClassId, $Version):"";
539674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $Header = $SymbolInfo{$Version}{$InfoId}{"Header"};
539774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(my $HPath = $SymbolHeader{$Version}{$ClassName}{$ShortName})
539874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    {
539974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(get_filename($HPath) eq $Header)
540074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        {
540174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $HDir = get_filename(get_dirname($HPath));
540274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if($HDir ne "include"
540374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            and $HDir=~/\A[a-z]+\Z/i) {
540474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                return join_P($HDir, $Header);
540574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
540674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
540774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
540874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return $Header;
5409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isInline($)
5412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # "body: undefined" in the tree
5413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # -fkeep-inline-functions GCC option should be specified
5414dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5415dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
5416dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/ undefined /i) {
5417dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return 0;
5418dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1;
5421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5423e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenkosub hasThrow($)
5424e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko{
5425e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5426e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    {
5427e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko        if($Info=~/type[ ]*:[ ]*@(\d+) /) {
5428e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko            return getTreeAttr_Unql($1, "unql");
5429e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko        }
5430e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    }
5431e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    return 1;
5432e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko}
5433e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko
5434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTypeId($)
5435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5436dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5437dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
5438dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/type[ ]*:[ ]*@(\d+) /) {
5439dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return $1;
5440dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5442dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
5443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setTypeMemb($$)
5446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeId, $TypeAttr) = @_;
5448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TypeType = $TypeAttr->{"Type"};
54490d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Pos, $UnnamedPos) = (0, 0);
545074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $StaticFields = 0;
5451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TypeType eq "Enum")
5452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
54534b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        my $MInfoId = getTreeAttr_Csts($TypeId);
54544b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        while($MInfoId)
5455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
54564b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            $TypeAttr->{"Memb"}{$Pos}{"value"} = getEnumMembVal($MInfoId);
54574b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            my $MembName = getTreeStr(getTreeAttr_Purp($MInfoId));
545862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $TypeAttr->{"Memb"}{$Pos}{"name"} = $MembName;
54594b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            $EnumMembName_Id{$Version}{getTreeAttr_Valu($MInfoId)} = ($TypeAttr->{"NameSpace"})?$TypeAttr->{"NameSpace"}."::".$MembName:$MembName;
54604b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            $MInfoId = getNextElem($MInfoId);
54610d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $Pos += 1;
5462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($TypeType=~/\A(Struct|Class|Union)\Z/)
5465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
54664b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        my $MInfoId = getTreeAttr_Flds($TypeId);
54674b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        while($MInfoId)
5468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
54694b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            my $IType = $LibInfo{$Version}{"info_type"}{$MInfoId};
54704b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            my $MInfo = $LibInfo{$Version}{"info"}{$MInfoId};
5471989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if(not $IType or $IType ne "field_decl")
5472989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            { # search for fields, skip other stuff in the declaration
547374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
547474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if($IType eq "var_decl")
547574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                { # static field
547674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $StaticFields = 1;
547774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
547874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
54794b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                $MInfoId = getNextElem($MInfoId);
5480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
5481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
54824b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            my $StructMembName = getTreeStr(getTreeAttr_Name($MInfoId));
5483fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(index($StructMembName, "_vptr.")==0)
54841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # virtual tables
5485fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $StructMembName = "_vptr";
5486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $StructMembName)
5488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # unnamed fields
548901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                if(index($TypeAttr->{"Name"}, "_type_info_pseudo")==-1)
5490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
54914b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                    my $UnnamedTid = getTreeAttr_Type($MInfoId);
5492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $UnnamedTName = getNameByInfo(getTypeDeclId($UnnamedTid));
5493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(isAnon($UnnamedTName))
5494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # rename unnamed fields to unnamed0, unnamed1, ...
5495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $StructMembName = "unnamed".($UnnamedPos++);
5496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
5497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
5498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5499ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $StructMembName)
5500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # unnamed fields and base classes
55014b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                $MInfoId = getNextElem($MInfoId);
5502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
5503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
55044b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            my $MembTypeId = getTreeAttr_Type($MInfoId);
550562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(defined $MissedTypedef{$Version}{$MembTypeId})
550662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
550762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(my $AddedTid = $MissedTypedef{$Version}{$MembTypeId}{"Tid"}) {
550862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $MembTypeId = $AddedTid;
550962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
5510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5511177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
55120d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $TypeAttr->{"Memb"}{$Pos}{"type"} = $MembTypeId;
55130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $TypeAttr->{"Memb"}{$Pos}{"name"} = $StructMembName;
55144b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            if((my $Access = getTreeAccess($MInfoId)) ne "public")
55151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # marked only protected and private, public by default
55160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $TypeAttr->{"Memb"}{$Pos}{"access"} = $Access;
55170d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
55180d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if($MInfo=~/spec:\s*mutable /)
55190d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            { # mutable fields
55200d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $TypeAttr->{"Memb"}{$Pos}{"mutable"} = 1;
5521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
55224b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            if(my $Algn = getAlgn($MInfoId)) {
5523f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                $TypeAttr->{"Memb"}{$Pos}{"algn"} = $Algn;
5524f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
55254b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            if(my $BFSize = getBitField($MInfoId))
5526f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            { # in bits
55270d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $TypeAttr->{"Memb"}{$Pos}{"bitfield"} = $BFSize;
5528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
5530f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            { # in bytes
5531177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if($TypeAttr->{"Memb"}{$Pos}{"algn"}==1)
5532177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                { # template
5533177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    delete($TypeAttr->{"Memb"}{$Pos}{"algn"});
5534177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
5535177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                else {
5536177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $TypeAttr->{"Memb"}{$Pos}{"algn"} /= $BYTE_SIZE;
5537177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
5538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5539f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
55404b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            $MInfoId = getNextElem($MInfoId);
55410d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $Pos += 1;
5542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
554474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
554574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return $StaticFields;
5546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setFuncParams($)
5549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
55501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $InfoId = $_[0];
555162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $ParamInfoId = getTreeAttr_Args($InfoId);
5552989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(getFuncType($InfoId) eq "Method")
5553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # check type of "this" pointer
555462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ObjectTypeId = getTreeAttr_Type($ParamInfoId);
555562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $ObjectName = $TypeInfo{$Version}{$ObjectTypeId}{"Name"})
5556850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
555762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($ObjectName=~/\bconst(| volatile)\*const\b/) {
5558850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"Const"} = 1;
5559850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
556062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($ObjectName=~/\bvolatile\b/) {
5561850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"Volatile"} = 1;
5562850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
5563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5564850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        else
5565850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # skip
5566850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            return 1;
5567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5568ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        # skip "this"-parameter
5569ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        # $ParamInfoId = getNextElem($ParamInfoId);
5570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
55710d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Pos, $Vtt_Pos) = (0, -1);
5572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($ParamInfoId)
55730d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # formal args
557462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ParamTypeId = getTreeAttr_Type($ParamInfoId);
557562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ParamName = getTreeStr(getTreeAttr_Name($ParamInfoId));
557662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $ParamName)
557762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # unnamed
557862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $ParamName = "p".($Pos+1);
5579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
558062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(defined $MissedTypedef{$Version}{$ParamTypeId})
558162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
558262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $AddedTid = $MissedTypedef{$Version}{$ParamTypeId}{"Tid"}) {
558362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $ParamTypeId = $AddedTid;
558462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
558562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
558662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $PType = $TypeInfo{$Version}{$ParamTypeId}{"Type"};
5587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $PType or $PType eq "Unknown") {
5588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
5589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
559062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $PTName = $TypeInfo{$Version}{$ParamTypeId}{"Name"};
5591989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if(not $PTName) {
5592989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            return 1;
5593989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
5594989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($PTName eq "void") {
5595989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            last;
5596989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
5597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($ParamName eq "__vtt_parm"
559862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        and $TypeInfo{$Version}{$ParamTypeId}{"Name"} eq "void const**")
5599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
56000d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $Vtt_Pos = $Pos;
5601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ParamInfoId = getNextElem($ParamInfoId);
5602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
5603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
56040d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"type"} = $ParamTypeId;
5605177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
5606177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my %Base = get_BaseType($ParamTypeId, $Version))
5607177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
5608177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $Base{"Template"}) {
5609177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                return 1;
5610177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
5611177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
5612177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
56130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"name"} = $ParamName;
561462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $Algn = getAlgn($ParamInfoId)) {
561562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"algn"} = $Algn/$BYTE_SIZE;
561662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
56170d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(not $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"name"}) {
56180d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"name"} = "p".($Pos+1);
5619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LibInfo{$Version}{"info"}{$ParamInfoId}=~/spec:\s*register /)
5621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # foo(register type arg)
56220d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"reg"} = 1;
5623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ParamInfoId = getNextElem($ParamInfoId);
56250d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        $Pos += 1;
5626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
56270d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(setFuncArgs($InfoId, $Vtt_Pos)) {
562801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"type"} = "-1";
5629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
5631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
56330d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub setFuncArgs($$)
5634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
56351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($InfoId, $Vtt_Pos) = @_;
56361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $FuncTypeId = getFuncTypeId($InfoId);
563762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $ParamListElemId = getTreeAttr_Prms($FuncTypeId);
56381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(getFuncType($InfoId) eq "Method") {
563946bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko        # $ParamListElemId = getNextElem($ParamListElemId);
5640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
56410d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(not $ParamListElemId)
56420d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # foo(...)
56430d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return 1;
56440d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
5645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $HaveVoid = 0;
56460d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $Pos = 0;
5647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($ParamListElemId)
56480d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # actual params: may differ from formal args
56490d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko      # formal int*const
56500d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko      # actual: int*
56510d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($Vtt_Pos!=-1 and $Pos==$Vtt_Pos)
5652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
5653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Vtt_Pos=-1;
5654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ParamListElemId = getNextElem($ParamListElemId);
5655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
5656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
565762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ParamTypeId = getTreeAttr_Valu($ParamListElemId);
565862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($TypeInfo{$Version}{$ParamTypeId}{"Name"} eq "void")
5659dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
5660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $HaveVoid = 1;
5661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            last;
5662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
566346bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko        else
5664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
566546bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko            if(not defined $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"type"})
566646bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko            {
566746bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"type"} = $ParamTypeId;
566846bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                if(not $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"name"})
566946bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                { # unnamed
567046bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                    $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"name"} = "p".($Pos+1);
567146bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                }
567246bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko            }
567346bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko            elsif(my $OldId = $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"type"})
567446bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko            {
5675e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                if($Pos>0 or getFuncType($InfoId) ne "Method")
567646bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                { # params
567746bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                    if($OldId ne $ParamTypeId)
567846bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                    {
567946bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                        my %Old_Pure = get_PureType($OldId, $TypeInfo{$Version});
568046bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                        my %New_Pure = get_PureType($ParamTypeId, $TypeInfo{$Version});
568146bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko
568246bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                        if($Old_Pure{"Name"} ne $New_Pure{"Name"}) {
568346bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                            $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"type"} = $ParamTypeId;
568446bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                        }
568546bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                    }
568646bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                }
56870d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
56880d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
568962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $PurpId = getTreeAttr_Purp($ParamListElemId))
56900d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # default arguments
569101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if(my $PurpType = $LibInfo{$Version}{"info_type"}{$PurpId})
569201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            {
56938f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if($PurpType eq "nop_expr")
56948f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                { # func ( const char* arg = (const char*)(void*)0 )
56958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $PurpId = getTreeAttr_Op($PurpId);
56968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
569701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                my $Val = getInitVal($PurpId, $ParamTypeId);
569801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                if(defined $Val) {
569901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"default"} = $Val;
570001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                }
5701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ParamListElemId = getNextElem($ParamListElemId);
57040d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        $Pos += 1;
5705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
57060d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return ($Pos>=1 and not $HaveVoid);
5707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
570962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Chan($)
571062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
571162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
571262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
571362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/chan[ ]*:[ ]*@(\d+) /) {
571462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
571562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
571662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
571762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
571862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
571962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
572062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Chain($)
572162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
572262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
572362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
572462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/chain[ ]*:[ ]*@(\d+) /) {
572562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
572662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
572762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
572862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
572962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
573062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
5731e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenkosub getTreeAttr_Unql($)
5732e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko{
5733e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5734e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    {
5735e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko        if($Info=~/unql[ ]*:[ ]*@(\d+) /) {
5736e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko            return $1;
5737e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko        }
5738e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    }
5739e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    return "";
5740e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko}
5741e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko
574262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Scpe($)
574362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
574462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
574562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
574662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/scpe[ ]*:[ ]*@(\d+) /) {
574762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
574862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
574962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
575062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
575162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
575262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
575362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Type($)
575462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
575562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
575662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
575762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/type[ ]*:[ ]*@(\d+) /) {
575862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
575962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
576062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
576162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
576262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
576362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
576462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Name($)
576562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
576662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
576762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
576862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/name[ ]*:[ ]*@(\d+) /) {
576962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
577062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
577162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
577262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
577362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
577462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
577562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Mngl($)
577662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
577762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
577862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
577962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/mngl[ ]*:[ ]*@(\d+) /) {
578062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
578162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
578262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
578362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
578462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
578562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
578662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Prms($)
578762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
578862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
578962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
579062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/prms[ ]*:[ ]*@(\d+) /) {
579162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
579262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
579362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
579462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
579562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
579662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
579762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Fncs($)
5798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5799dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5800dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
580162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/fncs[ ]*:[ ]*@(\d+) /) {
580262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
580362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
580462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
580562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
580662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
580762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
580862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Csts($)
580962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
581062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
581162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
581262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/csts[ ]*:[ ]*@(\d+) /) {
581362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
581462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
581562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
581662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
581762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
581862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
581962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Purp($)
582062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
582162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
582262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
582362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/purp[ ]*:[ ]*@(\d+) /) {
582462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
582562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
582662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
582762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
582862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
582962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
58308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub getTreeAttr_Op($)
58318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko{
58328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
58338f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
58348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Info=~/op 0[ ]*:[ ]*@(\d+) /) {
58358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return $1;
58368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
58378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
58388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return "";
58398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko}
58408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
584162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Valu($)
584262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
584362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
584462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
584562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/valu[ ]*:[ ]*@(\d+) /) {
584662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
584762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
584862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
584962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
585062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
585162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
585262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Flds($)
585362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
585462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
585562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
585662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/flds[ ]*:[ ]*@(\d+) /) {
585762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
585862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
585962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
586062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
586162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
586262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
5863177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub getTreeAttr_Binf($)
5864177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{
5865177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5866177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
5867177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($Info=~/binf[ ]*:[ ]*@(\d+) /) {
5868177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return $1;
5869177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
5870177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
5871177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    return "";
5872177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
5873177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
587462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Args($)
587562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
587662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
587762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
587862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/args[ ]*:[ ]*@(\d+) /) {
5879dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return $1;
5880dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
5883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTreeValue($)
5886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5887dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5888dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
5889dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/low[ ]*:[ ]*([^ ]+) /) {
5890dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return $1;
5891dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
5894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTreeAccess($)
5897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5898dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
5900dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/accs[ ]*:[ ]*([a-zA-Z]+) /)
5901dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
5902dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            my $Access = $1;
5903dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if($Access eq "prot") {
5904dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                return "protected";
5905dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
5906dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            elsif($Access eq "priv") {
5907dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                return "private";
5908dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
5909dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5910dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/ protected /)
5911dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        { # support for old GCC versions
5912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "protected";
5913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5914dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/ private /)
5915dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        { # support for old GCC versions
5916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "private";
5917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "public";
5920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setFuncAccess($)
5923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
59241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Access = getTreeAccess($_[0]);
5925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Access eq "protected") {
59261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$_[0]}{"Protected"} = 1;
5927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Access eq "private") {
59291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$_[0]}{"Private"} = 1;
5930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setTypeAccess($$)
5934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeId, $TypeAttr) = @_;
5936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Access = getTreeAccess($TypeId);
5937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Access eq "protected") {
5938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr->{"Protected"} = 1;
5939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Access eq "private") {
5941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr->{"Private"} = 1;
5942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setFuncKind($)
5946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5947dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5948dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
5949dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/pseudo tmpl/) {
5950dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $SymbolInfo{$Version}{$_[0]}{"PseudoTemplate"} = 1;
5951dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5952dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/ constructor /) {
5953dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $SymbolInfo{$Version}{$_[0]}{"Constructor"} = 1;
5954dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5955dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/ destructor /) {
5956dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $SymbolInfo{$Version}{$_[0]}{"Destructor"} = 1;
5957dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5961989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenkosub getVirtSpec($)
5962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5963dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5964dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
5965dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/spec[ ]*:[ ]*pure /) {
5966dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return "PureVirt";
5967dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5968dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/spec[ ]*:[ ]*virt /) {
5969dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return "Virt";
5970dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5971dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/ pure\s+virtual /)
5972dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        { # support for old GCC versions
5973dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return "PureVirt";
5974dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5975dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/ virtual /)
5976dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        { # support for old GCC versions
5977dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return "Virt";
5978dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
5981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getFuncLink($)
5984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5985dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5986dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
5987dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/link[ ]*:[ ]*static /) {
5988dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return "Static";
5989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5990dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/link[ ]*:[ ]*([a-zA-Z]+) /) {
5991dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return $1;
5992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5994dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
5995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
599774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkosub select_Symbol_NS($$)
5998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
599974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
600074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return "" if(not $Symbol or not $LibVersion);
600174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $NS = $CompleteSignature{$LibVersion}{$Symbol}{"NameSpace"};
600274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(not $NS)
600374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    {
600474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(my $Class = $CompleteSignature{$LibVersion}{$Symbol}{"Class"}) {
600574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $NS = $TypeInfo{$LibVersion}{$Class}{"NameSpace"};
600674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
6007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
600874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($NS)
6009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
601074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(defined $NestedNameSpaces{$LibVersion}{$NS}) {
601174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            return $NS;
601274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
601374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        else
6014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
601574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            while($NS=~s/::[^:]+\Z//)
601674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            {
601774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if(defined $NestedNameSpaces{$LibVersion}{$NS}) {
601874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    return $NS;
601974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
6020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
602374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
602474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return "";
6025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
602774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkosub select_Type_NS($$)
6028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeName, $LibVersion) = @_;
6030ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $TypeName or not $LibVersion);
603174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(my $NS = $TypeInfo{$LibVersion}{$TName_Tid{$LibVersion}{$TypeName}}{"NameSpace"})
6032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
603374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(defined $NestedNameSpaces{$LibVersion}{$NS}) {
603474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            return $NS;
603574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
603674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        else
6037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
603874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            while($NS=~s/::[^:]+\Z//)
603974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            {
604074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if(defined $NestedNameSpaces{$LibVersion}{$NS}) {
604174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    return $NS;
604274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
6043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6044ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
604674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return "";
6047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getNameSpace($)
6050ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
605174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $InfoId = $_[0];
605274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(my $NSInfoId = getTreeAttr_Scpe($InfoId))
6053ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
605462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $InfoType = $LibInfo{$Version}{"info_type"}{$NSInfoId})
6055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
605662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($InfoType eq "namespace_decl")
6057dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
605862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($LibInfo{$Version}{"info"}{$NSInfoId}=~/name[ ]*:[ ]*@(\d+) /)
605962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
606062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $NameSpace = getTreeStr($1);
606162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($NameSpace eq "::")
606262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    { # global namespace
606362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        return "";
606462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
606562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if(my $BaseNameSpace = getNameSpace($NSInfoId)) {
606662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $NameSpace = $BaseNameSpace."::".$NameSpace;
606762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
606862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $NestedNameSpaces{$Version}{$NameSpace} = 1;
606962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    return $NameSpace;
607062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
607162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                else {
607262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    return "";
6073dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                }
6074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6075177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            elsif($InfoType ne "function_decl")
607662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            { # inside data type
607762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my ($Name, $NameNS) = getTrivialName(getTypeDeclId($NSInfoId), $NSInfoId);
607862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return $Name;
607962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
6080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6082dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
6083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getEnumMembVal($)
6086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6087dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
6088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6089dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/valu[ ]*:[ ]*\@(\d+)/)
6090dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
6091dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(my $VInfo = $LibInfo{$Version}{"info"}{$1})
6092dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
6093dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if($VInfo=~/cnst[ ]*:[ ]*\@(\d+)/)
6094dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                { # in newer versions of GCC the value is in the "const_decl->cnst" node
6095dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    return getTreeValue($1);
6096dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                }
6097dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                else
6098dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                { # some old versions of GCC (3.3) have the value in the "integer_cst" node
6099dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    return getTreeValue($1);
6100dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                }
6101dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
6102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
6105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getSize($)
6108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6109dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
6110dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
6111dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/size[ ]*:[ ]*\@(\d+)/) {
6112dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return getTreeValue($1);
6113dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
6114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6115dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return 0;
6116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getAlgn($)
6119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6120dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
6121dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
6122dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/algn[ ]*:[ ]*(\d+) /) {
6123dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return $1;
6124dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
6125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6126dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
6127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6129f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenkosub getBitField($)
6130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6131dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
6132dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
6133dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/ bitfield /) {
6134dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return getSize($_[0]);
6135dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
6136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6137dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return 0;
6138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
614062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getNextElem($)
6141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
614262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $Chan = getTreeAttr_Chan($_[0])) {
614362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Chan;
6144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
614562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif(my $Chain = getTreeAttr_Chain($_[0])) {
614662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Chain;
6147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6148dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
6149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
615162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub registerHeader($$)
615262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{ # input: absolute path of header, relative path or name
6153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $LibVersion) = @_;
615462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not $Header) {
615562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return "";
6156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
615762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(is_abs($Header) and not -f $Header)
615862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # incorrect absolute path
615962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        exitStatus("Access_Error", "can't access \'$Header\'");
6160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
616162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(skipHeader($Header, $LibVersion))
616262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # skip
6163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
6164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
616562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $Header_Path = identifyHeader($Header, $LibVersion))
616662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
616762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        detect_header_includes($Header_Path, $LibVersion);
616862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
61698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(defined $Tolerance and $Tolerance=~/3/)
61708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # 3 - skip headers that include non-Linux headers
61718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($OSgroup ne "windows")
61728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
61738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                foreach my $Inc (keys(%{$Header_Includes{$LibVersion}{$Header_Path}}))
61748f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                {
61758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    if(specificHeader($Inc, "windows")) {
61768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        return "";
61778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    }
61788f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
61798f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
61808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
61818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
618262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $RHeader_Path = $Header_ErrorRedirect{$LibVersion}{$Header_Path})
618362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # redirect
618462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($Registered_Headers{$LibVersion}{$RHeader_Path}{"Identity"}
618562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            or skipHeader($RHeader_Path, $LibVersion))
618662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            { # skip
618762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return "";
618862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
618962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $Header_Path = $RHeader_Path;
619062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
619162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        elsif($Header_ShouldNotBeUsed{$LibVersion}{$Header_Path})
619262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # skip
619362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return "";
619462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
619562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
619662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $HName = get_filename($Header_Path))
619762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # register
619862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $Registered_Headers{$LibVersion}{$Header_Path}{"Identity"} = $HName;
619962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $HeaderName_Paths{$LibVersion}{$HName}{$Header_Path} = 1;
620062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
620162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
620262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(($Header=~/\.(\w+)\Z/ and $1 ne "h")
620362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        or $Header!~/\.(\w+)\Z/)
62048f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # hpp, hh, etc.
620562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            setLanguage($LibVersion, "C++");
62068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $CPP_HEADERS = 1;
620762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
620862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
620962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($CheckHeadersOnly
621062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        and $Header=~/(\A|\/)c\+\+(\/|\Z)/)
621162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # /usr/include/c++/4.6.1/...
621262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $STDCXX_TESTING = 1;
621362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
621462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
621562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Header_Path;
6216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
621762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
6218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
62208f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub registerDir($$$)
6221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Dir, $WithDeps, $LibVersion) = @_;
6223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Dir=~s/[\/\\]+\Z//g;
6224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(not $LibVersion or not $Dir or not -d $Dir);
6225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Dir = get_abs_path($Dir);
6226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Mode = "All";
6227850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($WithDeps)
6228850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
6229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($RegisteredDirs{$LibVersion}{$Dir}{1}) {
6230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return;
6231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($RegisteredDirs{$LibVersion}{$Dir}{0}) {
6233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mode = "DepsOnly";
6234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6236850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    else
6237850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
6238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($RegisteredDirs{$LibVersion}{$Dir}{1}
6239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        or $RegisteredDirs{$LibVersion}{$Dir}{0}) {
6240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return;
6241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Header_Dependency{$LibVersion}{$Dir} = 1;
6244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $RegisteredDirs{$LibVersion}{$Dir}{$WithDeps} = 1;
6245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Mode eq "DepsOnly")
6246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6247570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        foreach my $Path (cmd_find($Dir,"d")) {
6248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Header_Dependency{$LibVersion}{$Path} = 1;
6249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
6251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6252570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Path (sort {length($b)<=>length($a)} cmd_find($Dir,"f"))
6253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($WithDeps)
6255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $SubDir = $Path;
6257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            while(($SubDir = get_dirname($SubDir)) ne $Dir)
6258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # register all sub directories
6259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Header_Dependency{$LibVersion}{$SubDir} = 1;
6260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(is_not_header($Path));
6263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(ignore_path($Path));
6264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # Neighbors
62659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        foreach my $Part (get_prefixes($Path)) {
6266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Include_Neighbors{$LibVersion}{$Part} = $Path;
6267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(get_filename($Dir) eq "include")
6270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search for "lib/include/" directory
6271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $LibDir = $Dir;
6272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LibDir=~s/([\/\\])include\Z/$1lib/g and -d $LibDir) {
62738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            registerDir($LibDir, $WithDeps, $LibVersion);
6274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub parse_redirect($$$)
6279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Content, $Path, $LibVersion) = @_;
6281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Errors = ();
6282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($Content=~s/#\s*error\s+([^\n]+?)\s*(\n|\Z)//) {
6283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        push(@Errors, $1);
6284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Redirect = "";
6286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (@Errors)
6287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        s/\s{2,}/ /g;
6289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(/(only|must\ include
6290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        |update\ to\ include
6291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        |replaced\ with
6292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        |replaced\ by|renamed\ to
62939927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        |\ is\ in|\ use)\ (<[^<>]+>|[\w\-\/\\]+\.($HEADER_EXT))/ix)
6294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Redirect = $2;
6296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            last;
6297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(/(include|use|is\ in)\ (<[^<>]+>|[\w\-\/\\]+\.($HEADER_EXT))\ instead/i)
6299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Redirect = $2;
6301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            last;
6302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(/this\ header\ should\ not\ be\ used
6304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         |programs\ should\ not\ directly\ include
6305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         |you\ should\ not\ (include|be\ (including|using)\ this\ (file|header))
6306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         |is\ not\ supported\ API\ for\ general\ use
6307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         |do\ not\ use
63089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko         |should\ not\ be\ (used|using)
6309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         |cannot\ be\ included\ directly/ix and not /\ from\ /i) {
6310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Header_ShouldNotBeUsed{$LibVersion}{$Path} = 1;
6311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6313850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($Redirect)
6314850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
6315850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $Redirect=~s/\A<//g;
6316850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $Redirect=~s/>\Z//g;
6317850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
6318850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return $Redirect;
6319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub parse_includes($$)
6322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Content, $Path) = @_;
6324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %Includes = ();
632574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    while($Content=~s/^[ \t]*#[ \t]*(include|include_next|import)[ \t]*([<"].+?[">])[ \t]*//m)
6326850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    { # C/C++: include, Objective C/C++: import directive
63274b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        my $Header = $2;
632874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my $Method = substr($Header, 0, 1, "");
632974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        substr($Header, length($Header)-1, 1, "");
633074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $Header = path_format($Header, $OSgroup);
633174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if($Method eq "\"" or is_abs($Header))
633274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        {
633374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(-e join_P(get_dirname($Path), $Header))
633474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            { # relative path exists
633574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $Includes{$Header} = -1;
6336850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
633774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            else
633874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            { # include "..." that doesn't exist is equal to include <...>
633974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $Includes{$Header} = 2;
6340850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
6341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
634274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        else {
634374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $Includes{$Header} = 1;
634474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
634574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
634674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraInfo)
634774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    {
634874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        while($Content=~s/^[ \t]*#[ \t]*(include|include_next|import)[ \t]+(\w+)[ \t]*//m)
634974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        { # FT_FREETYPE_H
635074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $Includes{$2} = 0;
6351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return \%Includes;
6354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub ignore_path($)
6357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
6359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Path=~/\~\Z/)
6360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {# skipping system backup files
6361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Path=~/(\A|[\/\\]+)(\.(svn|git|bzr|hg)|CVS)([\/\\]+|\Z)/)
6364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {# skipping hidden .svn, .git, .bzr, .hg and CVS directories
6365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
6368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
63709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub sortByWord($$)
6371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ArrRef, $W) = @_;
6373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(length($W)<2);
6374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    @{$ArrRef} = sort {get_filename($b)=~/\Q$W\E/i<=>get_filename($a)=~/\Q$W\E/i} @{$ArrRef};
6375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
63779927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub sortHeaders($$)
6378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($H1, $H2) = @_;
63808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
6381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $H1=~s/\.[a-z]+\Z//ig;
6382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $H2=~s/\.[a-z]+\Z//ig;
63838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
63848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Hname1 = get_filename($H1);
63858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Hname2 = get_filename($H2);
63868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $HDir1 = get_dirname($H1);
63878f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $HDir2 = get_dirname($H2);
6388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Dirname1 = get_filename($HDir1);
6389ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Dirname2 = get_filename($HDir2);
63908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
63918f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $HDir1=~s/\A.*[\/\\]+([^\/\\]+[\/\\]+[^\/\\]+)\Z/$1/;
63928f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $HDir2=~s/\A.*[\/\\]+([^\/\\]+[\/\\]+[^\/\\]+)\Z/$1/;
63938f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
63949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($_[0] eq $_[1]
63959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    or $H1 eq $H2) {
6396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
6397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($H1=~/\A\Q$H2\E/) {
6399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($H2=~/\A\Q$H1\E/) {
6402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return -1;
6403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($HDir1=~/\Q$Hname1\E/i
6405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $HDir2!~/\Q$Hname2\E/i)
64069927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # include/glib-2.0/glib.h
6407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return -1;
6408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($HDir2=~/\Q$Hname2\E/i
6410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $HDir1!~/\Q$Hname1\E/i)
64119927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # include/glib-2.0/glib.h
6412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Hname1=~/\Q$Dirname1\E/i
6415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Hname2!~/\Q$Dirname2\E/i)
64169927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # include/hildon-thumbnail/hildon-thumbnail-factory.h
6417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return -1;
6418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Hname2=~/\Q$Dirname2\E/i
6420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Hname1!~/\Q$Dirname1\E/i)
64219927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # include/hildon-thumbnail/hildon-thumbnail-factory.h
6422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
64249927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    elsif($Hname1=~/(config|lib|util)/i
64259927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    and $Hname2!~/(config|lib|util)/i)
64269927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # include/alsa/asoundlib.h
6427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return -1;
6428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
64299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    elsif($Hname2=~/(config|lib|util)/i
64309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    and $Hname1!~/(config|lib|util)/i)
64319927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # include/alsa/asoundlib.h
6432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
64349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    else
64359927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
64368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $R1 = checkRelevance($H1);
64378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $R2 = checkRelevance($H2);
64388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($R1 and not $R2)
64398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # libebook/e-book.h
64408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return -1;
64418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
64428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        elsif($R2 and not $R1)
64438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # libebook/e-book.h
64448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1;
64458f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
64468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        else
64478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
64488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return (lc($H1) cmp lc($H2));
64498f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
6450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub searchForHeaders($)
6454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
6456570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
6457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # gcc standard include paths
6458570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    registerGccHeaders();
6459570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
6460570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($COMMON_LANGUAGE{$LibVersion} eq "C++" and not $STDCXX_TESTING)
6461570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # c++ standard include paths
6462570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        registerCppHeaders();
6463570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
6464570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
6465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # processing header paths
6466570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Path (@{$Descriptor{$LibVersion}{"IncludePaths"}},
6467570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    @{$Descriptor{$LibVersion}{"AddIncludePaths"}})
6468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $IPath = $Path;
6470a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if($SystemRoot)
6471a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        {
6472a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            if(is_abs($Path)) {
6473a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                $Path = $SystemRoot.$Path;
6474a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            }
6475a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        }
6476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -e $Path) {
6477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access \'$Path\'");
6478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(-f $Path) {
6480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "\'$Path\' - not a directory");
6481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(-d $Path)
6483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Path = get_abs_path($Path);
64858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            registerDir($Path, 0, $LibVersion);
6486570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(grep {$IPath eq $_} @{$Descriptor{$LibVersion}{"AddIncludePaths"}}) {
6487570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push(@{$Add_Include_Paths{$LibVersion}}, $Path);
6488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6489ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
6490570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push(@{$Include_Paths{$LibVersion}}, $Path);
6491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6494570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(@{$Include_Paths{$LibVersion}}) {
6495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $INC_PATH_AUTODETECT{$LibVersion} = 0;
6496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6497570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
6498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # registering directories
6499ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, $Descriptor{$LibVersion}{"Headers"}))
6500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not -e $Path);
6502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = get_abs_path($Path);
6503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = path_format($Path, $OSgroup);
6504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-d $Path) {
65058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            registerDir($Path, 1, $LibVersion);
6506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(-f $Path)
6508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Dir = get_dirname($Path);
6510570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(not grep { $Dir eq $_ } (@{$SystemPaths{"include"}})
6511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and not $LocalIncludes{$Dir})
6512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
65138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                registerDir($Dir, 1, $LibVersion);
6514fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                # if(my $OutDir = get_dirname($Dir))
6515fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                # { # registering the outer directory
6516fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                #     if(not grep { $OutDir eq $_ } (@{$SystemPaths{"include"}})
6517fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                #     and not $LocalIncludes{$OutDir}) {
6518fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                #         registerDir($OutDir, 0, $LibVersion);
6519fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                #     }
6520fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                # }
6521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6524850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
6525850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
6526850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %RegisteredDirs = ();
6527850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
6528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # registering headers
6529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Position = 0;
6530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Dest (split(/\s*\n\s*/, $Descriptor{$LibVersion}{"Headers"}))
6531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(is_abs($Dest) and not -e $Dest) {
6533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access \'$Dest\'");
6534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Dest = path_format($Dest, $OSgroup);
6536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(is_header($Dest, 1, $LibVersion))
6537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
653862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $HPath = registerHeader($Dest, $LibVersion)) {
6539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Registered_Headers{$LibVersion}{$HPath}{"Pos"} = $Position++;
6540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(-d $Dest)
6543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my @Registered = ();
6545570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            foreach my $Path (cmd_find($Dest,"f"))
6546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
6547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next if(ignore_path($Path));
6548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next if(not is_header($Path, 0, $LibVersion));
654962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(my $HPath = registerHeader($Path, $LibVersion)) {
6550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    push(@Registered, $HPath);
6551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
6552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
65539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            @Registered = sort {sortHeaders($a, $b)} @Registered;
65549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            sortByWord(\@Registered, $TargetLibraryShortName);
6555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Path (@Registered) {
6556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Registered_Headers{$LibVersion}{$Path}{"Pos"} = $Position++;
6557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
6560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't identify \'$Dest\' as a header file");
6561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
65638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
65648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(defined $Tolerance and $Tolerance=~/4/)
65658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # 4 - skip headers included by others
65668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        foreach my $Path (keys(%{$Registered_Headers{$LibVersion}}))
65678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
6568fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(defined $Header_Includes_R{$LibVersion}{$Path}) {
65698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                delete($Registered_Headers{$LibVersion}{$Path});
65708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
65718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
65728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
65738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
6574dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if(my $HList = $Descriptor{$LibVersion}{"IncludePreamble"})
6575dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    { # preparing preamble headers
6576dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        foreach my $Header (split(/\s*\n\s*/, $HList))
6577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6578dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(is_abs($Header) and not -f $Header) {
6579dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                exitStatus("Access_Error", "can't access file \'$Header\'");
6580dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
6581dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $Header = path_format($Header, $OSgroup);
6582dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(my $Header_Path = is_header($Header, 1, $LibVersion))
6583dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
658462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                next if(skipHeader($Header_Path, $LibVersion));
6585570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push_U($Include_Preamble{$LibVersion}, $Header_Path);
6586dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
6587dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            else {
6588dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                exitStatus("Access_Error", "can't identify \'$Header\' as a header file");
6589dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
6590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Header_Name (keys(%{$HeaderName_Paths{$LibVersion}}))
6593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # set relative paths (for duplicates)
6594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(keys(%{$HeaderName_Paths{$LibVersion}{$Header_Name}})>=2)
6595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # search for duplicates
6596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $FirstPath = (keys(%{$HeaderName_Paths{$LibVersion}{$Header_Name}}))[0];
6597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Prefix = get_dirname($FirstPath);
6598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            while($Prefix=~/\A(.+)[\/\\]+[^\/\\]+\Z/)
6599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # detect a shortest distinguishing prefix
6600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $NewPrefix = $1;
6601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my %Identity = ();
6602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Path (keys(%{$HeaderName_Paths{$LibVersion}{$Header_Name}}))
6603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
6604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($Path=~/\A\Q$Prefix\E[\/\\]+(.*)\Z/) {
6605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $Identity{$Path} = $1;
6606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
6607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
6608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(keys(%Identity)==keys(%{$HeaderName_Paths{$LibVersion}{$Header_Name}}))
6609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # all names are differend with current prefix
6610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    foreach my $Path (keys(%{$HeaderName_Paths{$LibVersion}{$Header_Name}})) {
6611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $Registered_Headers{$LibVersion}{$Path}{"Identity"} = $Identity{$Path};
6612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
6613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    last;
6614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
6615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Prefix = $NewPrefix; # increase prefix
6616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6619850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
6620850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
6621850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %HeaderName_Paths = ();
6622850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
6623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $HeaderName (keys(%{$Include_Order{$LibVersion}}))
6624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # ordering headers according to descriptor
66258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $PairName = $Include_Order{$LibVersion}{$HeaderName};
6626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($Pos, $PairPos) = (-1, -1);
6627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($Path, $PairPath) = ();
6628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Paths = keys(%{$Registered_Headers{$LibVersion}});
6629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        @Paths = sort {int($Registered_Headers{$LibVersion}{$a}{"Pos"})<=>int($Registered_Headers{$LibVersion}{$b}{"Pos"})} @Paths;
6630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Header_Path (@Paths)
6631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(get_filename($Header_Path) eq $PairName)
6633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
6634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $PairPos = $Registered_Headers{$LibVersion}{$Header_Path}{"Pos"};
6635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $PairPath = $Header_Path;
6636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(get_filename($Header_Path) eq $HeaderName)
6638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
6639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Pos = $Registered_Headers{$LibVersion}{$Header_Path}{"Pos"};
6640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Path = $Header_Path;
6641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($PairPos!=-1 and $Pos!=-1
6644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and int($PairPos)<int($Pos))
6645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my %Tmp = %{$Registered_Headers{$LibVersion}{$Path}};
6647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            %{$Registered_Headers{$LibVersion}{$Path}} = %{$Registered_Headers{$LibVersion}{$PairPath}};
6648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            %{$Registered_Headers{$LibVersion}{$PairPath}} = %Tmp;
6649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not keys(%{$Registered_Headers{$LibVersion}})) {
6652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Error", "header files are not found in the ".$Descriptor{$LibVersion}{"Version"});
6653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_real_includes($$)
6657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($AbsPath, $LibVersion) = @_;
6659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $LibVersion or not $AbsPath or not -e $AbsPath);
6660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Cache{"detect_real_includes"}{$LibVersion}{$AbsPath}
6661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}})) {
6662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}});
6663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6664850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    $Cache{"detect_real_includes"}{$LibVersion}{$AbsPath}=1;
6665850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
6666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = callPreprocessor($AbsPath, "", $LibVersion);
6667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $Path);
6668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    open(PREPROC, $Path);
6669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while(<PREPROC>)
6670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(/#\s+\d+\s+"([^"]+)"[\s\d]*\n/)
6672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Include = path_format($1, $OSgroup);
6674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Include=~/\<(built\-in|internal|command(\-|\s)line)\>|\A\./) {
6675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
6676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Include eq $AbsPath) {
6678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
6679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $RecursiveIncludes{$LibVersion}{$AbsPath}{$Include} = 1;
6681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    close(PREPROC);
6684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}});
6685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_header_includes($$)
6688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $LibVersion) = @_;
6690850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return if(not $LibVersion or not $Path);
6691850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(defined $Cache{"detect_header_includes"}{$LibVersion}{$Path}) {
6692850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return;
6693850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
6694850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    $Cache{"detect_header_includes"}{$LibVersion}{$Path}=1;
6695850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
6696850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(not -e $Path) {
6697850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return;
6698850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
6699850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
6700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Content = readFile($Path);
6701850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(my $Redirect = parse_redirect($Content, $Path, $LibVersion))
6702850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    { # detect error directive in headers
670362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $RedirectPath = identifyHeader($Redirect, $LibVersion))
6704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($RedirectPath=~/\/usr\/include\// and $Path!~/\/usr\/include\//) {
670662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $RedirectPath = identifyHeader(get_filename($Redirect), $LibVersion);
6707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($RedirectPath ne $Path) {
6709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Header_ErrorRedirect{$LibVersion}{$Path} = $RedirectPath;
6710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
67129927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        else
67139927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # can't find
67149927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $Header_ShouldNotBeUsed{$LibVersion}{$Path} = 1;
67159927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
6716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6717850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(my $Inc = parse_includes($Content, $Path))
6718850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
6719850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        foreach my $Include (keys(%{$Inc}))
6720850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # detect includes
6721850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            $Header_Includes{$LibVersion}{$Path}{$Include} = $Inc->{$Include};
67228f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
67238f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(defined $Tolerance and $Tolerance=~/4/)
67248f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
67258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if(my $HPath = identifyHeader($Include, $LibVersion))
67268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                {
67278f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $Header_Includes_R{$LibVersion}{$HPath}{$Path} = 1;
67288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
67298f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
6730850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
6731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub fromLibc($)
673574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko{ # system GLIBC header
6736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
6737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Dir, $Name) = separate_path($Path);
6738fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($OStarget eq "symbian")
6739fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
6740fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(get_filename($Dir) eq "libc" and $GlibcHeader{$Name})
6741fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # epoc32/include/libc/{stdio, ...}.h
6742fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            return 1;
6743fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
6744fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
6745fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    else
6746fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
6747fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Dir eq "/usr/include" and $GlibcHeader{$Name})
6748fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # /usr/include/{stdio, ...}.h
6749fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            return 1;
6750fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
6751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
6753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isLibcDir($)
675674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko{ # system GLIBC directory
6757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Dir = $_[0];
6758ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($OutDir, $Name) = separate_path($Dir);
6759fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($OStarget eq "symbian")
6760fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
6761fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(get_filename($OutDir) eq "libc"
6762fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        and ($Name=~/\Aasm(|-.+)\Z/ or $GlibcDir{$Name}))
6763fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # epoc32/include/libc/{sys,bits,asm,asm-*}/*.h
6764fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            return 1;
6765fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
6766fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
6767fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    else
6768fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # linux
6769fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($OutDir eq "/usr/include"
6770fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        and ($Name=~/\Aasm(|-.+)\Z/ or $GlibcDir{$Name}))
6771fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # /usr/include/{sys,bits,asm,asm-*}/*.h
6772fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            return 1;
6773fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
6774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
6776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_recursive_includes($$)
6779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($AbsPath, $LibVersion) = @_;
6781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $AbsPath);
6782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(isCyclical(\@RecurInclude, $AbsPath)) {
6783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}});
6784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($AbsDir, $Name) = separate_path($AbsPath);
6786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(isLibcDir($AbsDir))
678774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    { # system GLIBC internals
678874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        return () if(not $ExtraInfo);
6789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}})) {
6791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}});
6792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if($OSgroup ne "windows" and $Name=~/windows|win32|win64/i);
6794570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
6795570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($MAIN_CPP_DIR and $AbsPath=~/\A\Q$MAIN_CPP_DIR\E/ and not $STDCXX_TESTING)
6796570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # skip /usr/include/c++/*/ headers
6797570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return () if(not $ExtraInfo);
6798570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
6799570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
6800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    push(@RecurInclude, $AbsPath);
6801570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(grep { $AbsDir eq $_ } @DefaultGccPaths
680274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    or (grep { $AbsDir eq $_ } @DefaultIncPaths and fromLibc($AbsPath)))
6803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # check "real" (non-"model") include paths
6804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Paths = detect_real_includes($AbsPath, $LibVersion);
6805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        pop(@RecurInclude);
6806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return @Paths;
6807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not keys(%{$Header_Includes{$LibVersion}{$AbsPath}})) {
6809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        detect_header_includes($AbsPath, $LibVersion);
6810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Include (keys(%{$Header_Includes{$LibVersion}{$AbsPath}}))
6812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6813850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $IncType = $Header_Includes{$LibVersion}{$AbsPath}{$Include};
6814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $HPath = "";
6815850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($IncType<0)
6816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # for #include "..."
681774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $Candidate = join_P($AbsDir, $Include);
6818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(-f $Candidate) {
681974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $HPath = realpath($Candidate);
6820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6822850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        elsif($IncType>0
68231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        and $Include=~/[\/\\]/) # and not find_in_defaults($Include)
6824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # search for the nearest header
6825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # QtCore/qabstractanimation.h includes <QtCore/qobject.h>
682674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $Candidate = join_P(get_dirname($AbsDir), $Include);
6827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(-f $Candidate) {
6828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $HPath = $Candidate;
6829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $HPath) {
683262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $HPath = identifyHeader($Include, $LibVersion);
6833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $HPath);
6835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($HPath eq $AbsPath) {
6836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
6837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
68389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
68399927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($Debug)
68409927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # boundary headers
684174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko#             if($HPath=~/vtk/ and $AbsPath!~/vtk/)
684274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko#             {
684374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko#                 print STDERR "$AbsPath -> $HPath\n";
684474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko#             }
68459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
68469927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
6847850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $RecursiveIncludes{$LibVersion}{$AbsPath}{$HPath} = $IncType;
6848850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($IncType>0)
6849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # only include <...>, skip include "..." prefixes
6850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Header_Include_Prefix{$LibVersion}{$AbsPath}{$HPath}{get_dirname($Include)} = 1;
6851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $IncPath (detect_recursive_includes($HPath, $LibVersion))
6853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($IncPath eq $AbsPath) {
6855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
6856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6857850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            my $RIncType = $RecursiveIncludes{$LibVersion}{$HPath}{$IncPath};
6858850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($RIncType==-1)
6859850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # include "..."
6860850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $RIncType = $IncType;
6861850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
6862850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            elsif($RIncType==2)
6863850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
6864850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($IncType!=-1) {
6865850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    $RIncType = $IncType;
6866850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
6867850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
6868850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            $RecursiveIncludes{$LibVersion}{$AbsPath}{$IncPath} = $RIncType;
6869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Prefix (keys(%{$Header_Include_Prefix{$LibVersion}{$HPath}{$IncPath}})) {
6870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Header_Include_Prefix{$LibVersion}{$AbsPath}{$IncPath}{$Prefix} = 1;
6871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Dep (keys(%{$Header_Include_Prefix{$LibVersion}{$AbsPath}}))
6874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($GlibcHeader{get_filename($Dep)} and keys(%{$Header_Include_Prefix{$LibVersion}{$AbsPath}{$Dep}})>=2
6876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and defined $Header_Include_Prefix{$LibVersion}{$AbsPath}{$Dep}{""})
6877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # distinguish math.h from glibc and math.h from the tested library
6878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                delete($Header_Include_Prefix{$LibVersion}{$AbsPath}{$Dep}{""});
6879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                last;
6880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    pop(@RecurInclude);
6884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}});
6885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub find_in_framework($$$)
6888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $Framework, $LibVersion) = @_;
6890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Header or not $Framework or not $LibVersion);
6891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Cache{"find_in_framework"}{$LibVersion}{$Framework}{$Header}) {
6892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"find_in_framework"}{$LibVersion}{$Framework}{$Header};
6893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Dependency (sort {get_depth($a)<=>get_depth($b)} keys(%{$Header_Dependency{$LibVersion}}))
6895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(get_filename($Dependency) eq $Framework
6897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and -f get_dirname($Dependency)."/".$Header) {
6898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return ($Cache{"find_in_framework"}{$LibVersion}{$Framework}{$Header} = get_dirname($Dependency));
6899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"find_in_framework"}{$LibVersion}{$Framework}{$Header} = "");
6902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub find_in_defaults($)
6905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Header = $_[0];
6907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Header);
6908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Cache{"find_in_defaults"}{$Header}) {
6909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"find_in_defaults"}{$Header};
6910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6911570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Dir (@DefaultIncPaths,
6912570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                     @DefaultGccPaths,
6913570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                     @DefaultCppPaths,
6914570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                     @UsersIncPath)
6915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Dir);
6917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-f $Dir."/".$Header) {
6918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return ($Cache{"find_in_defaults"}{$Header}=$Dir);
6919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"find_in_defaults"}{$Header}="");
6922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub cmp_paths($$)
6925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path1, $Path2) = @_;
6927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Parts1 = split(/[\/\\]/, $Path1);
6928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Parts2 = split(/[\/\\]/, $Path2);
6929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Num (0 .. $#Parts1)
6930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Part1 = $Parts1[$Num];
6932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Part2 = $Parts2[$Num];
6933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($GlibcDir{$Part1}
6934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and not $GlibcDir{$Part2}) {
6935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
6936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($GlibcDir{$Part2}
6938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and not $GlibcDir{$Part1}) {
6939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return -1;
6940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Part1=~/glib/
6942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Part2!~/glib/) {
6943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
6944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Part1!~/glib/
6946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Part2=~/glib/) {
6947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return -1;
6948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(my $CmpRes = ($Part1 cmp $Part2)) {
6950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $CmpRes;
6951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
6954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub checkRelevance($)
6957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
69588f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Path = $_[0];
6959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not $Path);
69608f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
6961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SystemRoot) {
6962a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        $Path = cut_path_prefix($Path, $SystemRoot);
6963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
69648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
69658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Name = lc(get_filename($Path));
69668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Dir = lc(get_dirname($Path));
69678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
6968a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    $Name=~s/\.\w+\Z//g; # remove extension (.h)
69698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
69708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $Token (split(/[_\d\W]+/, $Name))
6971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
69728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $Len = length($Token);
69738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        next if($Len<=1);
69748f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Dir=~/(\A|lib|[_\d\W])\Q$Token\E([_\d\W]|lib|\Z)/)
69758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # include/evolution-data-server-1.4/libebook/e-book.h
69768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1;
69778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
69788f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Len>=4 and index($Dir, $Token)!=-1)
6979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # include/gupnp-1.0/libgupnp/gupnp-context.h
6980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
6981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
6984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub checkFamily(@)
6987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Paths = @_;
6989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1 if($#Paths<=0);
6990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %Prefix = ();
6991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (@Paths)
6992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SystemRoot) {
6994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Path = cut_path_prefix($Path, $SystemRoot);
6995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $Dir = get_dirname($Path))
6997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Dir=~s/(\/[^\/]+?)[\d\.\-\_]+\Z/$1/g; # remove version suffix
6999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Prefix{$Dir} += 1;
7000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Prefix{get_dirname($Dir)} += 1;
7001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7002ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (sort keys(%Prefix))
7004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(get_depth($_)>=3
7006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Prefix{$_}==$#Paths+1) {
7007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
7008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7010ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
7011ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isAcceptable($$$)
7014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $Candidate, $LibVersion) = @_;
7016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $HName = get_filename($Header);
7017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(get_dirname($Header))
7018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # with prefix
7019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
7020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($HName=~/config|setup/i and $Candidate=~/[\/\\]lib\d*[\/\\]/)
7022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # allow to search for glibconfig.h in /usr/lib/glib-2.0/include/
7023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
7024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(checkRelevance($Candidate))
7026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # allow to search for atk.h in /usr/include/atk-1.0/atk/
7027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
7028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(checkFamily(getSystemHeaders($HName, $LibVersion)))
7030ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # /usr/include/qt4/QtNetwork/qsslconfiguration.h
7031ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # /usr/include/qt4/Qt/qsslconfiguration.h
7032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
7033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7034ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OStarget eq "symbian")
7035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7036ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Candidate=~/[\/\\]stdapis[\/\\]/) {
7037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
7038ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
7041ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isRelevant($$$)
7044ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # disallow to search for "abstract" headers in too deep directories
7045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $Candidate, $LibVersion) = @_;
7046ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $HName = get_filename($Header);
7047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OStarget eq "symbian")
7048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Candidate=~/[\/\\](tools|stlportv5)[\/\\]/) {
7050ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
7051ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
70539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($OStarget ne "bsd")
70549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
7055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Candidate=~/[\/\\]include[\/\\]bsd[\/\\]/)
7056ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # openssh: skip /usr/lib/bcc/include/bsd/signal.h
7057ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
7058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
70609927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($OStarget ne "windows")
70619927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
70629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($Candidate=~/[\/\\](wine|msvcrt|windows)[\/\\]/)
70639927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # skip /usr/include/wine/msvcrt
70649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            return 0;
70659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
70669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
7067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not get_dirname($Header)
7068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Candidate=~/[\/\\]wx[\/\\]/)
7069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # do NOT search in system /wx/ directory
7070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # for headers without a prefix: sstream.h
7071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
7072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Candidate=~/c\+\+[\/\\]\d+/ and $MAIN_CPP_DIR
7074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Candidate!~/\A\Q$MAIN_CPP_DIR\E/)
7075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # skip ../c++/3.3.3/ if using ../c++/4.5/
7076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
7077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7078ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Candidate=~/[\/\\]asm-/
7079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and (my $Arch = getArch($LibVersion)) ne "unknown")
7080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # arch-specific header files
7081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Candidate!~/[\/\\]asm-\Q$Arch\E/)
7082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {# skip ../asm-arm/ if using x86 architecture
7083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
7084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Candidates = getSystemHeaders($HName, $LibVersion);
7087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($#Candidates==1)
7088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # unique header
7089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
7090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @SCandidates = getSystemHeaders($Header, $LibVersion);
7092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($#SCandidates==1)
7093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # unique name
7094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
7095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $SystemDepth = $SystemRoot?get_depth($SystemRoot):0;
7097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(get_depth($Candidate)-$SystemDepth>=5)
7098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # abstract headers in too deep directories
7099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # sstream.h or typeinfo.h in /usr/include/wx-2.9/wx/
7100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not isAcceptable($Header, $Candidate, $LibVersion)) {
7101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
7102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Header eq "parser.h"
7105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Candidate!~/\/libxml2\//)
7106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # select parser.h from xml2 library
7107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
7108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not get_dirname($Header)
7110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and keys(%{$SystemHeaders{$HName}})>=3)
7111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # many headers with the same name
7112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # like thread.h included without a prefix
7113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not checkFamily(@Candidates)) {
7114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
7115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1;
7118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub selectSystemHeader($$)
712162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{ # cache function
712262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"selectSystemHeader"}{$_[1]}{$_[0]}) {
712362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"selectSystemHeader"}{$_[1]}{$_[0]};
712462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
712562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return ($Cache{"selectSystemHeader"}{$_[1]}{$_[0]} = selectSystemHeader_I(@_));
712662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
712762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
712862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub selectSystemHeader_I($$)
7129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $LibVersion) = @_;
713162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(-f $Header) {
713262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Header;
713362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
713462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(is_abs($Header) and not -f $Header)
713562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # incorrect absolute path
713662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return "";
713762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
71389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(defined $ConfHeaders{lc($Header)})
713962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # too abstract configuration headers
714062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return "";
714162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
71429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my $HName = get_filename($Header);
7143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup ne "windows")
7144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
71459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(defined $WinHeaders{lc($HName)}
71469927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        or $HName=~/windows|win32|win64/i)
714762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # windows headers
7148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "";
7149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
71509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
71519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($OSgroup ne "macos")
71529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
71539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($HName eq "fp.h")
715474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        { # pngconf.h includes fp.h in Mac OS
7155ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "";
7156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
715874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
715974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(defined $ObsoleteHeaders{$HName})
716074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    { # obsolete headers
716174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        return "";
7162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
716374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($OSgroup eq "linux" or $OSgroup eq "bsd")
716407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    {
716574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(defined $AlienHeaders{$HName}
716674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        or defined $AlienHeaders{$Header})
716774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        { # alien headers from other systems
716807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            return "";
716907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        }
717007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    }
717162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
7172570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Path (@{$SystemPaths{"include"}})
7173ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search in default paths
7174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-f $Path."/".$Header) {
717574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            return join_P($Path,$Header);
7176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7178e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    if(not defined $Cache{"checkSystemFiles"})
717962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # register all headers in system include dirs
7180e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        checkSystemFiles();
7181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Candidate (sort {get_depth($a)<=>get_depth($b)}
7183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    sort {cmp_paths($b, $a)} getSystemHeaders($Header, $LibVersion))
7184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(isRelevant($Header, $Candidate, $LibVersion)) {
718662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $Candidate;
7187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
718962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    # error
719062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
7191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getSystemHeaders($$)
7194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $LibVersion) = @_;
7196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Candidates = ();
7197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Candidate (sort keys(%{$SystemHeaders{$Header}}))
7198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
719962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(skipHeader($Candidate, $LibVersion)) {
7200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
7201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        push(@Candidates, $Candidate);
7203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @Candidates;
7205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub cut_path_prefix($$)
7208ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Prefix) = @_;
7210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Path if(not $Prefix);
7211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Prefix=~s/[\/\\]+\Z//;
7212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Path=~s/\A\Q$Prefix\E([\/\\]+|\Z)//;
7213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Path;
7214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub is_default_include_dir($)
7217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Dir = $_[0];
7219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Dir=~s/[\/\\]+\Z//;
7220570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    return grep { $Dir eq $_ } (@DefaultGccPaths, @DefaultCppPaths, @DefaultIncPaths);
7221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
722362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub identifyHeader($$)
722462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{ # cache function
7225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $LibVersion) = @_;
722662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not $Header) {
722762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return "";
7228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
722962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    $Header=~s/\A(\.\.[\\\/])+//g;
723062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"identifyHeader"}{$LibVersion}{$Header}) {
723162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"identifyHeader"}{$LibVersion}{$Header};
7232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
723362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return ($Cache{"identifyHeader"}{$LibVersion}{$Header} = identifyHeader_I($Header, $LibVersion));
7234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
723662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub identifyHeader_I($$)
7237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # search for header by absolute path, relative path or name
7238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $LibVersion) = @_;
7239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(-f $Header)
7240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # it's relative or absolute path
7241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return get_abs_path($Header);
7242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($GlibcHeader{$Header} and not $GLIBC_TESTING
7244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and my $HeaderDir = find_in_defaults($Header))
7245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search for libc headers in the /usr/include
7246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # for non-libc target library before searching
7247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # in the library paths
724874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        return join_P($HeaderDir,$Header);
7249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif(my $Path = $Include_Neighbors{$LibVersion}{$Header})
7251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search in the target library paths
7252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Path;
7253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7254570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    elsif(defined $DefaultGccHeader{$Header})
7255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search in the internal GCC include paths
7256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $DefaultGccHeader{$Header};
7257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7258dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    elsif(my $DefaultDir = find_in_defaults($Header))
7259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search in the default GCC include paths
726074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        return join_P($DefaultDir,$Header);
7261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7262570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    elsif(defined $DefaultCppHeader{$Header})
7263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search in the default G++ include paths
7264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $DefaultCppHeader{$Header};
7265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif(my $AnyPath = selectSystemHeader($Header, $LibVersion))
7267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search everywhere in the system
7268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $AnyPath;
7269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
727062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif($OSgroup eq "macos")
727162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # search in frameworks: "OpenGL/gl.h" is "OpenGL.framework/Headers/gl.h"
727262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $Dir = get_dirname($Header))
727362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
727462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $RelPath = "Headers\/".get_filename($Header);
727562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $HeaderDir = find_in_framework($RelPath, $Dir.".framework", $LibVersion)) {
727674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                return join_P($HeaderDir, $RelPath);
727762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
727862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
7279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
728062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    # cannot find anything
728162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
7282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getLocation($)
7285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7286dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7287dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
7288dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/srcp[ ]*:[ ]*([\w\-\<\>\.\+\/\\]+):(\d+) /) {
72899927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            return (path_format($1, $OSgroup), $2);
7290dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
7291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
72920d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return ();
7293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getNameByInfo($)
7296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7297989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7298dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
7299dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/name[ ]*:[ ]*@(\d+) /)
7300dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
7301dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(my $NInfo = $LibInfo{$Version}{"info"}{$1})
7302dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
7303dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if($NInfo=~/strg[ ]*:[ ]*(.*?)[ ]+lngt/)
7304dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                { # short unsigned int (may include spaces)
73058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my $Str = $1;
73068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    if($CppMode{$Version}
73078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    and $Str=~/\Ac99_(.+)\Z/)
73088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    {
73098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        if($CppKeywords_A{$1}) {
73108f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                            $Str=$1;
73118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        }
73128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    }
73138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    return $Str;
7314dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                }
7315dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
7316dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
7317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7318dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
7319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTreeStr($)
7322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7323989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7325989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/strg[ ]*:[ ]*([^ ]*)/)
7326989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        {
7327989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            my $Str = $1;
732807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            if($CppMode{$Version}
7329570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            and $Str=~/\Ac99_(.+)\Z/)
7330570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
7331989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                if($CppKeywords_A{$1}) {
7332989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    $Str=$1;
7333989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
7334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7335989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            return $Str;
7336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7338989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return "";
7339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getFuncShortName($)
7342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7343989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7345570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(index($Info, " operator ")!=-1)
7346989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        {
7347570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(index($Info, " conversion ")!=-1)
734862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
734962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(my $Rid = $SymbolInfo{$Version}{$_[0]}{"Return"})
735062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
735162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if(my $RName = $TypeInfo{$Version}{$Rid}{"Name"}) {
735262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        return "operator ".$RName;
735362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
735462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
7355989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
7356989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            else
7357989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
735862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($Info=~/ operator[ ]+([a-zA-Z]+) /)
735962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
736062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if(my $Ind = $Operator_Indication{$1}) {
736162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        return "operator".$Ind;
736262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
736362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    elsif(not $UnknownOperator{$1})
736462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    {
736562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        printMsg("WARNING", "unknown operator $1");
736662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $UnknownOperator{$1} = 1;
736762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
7368989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
7369989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
7370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
7372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
7373989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if($Info=~/name[ ]*:[ ]*@(\d+) /) {
7374989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                return getTreeStr($1);
7375989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
7376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7378989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return "";
7379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getFuncReturn($)
7382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7383989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7384989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    {
7385989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/type[ ]*:[ ]*@(\d+) /)
7386989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        {
7387989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if($LibInfo{$Version}{"info"}{$1}=~/retn[ ]*:[ ]*@(\d+) /) {
7388989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                return $1;
7389989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
7390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
7393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getFuncOrig($)
7396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7397989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7398989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    {
7399989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/orig[ ]*:[ ]*@(\d+) /) {
7400989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            return $1;
7401989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
7402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7403989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return $_[0];
7404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub unmangleArray(@)
7407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7408dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0]=~/\A\?/)
7409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # MSVC mangling
7410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $UndNameCmd = get_CmdPath("undname");
7411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $UndNameCmd) {
7412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"undname\"");
7413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        writeFile("$TMP_DIR/unmangle", join("\n", @_));
7415a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        return split(/\n/, `$UndNameCmd 0x8386 \"$TMP_DIR/unmangle\"`);
7416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
7418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # GCC mangling
7419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $CppFiltCmd = get_CmdPath("c++filt");
7420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $CppFiltCmd) {
7421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find c++filt in PATH");
7422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
74239927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(not defined $CPPFILT_SUPPORT_FILE)
74249927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
74259927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            my $Info = `$CppFiltCmd -h 2>&1`;
74269927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $CPPFILT_SUPPORT_FILE = $Info=~/\@<file>/;
74279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
7428570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my $NoStrip = ($OSgroup=~/macos|windows/)?"-n":"";
74299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($CPPFILT_SUPPORT_FILE)
74309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # new versions of c++filt can take a file
74319927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($#_>$MAX_CPPFILT_FILE_SIZE)
74329927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # c++filt <= 2.22 may crash on large files (larger than 8mb)
74339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko              # this is fixed in the oncoming version of Binutils
74349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                my @Half = splice(@_, 0, ($#_+1)/2);
74359927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                return (unmangleArray(@Half), unmangleArray(@_))
74369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
74379927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            else
74389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
74399927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                writeFile("$TMP_DIR/unmangle", join("\n", @_));
74409927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                my $Res = `$CppFiltCmd $NoStrip \@\"$TMP_DIR/unmangle\"`;
74419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if($?==139)
74429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                { # segmentation fault
74439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    printMsg("ERROR", "internal error - c++filt crashed, try to reduce MAX_CPPFILT_FILE_SIZE constant");
74449927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
74459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                return split(/\n/, $Res);
7446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
7449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # old-style unmangling
74509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($#_>$MAX_COMMAND_LINE_ARGUMENTS)
74519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
7452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my @Half = splice(@_, 0, ($#_+1)/2);
7453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return (unmangleArray(@Half), unmangleArray(@_))
7454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
7456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
7457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Strings = join(" ", @_);
74589927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                my $Res = `$CppFiltCmd $NoStrip $Strings`;
74599927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if($?==139)
74609927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                { # segmentation fault
74619927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    printMsg("ERROR", "internal error - c++filt crashed, try to reduce MAX_COMMAND_LINE_ARGUMENTS constant");
74629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
74639927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                return split(/\n/, $Res);
7464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_SignatureNoInfo($$)
7470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
747162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
747262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($Cache{"get_SignatureNoInfo"}{$LibVersion}{$Symbol}) {
747362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"get_SignatureNoInfo"}{$LibVersion}{$Symbol};
7474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
747562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($MnglName, $VersionSpec, $SymbolVersion) = separate_symbol($Symbol);
7476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Signature = $tr_name{$MnglName}?$tr_name{$MnglName}:$MnglName;
747762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($Symbol=~/\A(_Z|\?)/)
7478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # C++
74791477d2c1a4df8ea5c19b19604da6d4c5b7016d72Andrey Ponomarenko        # some standard typedefs
7480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Signature=~s/\Qstd::basic_string<char, std::char_traits<char>, std::allocator<char> >\E/std::string/g;
7481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey 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;
7482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
748382b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    if(not $CheckObjectsOnly or $OSgroup=~/linux|bsd|beos/i)
7484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # ELF format marks data as OBJECT
748562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($GlobalDataObject{$LibVersion}{$Symbol}) {
7486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Signature .= " [data]";
7487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
748862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        elsif($Symbol!~/\A(_Z|\?)/) {
7489ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Signature .= " (...)";
7490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
749262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $ChargeLevel = get_ChargeLevel($Symbol, $LibVersion))
7493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
74941693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $ShortName = substr($Signature, 0, find_center($Signature, "("));
7495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Signature=~s/\A\Q$ShortName\E/$ShortName $ChargeLevel/g;
7496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolVersion) {
7498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Signature .= $VersionSpec.$SymbolVersion;
7499ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
750062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return ($Cache{"get_SignatureNoInfo"}{$LibVersion}{$Symbol} = $Signature);
7501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_ChargeLevel($$)
7504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
750562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
750662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "" if($Symbol!~/\A(_Z|\?)/);
750762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $CompleteSignature{$LibVersion}{$Symbol}
750862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and $CompleteSignature{$LibVersion}{$Symbol}{"Header"})
7509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
751062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($CompleteSignature{$LibVersion}{$Symbol}{"Constructor"})
7511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
751262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($Symbol=~/C1E/) {
7513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "[in-charge]";
7514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
751562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            elsif($Symbol=~/C2E/) {
7516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "[not-in-charge]";
7517ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
751962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        elsif($CompleteSignature{$LibVersion}{$Symbol}{"Destructor"})
7520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
752162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($Symbol=~/D1E/) {
7522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "[in-charge]";
7523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
752462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            elsif($Symbol=~/D2E/) {
7525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "[not-in-charge]";
7526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
752762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            elsif($Symbol=~/D0E/) {
7528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "[in-charge-deleting]";
7529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
7533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
753462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Symbol=~/C1E/) {
7535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "[in-charge]";
7536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
753762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        elsif($Symbol=~/C2E/) {
7538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "[not-in-charge]";
7539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
754062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        elsif($Symbol=~/D1E/) {
7541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "[in-charge]";
7542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
754362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        elsif($Symbol=~/D2E/) {
7544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "[not-in-charge]";
7545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
754662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        elsif($Symbol=~/D0E/) {
7547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "[in-charge-deleting]";
7548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
7551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
75530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub get_Signature_M($$)
75540d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
75550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
75560d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $Signature_M = $tr_name{$Symbol};
75570d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $RTid = $CompleteSignature{$LibVersion}{$Symbol}{"Return"})
75580d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # add return type name
755962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $Signature_M = $TypeInfo{$LibVersion}{$RTid}{"Name"}." ".$Signature_M;
75600d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
75610d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return $Signature_M;
75620d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
75630d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
7564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_Signature($$)
7565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
756662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
756762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($Cache{"get_Signature"}{$LibVersion}{$Symbol}) {
756862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"get_Signature"}{$LibVersion}{$Symbol};
7569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
757062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($MnglName, $VersionSpec, $SymbolVersion) = separate_symbol($Symbol);
757162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(isPrivateData($MnglName) or not $CompleteSignature{$LibVersion}{$Symbol}{"Header"})
75720d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # non-public global data
757362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return get_SignatureNoInfo($Symbol, $LibVersion);
7574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
75758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my ($Signature, @Param_Types_FromUnmangledName) = ();
757662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $ShortName = $CompleteSignature{$LibVersion}{$Symbol}{"ShortName"};
757762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($Symbol=~/\A(_Z|\?)/)
7578ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7579fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my $ClassId = $CompleteSignature{$LibVersion}{$Symbol}{"Class"})
7580fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
7581fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $Signature .= $TypeInfo{$LibVersion}{$ClassId}{"Name"}."::";
7582fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($CompleteSignature{$LibVersion}{$Symbol}{"Destructor"}) {
7583fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $Signature .= "~";
7584fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
7585fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $Signature .= $ShortName;
7586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
758762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        elsif(my $NameSpace = $CompleteSignature{$LibVersion}{$Symbol}{"NameSpace"}) {
7588fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $Signature .= $NameSpace."::".$ShortName;
7589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
7591fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $Signature .= $ShortName;
7592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
759307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        my ($Short, $Params) = split_Signature($tr_name{$MnglName});
759407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        @Param_Types_FromUnmangledName = separate_Params($Params, 0, 1);
7595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7596fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    else
7597fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
7598fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $Signature .= $MnglName;
7599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @ParamArray = ();
760162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $Pos (sort {int($a) <=> int($b)} keys(%{$CompleteSignature{$LibVersion}{$Symbol}{"Param"}}))
7602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($Pos eq "");
760462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ParamTypeId = $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$Pos}{"type"};
7605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $ParamTypeId);
760662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ParamTypeName = $TypeInfo{$LibVersion}{$ParamTypeId}{"Name"};
7607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $ParamTypeName) {
7608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ParamTypeName = $Param_Types_FromUnmangledName[$Pos];
7609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Typedef (keys(%ChangedTypedef))
7611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
76128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(my $Base = $Typedef_BaseName{$LibVersion}{$Typedef}) {
76138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $ParamTypeName=~s/\b\Q$Typedef\E\b/$Base/g;
76148f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
7615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7616177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $ParamName = $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$Pos}{"name"})
7617177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
7618177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($ParamName ne "this" or $Symbol!~/\A(_Z|\?)/)
7619177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            { # do NOT show first hidded "this"-parameter
7620177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                push(@ParamArray, create_member_decl($ParamTypeName, $ParamName));
7621177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
7622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
7624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            push(@ParamArray, $ParamTypeName);
7625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
762762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($CompleteSignature{$LibVersion}{$Symbol}{"Data"}
762862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    or $GlobalDataObject{$LibVersion}{$Symbol}) {
76298f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Signature .= " [data]";
7630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
7632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
763362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $ChargeLevel = get_ChargeLevel($Symbol, $LibVersion))
7634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # add [in-charge]
76358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Signature .= " ".$ChargeLevel;
7636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
76378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Signature .= " (".join(", ", @ParamArray).")";
763862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($CompleteSignature{$LibVersion}{$Symbol}{"Const"}
763962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        or $Symbol=~/\A_ZN(V|)K/) {
76408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Signature .= " const";
7641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
764262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($CompleteSignature{$LibVersion}{$Symbol}{"Volatile"}
764362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        or $Symbol=~/\A_ZN(K|)V/) {
76448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Signature .= " volatile";
7645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
764662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($CompleteSignature{$LibVersion}{$Symbol}{"Static"}
764762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        and $Symbol=~/\A(_Z|\?)/)
764874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        { # for static methods
76498f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Signature .= " [static]";
7650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $ShowRetVal
765362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and my $ReturnTId = $CompleteSignature{$LibVersion}{$Symbol}{"Return"}) {
76548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Signature .= ":".$TypeInfo{$LibVersion}{$ReturnTId}{"Name"};
7655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolVersion) {
76578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Signature .= $VersionSpec.$SymbolVersion;
7658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
76598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return ($Cache{"get_Signature"}{$LibVersion}{$Symbol} = $Signature);
7660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub create_member_decl($$)
7663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TName, $Member) = @_;
7665989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($TName=~/\([\*]+\)/)
7666989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    {
7667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TName=~s/\(([\*]+)\)/\($1$Member\)/;
7668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $TName;
7669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
7671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @ArraySizes = ();
7673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while($TName=~s/(\[[^\[\]]*\])\Z//) {
7674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            push(@ArraySizes, $1);
7675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $TName." ".$Member.join("", @ArraySizes);
7677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getFuncType($)
7681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7682989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7683989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    {
7684989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/type[ ]*:[ ]*@(\d+) /)
7685989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        {
7686989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if(my $Type = $LibInfo{$Version}{"info_type"}{$1})
7687989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
7688989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                if($Type eq "method_type") {
7689989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    return "Method";
7690989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
7691989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                elsif($Type eq "function_type") {
7692989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    return "Function";
7693989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
7694989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                else {
7695989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    return "Other";
7696989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
7697989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
7698989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
7699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7700f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    return "";
7701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getFuncTypeId($)
7704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7705989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7706989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    {
7707989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/type[ ]*:[ ]*@(\d+)( |\Z)/) {
7708989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            return $1;
7709989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
7710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7711989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return 0;
7712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isAnon($)
7715989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko{ # "._N" or "$_N" in older GCC versions
7716989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return ($_[0] and $_[0]=~/(\.|\$)\_\d+|anon\-/);
7717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
77199927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub formatName($$)
772062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{ # type name correction
77219927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(defined $Cache{"formatName"}{$_[1]}{$_[0]}) {
77229927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $Cache{"formatName"}{$_[1]}{$_[0]};
772362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
772462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
7725f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my $N = $_[0];
772662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
77279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($_[1] ne "S")
77289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
77299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $N=~s/\A[ ]+//g;
77309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $N=~s/[ ]+\Z//g;
77319927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $N=~s/[ ]{2,}/ /g;
77329927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
77339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
77349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    $N=~s/[ ]*(\W)[ ]*/$1/g; # std::basic_string<char> const
773562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
7736f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    $N=~s/\bvolatile const\b/const volatile/g;
773762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
7738f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    $N=~s/\b(long long|short|long) unsigned\b/unsigned $1/g;
7739f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    $N=~s/\b(short|long) int\b/$1/g;
774062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
7741f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    $N=~s/([\)\]])(const|volatile)\b/$1 $2/g;
774262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
7743f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    while($N=~s/>>/> >/g) {};
774462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
77459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($_[1] eq "S")
77469927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
77479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(index($N, "operator")!=-1) {
77489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $N=~s/\b(operator[ ]*)> >/$1>>/;
77499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
77509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
775162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
77529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return ($Cache{"formatName"}{$_[1]}{$_[0]} = $N);
7753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_HeaderDeps($$)
7756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($AbsPath, $LibVersion) = @_;
7758ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $AbsPath or not $LibVersion);
7759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Cache{"get_HeaderDeps"}{$LibVersion}{$AbsPath}) {
7760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return @{$Cache{"get_HeaderDeps"}{$LibVersion}{$AbsPath}};
7761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %IncDir = ();
7763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    detect_recursive_includes($AbsPath, $LibVersion);
7764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $HeaderPath (keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}}))
7765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $HeaderPath);
7767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($MAIN_CPP_DIR and $HeaderPath=~/\A\Q$MAIN_CPP_DIR\E([\/\\]|\Z)/);
7768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Dir = get_dirname($HeaderPath);
7769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Prefix (keys(%{$Header_Include_Prefix{$LibVersion}{$AbsPath}{$HeaderPath}}))
7770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
7771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Dep = $Dir;
7772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Prefix)
7773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
7774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($OSgroup eq "windows")
7775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # case insensitive seach on windows
7776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(not $Dep=~s/[\/\\]+\Q$Prefix\E\Z//ig) {
7777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        next;
7778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
7779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
7780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                elsif($OSgroup eq "macos")
7781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # seach in frameworks
7782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(not $Dep=~s/[\/\\]+\Q$Prefix\E\Z//g)
7783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
7784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($HeaderPath=~/(.+\.framework)\/Headers\/([^\/]+)/)
7785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {# frameworks
7786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            my ($HFramework, $HName) = ($1, $2);
7787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $Dep = $HFramework;
7788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
7789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        else
7790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {# mismatch
7791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            next;
7792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
7793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
7794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
7795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                elsif(not $Dep=~s/[\/\\]+\Q$Prefix\E\Z//g)
7796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # Linux, FreeBSD
7797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
7798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
7799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $Dep)
7801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # nothing to include
7802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
7803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(is_default_include_dir($Dep))
7805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # included by the compiler
7806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
7807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(get_depth($Dep)==1)
7809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # too short
7810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
7811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(isLibcDir($Dep))
7813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # do NOT include /usr/include/{sys,bits}
7814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
7815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7816570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            $IncDir{$Dep} = 1;
7817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Cache{"get_HeaderDeps"}{$LibVersion}{$AbsPath} = sortIncPaths([keys(%IncDir)], $LibVersion);
7820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @{$Cache{"get_HeaderDeps"}{$LibVersion}{$AbsPath}};
7821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub sortIncPaths($$)
7824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ArrRef, $LibVersion) = @_;
7826989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(not $ArrRef or $#{$ArrRef}<0) {
7827989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        return $ArrRef;
7828989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
7829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    @{$ArrRef} = sort {$b cmp $a} @{$ArrRef};
7830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    @{$ArrRef} = sort {get_depth($a)<=>get_depth($b)} @{$ArrRef};
7831989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    @{$ArrRef} = sort {sortDeps($b, $a, $LibVersion)} @{$ArrRef};
7832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $ArrRef;
7833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7835989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenkosub sortDeps($$$)
7836989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko{
7837989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($Header_Dependency{$_[2]}{$_[0]}
7838989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    and not $Header_Dependency{$_[2]}{$_[1]}) {
7839989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        return 1;
7840989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
7841989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    elsif(not $Header_Dependency{$_[2]}{$_[0]}
7842989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    and $Header_Dependency{$_[2]}{$_[1]}) {
7843989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        return -1;
7844989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
7845989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return 0;
7846989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko}
7847989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko
784874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkosub join_P($$)
784974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko{
785074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $S = "/";
785174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($OSgroup eq "windows") {
785274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $S = "\\";
785374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
785474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return join($S, @_);
7855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_namespace_additions($)
7858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $NameSpaces = $_[0];
7860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Additions, $AddNameSpaceId) = ("", 1);
7861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $NS (sort {$a=~/_/ <=> $b=~/_/} sort {lc($a) cmp lc($b)} keys(%{$NameSpaces}))
7862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($SkipNameSpaces{$Version}{$NS});
7864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $NS or $NameSpaces->{$NS}==-1);
7865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($NS=~/(\A|::)iterator(::|\Z)/i);
7866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($NS=~/\A__/i);
7867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(($NS=~/\Astd::/ or $NS=~/\A(std|tr1|rel_ops|fcntl)\Z/) and not $STDCXX_TESTING);
78681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $NestedNameSpaces{$Version}{$NS} = 1; # for future use in reports
7869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($TypeDecl_Prefix, $TypeDecl_Suffix) = ();
7870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @NS_Parts = split(/::/, $NS);
7871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($#NS_Parts==-1);
7872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($NS_Parts[0]=~/\A(random|or)\Z/);
7873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $NS_Part (@NS_Parts)
7874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
7875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TypeDecl_Prefix .= "namespace $NS_Part\{";
7876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TypeDecl_Suffix .= "}";
7877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
787874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my $TypeDecl = $TypeDecl_Prefix."typedef int tmp_add_type_".$AddNameSpaceId.";".$TypeDecl_Suffix;
7879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $FuncDecl = "$NS\:\:tmp_add_type_$AddNameSpaceId tmp_add_func_$AddNameSpaceId(){return 0;};";
7880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Additions.="  $TypeDecl\n  $FuncDecl\n";
7881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $AddNameSpaceId+=1;
7882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Additions;
7884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub path_format($$)
788774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko{
7888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Fmt) = @_;
788974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    $Path=~s/[\/\\]+\.?\Z//g;
78901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Fmt eq "windows")
78911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
7892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path=~s/\//\\/g;
7893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path=lc($Path);
7894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
789574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    else
789674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    { # forward slash to pass into MinGW GCC
7897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path=~s/\\/\//g;
7898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Path;
7900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub inc_opt($$)
7903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Style) = @_;
7905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Style eq "GCC")
79061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # GCC options
7907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($OSgroup eq "windows")
79081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # to MinGW GCC
7909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "-I\"".path_format($Path, "unix")."\"";
7910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($OSgroup eq "macos"
7912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Path=~/\.framework\Z/)
7913570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        { # to Apple's GCC
7914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "-F".esc(get_dirname($Path));
7915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
7917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "-I".esc($Path);
7918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Style eq "CL") {
792162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return "/I \"".$Path."\"";
7922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
7924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub platformSpecs($)
7927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
7929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Arch = getArch($LibVersion);
7930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OStarget eq "symbian")
7931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # options for GCCE compiler
7932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my %Symbian_Opts = map {$_=>1} (
7933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__GCCE__",
7934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-DUNICODE",
7935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-fexceptions",
7936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__SYMBIAN32__",
7937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__MARM_INTERWORK__",
7938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_UNICODE",
7939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__S60_50__",
7940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__S60_3X__",
7941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__SERIES60_3X__",
7942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__EPOC32__",
7943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__MARM__",
7944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__EABI__",
7945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__MARM_ARMV5__",
7946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__SUPPORT_CPP_EXCEPTIONS__",
7947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-march=armv5t",
7948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-mapcs",
7949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-mthumb-interwork",
7950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-DEKA2",
7951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-DSYMBIAN_ENABLE_SPLIT_HEADERS"
7952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        );
7953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return join(" ", keys(%Symbian_Opts));
7954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($OSgroup eq "windows"
7956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and get_dumpmachine($GCC_PATH)=~/mingw/i)
7957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # add options to MinGW compiler
7958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # to simulate the MSVC compiler
7959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my %MinGW_Opts = map {$_=>1} (
7960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_WIN32",
7961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_STDCALL_SUPPORTED",
7962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__int64=\"long long\"",
7963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__int32=int",
7964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__int16=short",
7965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__int8=char",
7966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__possibly_notnullterminated=\" \"",
7967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__nullterminated=\" \"",
7968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__nullnullterminated=\" \"",
7969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__w64=\" \"",
7970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__ptr32=\" \"",
7971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__ptr64=\" \"",
7972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__forceinline=inline",
7973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__inline=inline",
7974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__uuidof(x)=IID()",
7975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__try=",
7976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__except(x)=",
7977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__declspec(x)=__attribute__((x))",
7978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__pragma(x)=",
7979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_inline=inline",
7980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__forceinline=__inline",
7981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__stdcall=__attribute__((__stdcall__))",
7982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__cdecl=__attribute__((__cdecl__))",
7983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__fastcall=__attribute__((__fastcall__))",
7984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__thiscall=__attribute__((__thiscall__))",
7985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_stdcall=__attribute__((__stdcall__))",
7986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_cdecl=__attribute__((__cdecl__))",
7987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_fastcall=__attribute__((__fastcall__))",
7988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_thiscall=__attribute__((__thiscall__))",
7989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-DSHSTDAPI_(x)=x",
7990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_MSC_EXTENSIONS",
7991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-DSECURITY_WIN32",
7992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_MSC_VER=1500",
7993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_USE_DECLSPECS_FOR_SAL",
7994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__noop=\" \"",
7995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-DDECLSPEC_DEPRECATED=\" \"",
7996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__builtin_alignof(x)=__alignof__(x)",
7997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-DSORTPP_PASS");
7998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Arch eq "x86") {
7999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MinGW_Opts{"-D_M_IX86=300"}=1;
8000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Arch eq "x86_64") {
8002ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MinGW_Opts{"-D_M_AMD64=300"}=1;
8003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Arch eq "ia64") {
8005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MinGW_Opts{"-D_M_IA64=300"}=1;
8006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return join(" ", keys(%MinGW_Opts));
8008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
8010ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8011ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %C_Structure = map {$_=>1} (
8013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# FIXME: Can't separate union and struct data types before dumping,
8014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# so it sometimes cause compilation errors for unknown reason
8015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# when trying to declare TYPE* tmp_add_class_N
8016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# This is a list of such structures + list of other C structures
8017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sigval",
8018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sigevent",
8019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sigaction",
8020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sigvec",
8021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sigstack",
8022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "timeval",
8023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "timezone",
8024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "rusage",
8025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "rlimit",
8026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "wait",
8027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "flock",
8028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "stat",
8029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "_stat",
8030ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "stat32",
8031ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "_stat32",
8032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "stat64",
8033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "_stat64",
8034ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "_stati64",
8035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "if_nameindex",
8036ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "usb_device",
8037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sigaltstack",
8038ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sysinfo",
8039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "timeLocale",
8040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "tcp_debug",
8041ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "rpc_createerr",
804282b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko # Other
8043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "timespec",
8044ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "random_data",
8045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "drand48_data",
8046ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "_IO_marker",
8047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "_IO_FILE",
8048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "lconv",
8049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sched_param",
8050ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "tm",
8051ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "itimerspec",
8052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "_pthread_cleanup_buffer",
8053ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "fd_set",
805401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    "siginfo",
805582b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "mallinfo",
8056570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "timex",
805774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "sigcontext",
805874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "ucontext",
805982b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko # Mac
806082b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_timex",
806182b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_class_t",
806282b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_category_t",
806382b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_class_ro_t",
806482b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_protocol_t",
806582b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_message_ref_t",
806682b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_super_message_ref_t",
806782b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_ivar_t",
806882b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_ivar_list_t"
8069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
8070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getCompileCmd($$$)
8072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Opt, $Inc) = @_;
8074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $GccCall = $GCC_PATH;
8075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Opt) {
8076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= " ".$Opt;
8077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8078ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $GccCall .= " -x ";
8079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup eq "macos") {
8080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= "objective-";
8081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
808262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(check_gcc($GCC_PATH, "4"))
8083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # compile as "C++" header
8084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # to obtain complete dump using GCC 4.0
8085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= "c++-header";
8086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
8088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # compile as "C++" source
8089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # GCC 3.3 cannot compile headers
8090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= "c++";
8091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Opts = platformSpecs($Version))
8093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {# platform-specific options
8094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= " ".$Opts;
8095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # allow extra qualifications
8097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # and other nonconformant code
809801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $GccCall .= " -fpermissive";
809901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $GccCall .= " -w";
8100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($NoStdInc)
8101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
8102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= " -nostdinc";
8103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= " -nostdinc++";
8104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($CompilerOptions{$Version})
8106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # user-defined options
8107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= " ".$CompilerOptions{$Version};
8108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8109a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    $GccCall .= " \"$Path\"";
8110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Inc)
8111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # include paths
8112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= " ".$Inc;
8113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $GccCall;
8115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
811701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenkosub detectPreamble($$)
8118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
811901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my ($Content, $LibVersion) = @_;
8120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %HeaderElems = (
8121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # Types
8122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "stdio.h" => ["FILE", "va_list"],
8123850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        "stddef.h" => ["NULL", "ptrdiff_t"],
81249927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "stdint.h" => ["uint8_t", "uint16_t", "uint32_t", "uint64_t",
81259927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                       "int8_t", "int16_t", "int32_t", "int64_t"],
8126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "time.h" => ["time_t"],
8127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "sys/types.h" => ["ssize_t", "u_int32_t", "u_short", "u_char",
81289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                          "u_int", "off_t", "u_quad_t", "u_long", "mode_t"],
81299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "unistd.h" => ["gid_t", "uid_t", "socklen_t"],
8130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "stdbool.h" => ["_Bool"],
8131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "rpc/xdr.h" => ["bool_t"],
8132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "in_systm.h" => ["n_long", "n_short"],
8133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # Fields
8134bede837470a7f2717ff60889049b6bbd2f33d224Andrey Ponomarenko        "arpa/inet.h" => ["fw_src", "ip_src"],
8135bede837470a7f2717ff60889049b6bbd2f33d224Andrey Ponomarenko        # Functions
81369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "stdlib.h" => ["free", "malloc", "size_t"],
8137850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        "string.h" => ["memmove", "strcmp"]
8138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
8139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %AutoPreamble = ();
8140850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    foreach (keys(%HeaderElems))
8141850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
8142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Elem (@{$HeaderElems{$_}}) {
81439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $AutoPreamble{$Elem} = $_;
8144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
814601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my %Types = ();
814701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    while($Content=~s/error\:\s*(field\s*|)\W+(.+?)\W+//)
814801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    { # error: 'FILE' has not been declared
81499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $Types{$2} = 1;
815001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    }
815101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(keys(%Types))
815201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    {
815301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        my %AddHeaders = ();
815401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        foreach my $Type (keys(%Types))
815501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        {
815601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if(my $Header = $AutoPreamble{$Type})
815701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            {
81589927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if(my $Path = identifyHeader($Header, $LibVersion))
81599927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                {
81609927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if(skipHeader($Path, $LibVersion)) {
81619927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        next;
81629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    }
81639927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $Path = path_format($Path, $OSgroup);
81649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $AddHeaders{$Path}{"Type"} = $Type;
81659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $AddHeaders{$Path}{"Header"} = $Header;
816601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                }
816701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
816801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
816901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(keys(%AddHeaders)) {
81709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            return \%AddHeaders;
817101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
817201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    }
81739927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return undef;
817401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko}
817501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
8176f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenkosub checkCTags($)
8177f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko{
8178f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my $Path = $_[0];
8179f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(not $Path) {
8180f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        return;
8181f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
8182570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my $CTags = undef;
8183570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
8184570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($OSgroup eq "bsd")
8185570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # use ectags on BSD
8186570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        $CTags = get_CmdPath("ectags");
8187570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(not $CTags) {
8188570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            printMsg("WARNING", "can't find \'ectags\' program");
8189570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
8190570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
8191f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(not $CTags) {
8192570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        $CTags = get_CmdPath("ctags");
8193570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
8194570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(not $CTags)
8195570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
8196570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        printMsg("WARNING", "can't find \'ctags\' program");
8197f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        return;
8198f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
8199bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko
820082b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    if($OSgroup ne "linux")
820182b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    { # macos, freebsd, etc.
8202bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko        my $Info = `$CTags --version 2>\"$TMP_DIR/null\"`;
8203bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko        if($Info!~/exuberant/i)
8204bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko        {
8205bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            printMsg("WARNING", "incompatible version of \'ctags\' program");
8206bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            return;
8207bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko        }
8208bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko    }
8209bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko
8210f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my $Out = $TMP_DIR."/ctags.txt";
8211bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko    system("$CTags --c-kinds=pxn -f \"$Out\" \"$Path\" 2>\"$TMP_DIR/null\"");
8212f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if($Debug) {
82139927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        copy($Out, $DEBUG_PATH{$Version}."/ctags.txt");
8214f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
8215f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    open(CTAGS, "<", $Out);
8216f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    while(my $Line = <CTAGS>)
8217f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    {
8218f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        chomp($Line);
8219f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my ($Name, $Header, $Def, $Type, $Scpe) = split(/\t/, $Line);
82209927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(defined $Intrinsic_Keywords{$Name})
82219927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # noise
82229927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            next;
82239927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
8224f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($Type eq "n")
8225f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        {
82269927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(index($Scpe, "class:")==0) {
82279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                next;
82289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
82299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(index($Scpe, "struct:")==0) {
8230f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                next;
8231f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
82329927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(index($Scpe, "namespace:")==0)
8233f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            {
82349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if($Scpe=~s/\Anamespace://) {
82359927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $Name = $Scpe."::".$Name;
82369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
82379927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
82389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $TUnit_NameSpaces{$Version}{$Name} = 1;
82399927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
82409927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        elsif($Type eq "p")
82419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
82429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(not $Scpe or index($Scpe, "namespace:")==0) {
82439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                $TUnit_Funcs{$Version}{$Name} = 1;
82449927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
82459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
82469927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        elsif($Type eq "x")
82479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
82489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(not $Scpe or index($Scpe, "namespace:")==0) {
82499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                $TUnit_Vars{$Version}{$Name} = 1;
8250f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
8251f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
8252f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
8253f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    close(CTAGS);
8254f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko}
8255f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
82568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub preChange($$)
825701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko{
82588f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my ($HeaderPath, $IncStr) = @_;
82599927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
82608f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $PreprocessCmd = getCompileCmd($HeaderPath, "-E", $IncStr);
82618f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Content = undef;
826207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
8263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OStarget eq "windows"
8264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and get_dumpmachine($GCC_PATH)=~/mingw/i
8265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $MinGWMode{$Version}!=-1)
8266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # modify headers to compile by MinGW
82678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not $Content)
8268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # preprocessing
82698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Content = `$PreprocessCmd 2>\"$TMP_DIR/null\"`;
8270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
82718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/__asm\s*(\{[^{}]*?\}|[^{};]*)//g)
8272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # __asm { ... }
8273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MinGWMode{$Version}=1;
8274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
82758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/\s+(\/ \/.*?)\n/\n/g)
8276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # comments after preprocessing
8277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MinGWMode{$Version}=1;
8278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
82798f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/(\W)(0x[a-f]+|\d+)(i|ui)(8|16|32|64)(\W)/$1$2$5/g)
8280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # 0xffui8
8281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MinGWMode{$Version}=1;
8282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
82838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
82848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($MinGWMode{$Version}) {
8285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            printMsg("INFO", "Using MinGW compatibility mode");
8286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
82888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
8289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(($COMMON_LANGUAGE{$Version} eq "C" or $CheckHeadersOnly)
82908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    and $CppMode{$Version}!=-1 and not $CppCompat and not $CPP_HEADERS)
82911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # rename C++ keywords in C code
8292570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      # disable this code by -cpp-compatible option
82938f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not $Content)
8294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # preprocessing
82958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Content = `$PreprocessCmd 2>\"$TMP_DIR/null\"`;
8296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $RegExp_C = join("|", keys(%CppKeywords_C));
8298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $RegExp_F = join("|", keys(%CppKeywords_F));
8299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $RegExp_O = join("|", keys(%CppKeywords_O));
8300bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko
8301bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko        my $Detected = undef;
8302bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko
83038f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        while($Content=~s/(\A|\n[^\#\/\n][^\n]*?|\n)(\*\s*|\s+|\@|\,|\()($RegExp_C|$RegExp_F)(\s*(\,|\)|\;|\-\>|\.|\:\s*\d))/$1$2c99_$3$4/g)
8304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # MATCH:
8305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int foo(int new, int class, int (*new)(int));
8306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # unsigned private: 8;
8307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # DO NOT MATCH:
8308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # #pragma GCC visibility push(default)
830907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $CppMode{$Version} = 1;
8310bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            $Detected = "$1$2$3$4" if(not defined $Detected);
8311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
83128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/([^\w\s]|\w\s+)(?<!operator )(delete)(\s*\()/$1c99_$2$3/g)
8313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # MATCH:
8314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int delete(...);
8315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int explicit(...);
8316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # DO NOT MATCH:
8317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # void operator delete(...)
831807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $CppMode{$Version} = 1;
8319bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            $Detected = "$1$2$3" if(not defined $Detected);
8320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
83218f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/(\s+)($RegExp_O)(\s*(\;|\:))/$1c99_$2$3/g)
8322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # MATCH:
8323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int bool;
8324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # DO NOT MATCH:
8325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # bool X;
8326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # return *this;
8327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # throw;
832807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $CppMode{$Version} = 1;
8329bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            $Detected = "$1$2$3" if(not defined $Detected);
8330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
83318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/(\s+)(operator)(\s*(\(\s*\)\s*[^\(\s]|\(\s*[^\)\s]))/$1c99_$2$3/g)
8332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # MATCH:
8333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int operator(...);
8334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # DO NOT MATCH:
8335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int operator()(...);
833607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $CppMode{$Version} = 1;
8337bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            $Detected = "$1$2$3" if(not defined $Detected);
8338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
83398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/([^\w\(\,\s]\s*|\s+)(operator)(\s*(\,\s*[^\(\s]|\)))/$1c99_$2$3/g)
8340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # MATCH:
8341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int foo(int operator);
8342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int foo(int operator, int other);
8343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # DO NOT MATCH:
8344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int operator,(...);
834507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $CppMode{$Version} = 1;
8346bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            $Detected = "$1$2$3" if(not defined $Detected);
8347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
83488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/(\*\s*|\w\s+)(bool)(\s*(\,|\)))/$1c99_$2$3/g)
8349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # MATCH:
8350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int foo(gboolean *bool);
8351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # DO NOT MATCH:
8352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # void setTabEnabled(int index, bool);
835307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $CppMode{$Version} = 1;
8354bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            $Detected = "$1$2$3" if(not defined $Detected);
8355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
83568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/(\w)(\s*[^\w\(\,\s]\s*|\s+)(this|throw)(\s*[\,\)])/$1$2c99_$3$4/g)
8357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # MATCH:
8358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int foo(int* this);
8359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int bar(int this);
83609927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko          # int baz(int throw);
8361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # DO NOT MATCH:
83629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko          # foo(X, this);
836307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $CppMode{$Version} = 1;
8364bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            $Detected = "$1$2$3$4" if(not defined $Detected);
836507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        }
83668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/(struct |extern )(template) /$1c99_$2 /g)
83678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # MATCH:
83688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko          # struct template {...};
83698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko          # extern template foo(...);
83708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $CppMode{$Version} = 1;
83718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Detected = "$1$2" if(not defined $Detected);
83728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
837307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
837407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        if($CppMode{$Version} == 1)
837507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        {
8376bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            if($Debug)
8377bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            {
8378bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko                $Detected=~s/\A\s+//g;
8379bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko                printMsg("INFO", "Detected code: \"$Detected\"");
838007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            }
8381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
83829927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
83839927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        # remove typedef enum NAME NAME;
83848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my @FwdTypedefs = $Content=~/typedef\s+enum\s+(\w+)\s+(\w+);/g;
83859927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        my $N = 0;
83869927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        while($N<=$#FwdTypedefs-1)
83879927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
83889927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            my $S = $FwdTypedefs[$N];
83899927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($S eq $FwdTypedefs[$N+1])
83909927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
83918f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $Content=~s/typedef\s+enum\s+\Q$S\E\s+\Q$S\E;//g;
8392fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $CppMode{$Version} = 1;
8393fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
8394fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Debug) {
8395fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    printMsg("INFO", "Detected code: \"typedef enum $S $S;\"");
8396fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
83979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
83989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $N+=2;
83999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
84009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
84018f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($CppMode{$Version}==1) {
840207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            printMsg("INFO", "Using C++ compatibility mode");
8403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
84058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
840607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if($CppMode{$Version}==1
8407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $MinGWMode{$Version}==1)
84088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
84098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $IPath = $TMP_DIR."/dump$Version.i";
84108f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        writeFile($IPath, $Content);
84118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return $IPath;
84128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
84138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
84148f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return undef;
84158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko}
84168f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
84178f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub getDump()
84188f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko{
84198f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(not $GCC_PATH) {
84208f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        exitStatus("Error", "internal error - GCC path is not set");
84218f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
84228f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
84238f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my @Headers = keys(%{$Registered_Headers{$Version}});
84248f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    @Headers = sort {int($Registered_Headers{$Version}{$a}{"Pos"})<=>int($Registered_Headers{$Version}{$b}{"Pos"})} @Headers;
84258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
84268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $IncludeString = getIncString(getIncPaths(@{$Include_Preamble{$Version}}, @Headers), "GCC");
84278f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
84288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $TmpHeaderPath = $TMP_DIR."/dump".$Version.".h";
84298f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $HeaderPath = $TmpHeaderPath;
84308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
84318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    # write tmp-header
84328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    open(TMP_HEADER, ">", $TmpHeaderPath) || die ("can't open file \'$TmpHeaderPath\': $!\n");
84338f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(my $AddDefines = $Descriptor{$Version}{"Defines"})
84348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
84358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $AddDefines=~s/\n\s+/\n  /g;
84368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        print TMP_HEADER "\n  // add defines\n  ".$AddDefines."\n";
84378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
84388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    print TMP_HEADER "\n  // add includes\n";
84398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $HPath (@{$Include_Preamble{$Version}}) {
84408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        print TMP_HEADER "  #include \"".path_format($HPath, "unix")."\"\n";
84418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
84428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $HPath (@Headers)
84438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
84448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not grep {$HPath eq $_} (@{$Include_Preamble{$Version}})) {
84458f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            print TMP_HEADER "  #include \"".path_format($HPath, "unix")."\"\n";
84468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
84478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
84488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    close(TMP_HEADER);
84498f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
84508f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($ExtraInfo)
84518f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # extra information for other tools
84528f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($IncludeString) {
84538f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            writeFile($ExtraInfo."/include-string", $IncludeString);
84548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
84558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        writeFile($ExtraInfo."/recursive-includes", Dumper($RecursiveIncludes{$Version}));
84568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        writeFile($ExtraInfo."/direct-includes", Dumper($Header_Includes{$Version}));
84578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
84588f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(my @Redirects = keys(%{$Header_ErrorRedirect{$Version}}))
84598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
84608f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $REDIR = "";
84618f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            foreach my $P1 (sort @Redirects) {
84628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $REDIR .= $P1.";".$Header_ErrorRedirect{$Version}{$P1}."\n";
84638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
84648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            writeFile($ExtraInfo."/include-redirect", $REDIR);
84658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
84668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
84678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
84688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(not keys(%{$TargetHeaders{$Version}}))
84698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # Target headers
84708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        addTargetHeaders($Version);
8471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8472850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
8473850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
84748f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    %RecursiveIncludes = ();
84758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    %Header_Include_Prefix = ();
84768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    %Header_Includes = ();
84778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
84788f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    # clean cache
84798f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    delete($Cache{"identifyHeader"});
84808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    delete($Cache{"detect_header_includes"});
84818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    delete($Cache{"selectSystemHeader"});
84828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
84838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    # preprocessing stage
84848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Pre = callPreprocessor($TmpHeaderPath, $IncludeString, $Version);
84858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    checkPreprocessedUnit($Pre);
84868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
84878f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($ExtraInfo)
84888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # extra information for other tools
84898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        writeFile($ExtraInfo."/header-paths", join("\n", sort keys(%{$PreprocessedHeaders{$Version}})));
84908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
84918f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
84928f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    # clean memory
84938f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    delete($Include_Neighbors{$Version});
84948f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    delete($PreprocessedHeaders{$Version});
84958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
84968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($COMMON_LANGUAGE{$Version} eq "C++") {
84978f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        checkCTags($Pre);
84988f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
84998f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
85008f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(my $PrePath = preChange($TmpHeaderPath, $IncludeString))
85018f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # try to correct the preprocessor output
85028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $HeaderPath = $PrePath;
85038f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
8504850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
8505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($COMMON_LANGUAGE{$Version} eq "C++")
8506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # add classes and namespaces to the dump
8507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $CHdump = "-fdump-class-hierarchy -c";
850807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        if($CppMode{$Version}==1
8509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        or $MinGWMode{$Version}==1) {
8510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CHdump .= " -fpreprocessed";
8511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
85128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $ClassHierarchyCmd = getCompileCmd($HeaderPath, $CHdump, $IncludeString);
8513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($TMP_DIR);
851462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        system($ClassHierarchyCmd." >null 2>&1");
8515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($ORIG_DIR);
8516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $ClassDump = (cmd_find($TMP_DIR,"f","*.class",1))[0])
8517ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
8518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Content = readFile($ClassDump);
8519ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $ClassInfo (split(/\n\n/, $Content))
8520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
8521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($ClassInfo=~/\AClass\s+(.+)\s*/i)
8522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
8523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $CName = $1;
8524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next if($CName=~/\A(__|_objc_|_opaque_)/);
8525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $TUnit_NameSpaces{$Version}{$CName} = -1;
8526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($CName=~/\A[\w:]+\Z/)
8527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # classes
8528f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        $TUnit_Classes{$Version}{$CName} = 1;
8529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
8530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($CName=~/(\w[\w:]*)::/)
8531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # namespaces
8532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $NS = $1;
8533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if(not defined $TUnit_NameSpaces{$Version}{$NS}) {
8534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $TUnit_NameSpaces{$Version}{$NS} = 1;
8535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
8536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
8537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
8538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                elsif($ClassInfo=~/\AVtable\s+for\s+(.+)\n((.|\n)+)\Z/i)
8539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # read v-tables (advanced approach)
8540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my ($CName, $VTable) = ($1, $2);
8541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ClassVTable_Content{$Version}{$CName} = $VTable;
8542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
8543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8544a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            foreach my $NS (keys(%{$AddNameSpaces{$Version}}))
8545a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            { # add user-defined namespaces
8546a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                $TUnit_NameSpaces{$Version}{$NS} = 1;
8547a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            }
8548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Debug)
8549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # debug mode
8550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                mkpath($DEBUG_PATH{$Version});
85511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                copy($ClassDump, $DEBUG_PATH{$Version}."/class-hierarchy-dump.txt");
8552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            unlink($ClassDump);
8554f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
8555f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
8556f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        # add namespaces and classes
8557f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if(my $NS_Add = get_namespace_additions($TUnit_NameSpaces{$Version}))
8558f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        { # GCC on all supported platforms does not include namespaces to the dump by default
85598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            appendFile($HeaderPath, "\n  // add namespaces\n".$NS_Add);
8560f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
8561f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        # some GCC versions don't include class methods to the TU dump by default
8562f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my ($AddClass, $ClassNum) = ("", 0);
8563570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my $GCC_44 = check_gcc($GCC_PATH, "4.4"); # support for old GCC versions
8564f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        foreach my $CName (sort keys(%{$TUnit_Classes{$Version}}))
8565f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        {
8566f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            next if($C_Structure{$CName});
8567f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            next if(not $STDCXX_TESTING and $CName=~/\Astd::/);
8568f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            next if($SkipTypes{$Version}{$CName});
8569570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(not $Force and $GCC_44
8570570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            and $OSgroup eq "linux")
8571570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            { # optimization for linux with GCC >= 4.4
8572570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko              # disable this code by -force option
8573570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if(index($CName, "::")!=-1)
8574570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                { # should be added by name space
857582b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko                    next;
857682b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko                }
857782b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko            }
857882b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko            else
857982b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko            {
858082b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko                if($CName=~/\A(.+)::[^:]+\Z/
858182b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko                and $TUnit_Classes{$Version}{$1})
858282b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko                { # classes inside other classes
858382b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko                    next;
858482b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko                }
8585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
85869927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(defined $TUnit_Funcs{$Version}{$CName})
85879927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # the same name for a function and type
85889927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                next;
85899927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
85909927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(defined $TUnit_Vars{$Version}{$CName})
85919927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # the same name for a variable and type
85929927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                next;
85939927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
8594f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $AddClass .= "  $CName* tmp_add_class_".($ClassNum++).";\n";
8595f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
8596f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($AddClass) {
85978f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            appendFile($HeaderPath, "\n  // add classes\n".$AddClass);
8598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    writeLog($Version, "Temporary header file \'$TmpHeaderPath\' with the following content will be compiled to create GCC translation unit dump:\n".readFile($TmpHeaderPath)."\n");
8601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # create TU dump
8602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TUdump = "-fdump-translation-unit -fkeep-inline-functions -c";
860307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if($CppMode{$Version}==1
8604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $MinGWMode{$Version}==1) {
8605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TUdump .= " -fpreprocessed";
8606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
86078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $SyntaxTreeCmd = getCompileCmd($HeaderPath, $TUdump, $IncludeString);
8608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    writeLog($Version, "The GCC parameters:\n  $SyntaxTreeCmd\n\n");
8609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    chdir($TMP_DIR);
8610a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    system($SyntaxTreeCmd." >\"$TMP_DIR/tu_errors\" 2>&1");
8611570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my $Errors = "";
8612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($?)
8613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # failed to compile, but the TU dump still can be created
8614570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if($Errors = readFile($TMP_DIR."/tu_errors"))
861501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        { # try to recompile
861601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko          # FIXME: handle other errors and try to recompile
861707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            if($CppMode{$Version}==1
8618570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            and index($Errors, "c99_")!=-1)
861901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # disable c99 mode and try again
862007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                $CppMode{$Version}=-1;
862107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                printMsg("INFO", "Disabling C++ compatibility mode");
862201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                resetLogging($Version);
862301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $TMP_DIR = tempdir(CLEANUP=>1);
862401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                return getDump();
8625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
862601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            elsif($AutoPreambleMode{$Version}!=-1
86279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            and my $AddHeaders = detectPreamble($Errors, $Version))
862801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # add auto preamble headers and try again
862901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $AutoPreambleMode{$Version}=-1;
86309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                my @Headers = sort {$b cmp $a} keys(%{$AddHeaders}); # sys/types.h should be the first
8631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Num (0 .. $#Headers)
8632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
863301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    my $Path = $Headers[$Num];
8634570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if(not grep {$Path eq $_} (@{$Include_Preamble{$Version}}))
8635570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    {
8636570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        push_U($Include_Preamble{$Version}, $Path);
8637570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        printMsg("INFO", "Add \'".$AddHeaders->{$Path}{"Header"}."\' preamble header for \'".$AddHeaders->{$Path}{"Type"}."\'");
8638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
8639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
8640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                resetLogging($Version);
8641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $TMP_DIR = tempdir(CLEANUP=>1);
8642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return getDump();
8643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
864401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            elsif($Cpp0xMode{$Version}!=-1
864501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            and ($Errors=~/\Q-std=c++0x\E/
864601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            or $Errors=~/is not a class or namespace/))
864701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # c++0x: enum class
8648570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if(check_gcc($GCC_PATH, "4.6"))
8649570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
8650570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $Cpp0xMode{$Version}=-1;
8651570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    printMsg("INFO", "Enabling c++0x mode");
8652570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    resetLogging($Version);
8653570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $TMP_DIR = tempdir(CLEANUP=>1);
8654570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $CompilerOptions{$Version} .= " -std=c++0x";
8655570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    return getDump();
8656570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
8657570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                else {
8658570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    printMsg("WARNING", "Probably c++0x construction detected");
8659570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
8660570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
866101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
866201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            elsif($MinGWMode{$Version}==1)
866301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # disable MinGW mode and try again
866401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $MinGWMode{$Version}=-1;
866501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                resetLogging($Version);
866601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $TMP_DIR = tempdir(CLEANUP=>1);
866701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                return getDump();
866801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
866901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            writeLog($Version, $Errors);
8670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
867101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        else {
867201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            writeLog($Version, "$!: $?\n");
8673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        printMsg("ERROR", "some errors occurred when compiling headers");
8675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        printErrorLog($Version);
8676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $COMPILE_ERRORS = $ERROR_CODE{"Compile_Error"};
8677570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        writeLog($Version, "\n"); # new line
8678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    chdir($ORIG_DIR);
8680f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    unlink($TmpHeaderPath);
86818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    unlink($HeaderPath);
8682570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
8683570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(my @TUs = cmd_find($TMP_DIR,"f","*.tu",1)) {
8684570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return $TUs[0];
8685570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
8686570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    else
8687570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
8688570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my $Msg = "can't compile header(s)";
8689570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if($Errors=~/error trying to exec \W+cc1plus\W+/) {
8690570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            $Msg .= "\nDid you install G++?";
8691570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
8692570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        exitStatus("Cannot_Compile", $Msg);
8693570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
8694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub cmd_file($)
8697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
8699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Path or not -e $Path);
8700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $CmdPath = get_CmdPath("file")) {
8701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return `$CmdPath -b \"$Path\"`;
8702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
8704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getIncString($$)
8707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ArrRef, $Style) = @_;
8709989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return "" if(not $ArrRef or $#{$ArrRef}<0);
8710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $String = "";
8711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (@{$ArrRef}) {
8712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $String .= " ".inc_opt($_, $Style);
8713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $String;
8715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getIncPaths(@)
8718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @HeaderPaths = @_;
8720570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my @IncPaths = @{$Add_Include_Paths{$Version}};
8721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($INC_PATH_AUTODETECT{$Version})
8722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # auto-detecting dependencies
8723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my %Includes = ();
8724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $HPath (@HeaderPaths)
8725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
8726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Dir (get_HeaderDeps($HPath, $Version))
8727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
8728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Skip_Include_Paths{$Version}{$Dir}) {
8729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
8730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
8731a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                if($SystemRoot)
8732a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                {
8733a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                    if($Skip_Include_Paths{$Version}{$SystemRoot.$Dir}) {
8734a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                        next;
8735a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                    }
8736a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                }
8737570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                $Includes{$Dir} = 1;
8738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Dir (@{sortIncPaths([keys(%Includes)], $Version)}) {
8741570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            push_U(\@IncPaths, $Dir);
8742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
8745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # user-defined paths
8746570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        @IncPaths = @{$Include_Paths{$Version}};
8747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return \@IncPaths;
8749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8751570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub push_U($@)
8752570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko{ # push unique
8753570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(my $Array = shift @_)
8754570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
8755570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(@_)
8756570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
8757570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            my %Exist = map {$_=>1} @{$Array};
8758570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            foreach my $Elem (@_)
8759570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
8760570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if(not defined $Exist{$Elem})
8761570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
8762570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    push(@{$Array}, $Elem);
8763570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $Exist{$Elem} = 1;
8764570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
8765570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
8766570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
8767570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
8768570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko}
8769570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
8770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub callPreprocessor($$$)
8771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Inc, $LibVersion) = @_;
8773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Path or not -f $Path);
8774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $IncludeString=$Inc;
8775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Inc) {
8776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $IncludeString = getIncString(getIncPaths($Path), "GCC");
8777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Cmd = getCompileCmd($Path, "-dD -E", $IncludeString);
8779f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my $Out = $TMP_DIR."/preprocessed.h";
8780a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    system($Cmd." >\"$Out\" 2>\"$TMP_DIR/null\"");
8781dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return $Out;
8782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
87844b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenkosub cmd_find($;$$$$)
8785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # native "find" is much faster than File::Find (~6x)
8786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # also the File::Find doesn't support --maxdepth N option
8787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # so using the cross-platform wrapper for the native one
8788570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my ($Path, $Type, $Name, $MaxDepth, $UseRegex) = @_;
8789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $Path or not -e $Path);
8790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup eq "windows")
8791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
8792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $DirCmd = get_CmdPath("dir");
8793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $DirCmd) {
8794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"dir\" command");
8795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = get_abs_path($Path);
8797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = path_format($Path, $OSgroup);
8798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Cmd = $DirCmd." \"$Path\" /B /O";
8799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MaxDepth!=1) {
8800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Cmd .= " /S";
8801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type eq "d") {
8803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Cmd .= " /AD";
8804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
880574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        elsif($Type eq "f") {
880674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $Cmd .= " /A-D";
880774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
8808570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my @Files = split(/\n/, `$Cmd 2>\"$TMP_DIR/null\"`);
8809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Name)
88108f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
88118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(not $UseRegex)
88128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # FIXME: how to search file names in MS shell?
88138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko              # wildcard to regexp
8814570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                $Name=~s/\*/.*/g;
88158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $Name='\A'.$Name.'\Z';
8816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
88178f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            @Files = grep { /$Name/i } @Files;
8818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @AbsPaths = ();
8820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $File (@Files)
8821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
8822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not is_abs($File)) {
882374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $File = join_P($Path, $File);
8824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type eq "f" and not -f $File)
8826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # skip dirs
8827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
8828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            push(@AbsPaths, path_format($File, $OSgroup));
8830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type eq "d") {
8832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            push(@AbsPaths, $Path);
8833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return @AbsPaths;
8835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
8837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
8838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $FindCmd = get_CmdPath("find");
8839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $FindCmd) {
8840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find a \"find\" command");
8841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = get_abs_path($Path);
8843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-d $Path and -l $Path
8844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Path!~/\/\Z/)
8845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # for directories that are symlinks
8846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Path.="/";
8847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Cmd = $FindCmd." \"$Path\"";
8849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MaxDepth) {
8850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Cmd .= " -maxdepth $MaxDepth";
8851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type) {
8853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Cmd .= " -type $Type";
8854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8855570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if($Name and not $UseRegex)
8856570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        { # wildcards
8857570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            $Cmd .= " -name \"$Name\"";
8858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
88599927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        my $Res = `$Cmd 2>\"$TMP_DIR/null\"`;
88608f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($? and $!) {
88619927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            printMsg("ERROR", "problem with \'find\' utility ($?): $!");
88629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
8863570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my @Files = split(/\n/, $Res);
8864570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if($Name and $UseRegex)
8865570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        { # regex
88668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            @Files = grep { /$Name/ } @Files;
8867570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
88684b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        return @Files;
8869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub unpackDump($)
8873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
8875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Path or not -e $Path);
8876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Path = get_abs_path($Path);
8877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Path = path_format($Path, $OSgroup);
8878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Dir, $FileName) = separate_path($Path);
8879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $UnpackDir = $TMP_DIR."/unpack";
8880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    rmtree($UnpackDir);
8881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    mkpath($UnpackDir);
8882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($FileName=~s/\Q.zip\E\Z//g)
8883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # *.zip
8884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $UnzipCmd = get_CmdPath("unzip");
8885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $UnzipCmd) {
8886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"unzip\" command");
8887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($UnpackDir);
888974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        system("$UnzipCmd \"$Path\" >\"$TMP_DIR/null\"");
8890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($?) {
889174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            exitStatus("Error", "can't extract \'$Path\' ($?): $!");
8892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($ORIG_DIR);
889474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my @Contents = cmd_find($UnpackDir, "f");
8895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not @Contents) {
8896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "can't extract \'$Path\'");
8897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
889874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        return $Contents[0];
8899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8900fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    elsif($FileName=~s/\Q.tar.gz\E(\.\w+|)\Z//g)
8901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # *.tar.gz
8902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($OSgroup eq "windows")
8903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # -xvzf option is not implemented in tar.exe (2003)
8904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # use "gzip.exe -k -d -f" + "tar.exe -xvf" instead
8905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $TarCmd = get_CmdPath("tar");
8906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $TarCmd) {
8907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Not_Found", "can't find \"tar\" command");
8908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $GzipCmd = get_CmdPath("gzip");
8910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $GzipCmd) {
8911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Not_Found", "can't find \"gzip\" command");
8912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            chdir($UnpackDir);
8914a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            system("$GzipCmd -k -d -f \"$Path\""); # keep input files (-k)
8915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($?) {
8916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Error", "can't extract \'$Path\'");
8917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
891874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            system("$TarCmd -xvf \"$Dir\\$FileName.tar\" >\"$TMP_DIR/null\"");
8919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($?) {
892074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                exitStatus("Error", "can't extract \'$Path\' ($?): $!");
8921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            chdir($ORIG_DIR);
8923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            unlink($Dir."/".$FileName.".tar");
892474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my @Contents = cmd_find($UnpackDir, "f");
8925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not @Contents) {
8926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Error", "can't extract \'$Path\'");
8927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
892874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            return $Contents[0];
8929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
893174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        { # Unix, Mac
8932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $TarCmd = get_CmdPath("tar");
8933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $TarCmd) {
8934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Not_Found", "can't find \"tar\" command");
8935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            chdir($UnpackDir);
893774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            system("$TarCmd -xvzf \"$Path\" >\"$TMP_DIR/null\"");
8938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($?) {
893974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                exitStatus("Error", "can't extract \'$Path\' ($?): $!");
8940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            chdir($ORIG_DIR);
894274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my @Contents = cmd_find($UnpackDir, "f");
8943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not @Contents) {
8944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Error", "can't extract \'$Path\'");
8945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
894674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            return $Contents[0];
8947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub createArchive($$)
8952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $To) = @_;
89545c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if(not $To) {
89555c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $To = ".";
89565c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
8957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Path or not -e $Path
8958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or not -d $To) {
8959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
8960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($From, $Name) = separate_path($Path);
8962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup eq "windows")
8963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # *.zip
8964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $ZipCmd = get_CmdPath("zip");
8965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $ZipCmd) {
8966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"zip\"");
8967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Pkg = $To."/".$Name.".zip";
8969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        unlink($Pkg);
8970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($To);
8971a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        system("$ZipCmd -j \"$Name.zip\" \"$Path\" >\"$TMP_DIR/null\"");
8972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($?)
8973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # cannot allocate memory (or other problems with "zip")
8974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            unlink($Path);
8975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "can't pack the ABI dump: ".$!);
8976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($ORIG_DIR);
8978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        unlink($Path);
8979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Pkg;
8980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
8982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # *.tar.gz
8983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $TarCmd = get_CmdPath("tar");
8984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $TarCmd) {
8985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"tar\"");
8986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $GzipCmd = get_CmdPath("gzip");
8988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $GzipCmd) {
8989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"gzip\"");
8990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Pkg = abs_path($To)."/".$Name.".tar.gz";
8992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        unlink($Pkg);
8993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($From);
8994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        system($TarCmd, "-czf", $Pkg, $Name);
8995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($?)
8996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # cannot allocate memory (or other problems with "tar")
8997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            unlink($Path);
8998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "can't pack the ABI dump: ".$!);
8999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($ORIG_DIR);
9001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        unlink($Path);
9002ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $To."/".$Name.".tar.gz";
9003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
9005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
9006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub is_header_file($)
9007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
9008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($_[0]=~/\.($HEADER_EXT)\Z/i) {
9009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $_[0];
9010ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9011ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
9012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
9013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
9014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub is_not_header($)
9015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
9016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($_[0]=~/\.\w+\Z/
9017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $_[0]!~/\.($HEADER_EXT)\Z/i) {
9018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
9019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
9021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
9022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
9023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub is_header($$$)
9024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
9025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $UserDefined, $LibVersion) = @_;
9026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(-d $Header);
9027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(-f $Header) {
9028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Header = get_abs_path($Header);
9029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9030ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
9031ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
9032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(is_abs($Header))
9033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # incorrect absolute path
9034ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
9035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
903662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $HPath = identifyHeader($Header, $LibVersion)) {
9037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Header = $HPath;
9038ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
9040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # can't find header
9041ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
9042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9044ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Header=~/\.\w+\Z/)
9045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # have an extension
9046ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return is_header_file($Header);
9047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
9049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
9050ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($UserDefined==2)
9051ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # specified on the command line
9052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(cmd_file($Header)!~/HTML|XML/i) {
9053ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return $Header;
9054ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9056ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($UserDefined)
9057ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # specified in the XML-descriptor
9058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # header file without an extension
9059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $Header;
9060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
9062ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
9063570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(index($Header, "/include/")!=-1
9064850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            or cmd_file($Header)=~/C[\+]*\s+program/i)
9065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # !~/HTML|XML|shared|dynamic/i
9066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return $Header;
9067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
9071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
9072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
90731693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub addTargetHeaders($)
9074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
9075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
9076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $RegHeader (keys(%{$Registered_Headers{$LibVersion}}))
9077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
9078ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $RegDir = get_dirname($RegHeader);
907946bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko        $TargetHeaders{$LibVersion}{get_filename($RegHeader)} = 1;
90809927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
90819927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(not $INC_PATH_AUTODETECT{$LibVersion}) {
90829927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            detect_recursive_includes($RegHeader, $LibVersion);
90839927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
90849927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
9085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $RecInc (keys(%{$RecursiveIncludes{$LibVersion}{$RegHeader}}))
9086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
9087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Dir = get_dirname($RecInc);
9088fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
9089177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(familiarDirs($RegDir, $Dir)
9090850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            or $RecursiveIncludes{$LibVersion}{$RegHeader}{$RecInc}!=1)
9091850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # in the same directory or included by #include "..."
909246bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                $TargetHeaders{$LibVersion}{get_filename($RecInc)} = 1;
9093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
9097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
9098fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub familiarDirs($$)
9099fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko{
9100fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my ($D1, $D2) = @_;
9101fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($D1 eq $D2) {
9102fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return 1;
9103fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
9104177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9105177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $U1 = index($D1, "/usr/");
9106177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $U2 = index($D2, "/usr/");
9107177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9108177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($U1==0 and $U2!=0) {
9109177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return 0;
9110177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9111177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9112177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($U2==0 and $U1!=0) {
9113177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return 0;
9114177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9115177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9116177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(index($D2, $D1."/")==0) {
9117177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return 1;
9118177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9119177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9120177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    # /usr/include/DIR
9121177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    # /home/user/DIR
9122177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9123177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $DL = get_depth($D1);
9124177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9125177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my @Dirs1 = ($D1);
9126177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    while($DL - get_depth($D1)<=2
9127177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    and get_depth($D1)>=4
9128177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    and $D1=~s/[\/\\]+[^\/\\]*?\Z//) {
9129177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        push(@Dirs1, $D1);
9130177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9131177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9132177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my @Dirs2 = ($D2);
9133177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    while(get_depth($D2)>=4
9134177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    and $D2=~s/[\/\\]+[^\/\\]*?\Z//) {
9135177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        push(@Dirs2, $D2);
9136177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9137177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9138177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $P1 (@Dirs1)
9139fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
9140177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $P2 (@Dirs2)
9141177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
9142177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9143177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($P1 eq $P2) {
9144177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                return 1;
9145177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
9146fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
9147fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
9148fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return 0;
9149fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko}
9150fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
9151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub readHeaders($)
9152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
9153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Version = $_[0];
9154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("INFO", "checking header(s) ".$Descriptor{$Version}{"Version"}." ...");
9155ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $DumpPath = getDump();
9156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Debug)
9157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # debug mode
9158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        mkpath($DEBUG_PATH{$Version});
91591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        copy($DumpPath, $DEBUG_PATH{$Version}."/translation-unit-dump.txt");
9160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    getInfo($DumpPath);
9162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
9163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
9164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub prepareTypes($)
9165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
9166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
916762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not checkDump($LibVersion, "2.0"))
9168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
9169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # type names have been corrected in ACC 1.22 (dump 2.0 format)
917062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $TypeId (keys(%{$TypeInfo{$LibVersion}}))
9171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
917262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $TName = $TypeInfo{$LibVersion}{$TypeId}{"Name"};
917362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($TName=~/\A(\w+)::(\w+)/) {
917462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my ($P1, $P2) = ($1, $2);
917562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($P1 eq $P2) {
917662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $TName=~s/\A$P1:\:$P1(\W)/$P1$1/;
917762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
917862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                else {
917962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $TName=~s/\A(\w+:\:)$P2:\:$P2(\W)/$1$P2$2/;
9180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
918262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $TypeInfo{$LibVersion}{$TypeId}{"Name"} = $TName;
9183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
918562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not checkDump($LibVersion, "2.5"))
9186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
9187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # V < 2.5: array size == "number of elements"
9188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # V >= 2.5: array size in bytes
918962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $TypeId (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
9190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
9191f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            my %Type = get_PureType($TypeId, $TypeInfo{$LibVersion});
919262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($Type{"Type"} eq "Array")
9193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
919401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                if(my $Size = $Type{"Size"})
919562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                { # array[N]
9196f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    my %Base = get_OneStep_BaseType($Type{"Tid"}, $TypeInfo{$LibVersion});
919701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    $Size *= $Base{"Size"};
919801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    $TypeInfo{$LibVersion}{$TypeId}{"Size"} = "$Size";
919962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
920062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                else
920162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                { # array[] is a pointer
920262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $TypeInfo{$LibVersion}{$TypeId}{"Size"} = $WORD_SIZE{$LibVersion};
9203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $V2 = ($LibVersion==1)?2:1;
920862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not checkDump($LibVersion, "2.7"))
9209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
9210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # size of "method ptr" corrected in 2.7
921162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $TypeId (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
9212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
9213f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            my %PureType = get_PureType($TypeId, $TypeInfo{$LibVersion});
921462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($PureType{"Type"} eq "MethodPtr")
9215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
921662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my %Type = get_Type($TypeId, $LibVersion);
921762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $TypeId_2 = getTypeIdByName($PureType{"Name"}, $V2);
921862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my %Type2 = get_Type($TypeId_2, $V2);
921962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($Type{"Size"} ne $Type2{"Size"}) {
922062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $TypeInfo{$LibVersion}{$TypeId}{"Size"} = $Type2{"Size"};
9221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
9226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
92271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub prepareSymbols($)
9228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
9229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
92301693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
92311693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not keys(%{$SymbolInfo{$LibVersion}}))
92321693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # check if input is valid
92331693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(not $ExtendedCheck and not $CheckObjectsOnly)
92341693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
92351693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if($CheckHeadersOnly) {
92361693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                exitStatus("Empty_Set", "the set of public symbols is empty (".$Descriptor{$LibVersion}{"Version"}.")");
92371693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
92381693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            else {
92391693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                exitStatus("Empty_Intersection", "the sets of public symbols in headers and libraries have empty intersection (".$Descriptor{$LibVersion}{"Version"}.")");
92401693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
92411693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
92421693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
92431693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
9244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Remangle = 0;
924562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not checkDump(1, "2.10")
924662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    or not checkDump(2, "2.10"))
9247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # different formats
9248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Remangle = 1;
9249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($CheckHeadersOnly)
9251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # different languages
9252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($UserLang)
9253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # --lang=LANG for both versions
9254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(($UsedDump{1}{"V"} and $UserLang ne $UsedDump{1}{"L"})
9255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            or ($UsedDump{2}{"V"} and $UserLang ne $UsedDump{2}{"L"}))
9256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
9257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($UserLang eq "C++")
9258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # remangle symbols
9259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Remangle = 1;
9260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                elsif($UserLang eq "C")
9262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # remove mangling
9263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Remangle = -1;
9264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
926862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
92691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $InfoId (sort {int($b)<=>int($a)} keys(%{$SymbolInfo{$LibVersion}}))
9270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # reverse order: D0, D1, D2, D0 (artificial, GCC < 4.5), C1, C2
927162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not checkDump($LibVersion, "2.13"))
92720d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # support for old ABI dumps
92730d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(defined $SymbolInfo{$LibVersion}{$InfoId}{"Param"})
92740d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
92750d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                foreach my $P (keys(%{$SymbolInfo{$LibVersion}{$InfoId}{"Param"}}))
92760d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                {
92770d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    my $TypeId = $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{$P}{"type"};
92780d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    my $DVal = $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{$P}{"default"};
927962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $TName = $TypeInfo{$LibVersion}{$TypeId}{"Name"};
92800d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    if(defined $DVal and $DVal ne "")
92810d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    {
92820d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        if($TName eq "char") {
92830d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{$P}{"default"} = chr($DVal);
92840d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        }
92850d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        elsif($TName eq "bool") {
92860d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{$P}{"default"} = $DVal?"true":"false";
92870d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        }
92880d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
92890d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
92900d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
92910d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
92921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SymbolInfo{$LibVersion}{$InfoId}{"Destructor"})
9293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
92941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if(defined $SymbolInfo{$LibVersion}{$InfoId}{"Param"}
92951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and keys(%{$SymbolInfo{$LibVersion}{$InfoId}{"Param"}})
9296082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko            and $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{0}{"name"} ne "this")
9297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # support for old GCC < 4.5: skip artificial ~dtor(int __in_chrg)
9298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # + support for old ABI dumps
9299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
9300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
93021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $MnglName = $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"};
9303850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $ShortName = $SymbolInfo{$LibVersion}{$InfoId}{"ShortName"};
93041693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $ClassID = $SymbolInfo{$LibVersion}{$InfoId}{"Class"};
9305850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $Return = $SymbolInfo{$LibVersion}{$InfoId}{"Return"};
9306989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko
93071693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $SRemangle = 0;
930862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not checkDump(1, "2.12")
930962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        or not checkDump(2, "2.12"))
93101693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # support for old ABI dumps
9311850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($ShortName eq "operator>>")
9312850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
9313850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(not $SymbolInfo{$LibVersion}{$InfoId}{"Class"})
9314850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # corrected mangling of operator>>
9315850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    $SRemangle = 1;
9316850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
93171693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
9318850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($SymbolInfo{$LibVersion}{$InfoId}{"Data"})
9319850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
9320850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(not $SymbolInfo{$LibVersion}{$InfoId}{"Class"}
9321850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                and isConstType($Return, $LibVersion) and $MnglName!~/L\d+$ShortName/)
9322850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # corrected mangling of const global data
9323850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                  # some global data is not mangled in the TU dump: qt_sine_table (Qt 4.8)
9324850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                  # and incorrectly mangled by old ACC versions
9325850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    $SRemangle = 1;
9326850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
93271693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
93281693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
93295c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        if(not $CheckHeadersOnly)
93305c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        { # support for old ABI dumps
93315c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            if(not checkDump(1, "2.17")
93325c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            or not checkDump(2, "2.17"))
93335c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            {
93345c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                if($SymbolInfo{$LibVersion}{$InfoId}{"Data"})
93355c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                {
93365c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                    if(not $SymbolInfo{$LibVersion}{$InfoId}{"Class"})
93375c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                    {
93385c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                        if(link_symbol($ShortName, $LibVersion, "-Deps"))
93395c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                        {
93405c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                            $MnglName = $ShortName;
93415c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                            $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"} = $MnglName;
93425c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                        }
93435c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                    }
93445c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                }
93455c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            }
93465c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
93471693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($Remangle==1 or $SRemangle==1)
9348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # support for old ABI dumps: some symbols are not mangled in old dumps
9349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # mangle both sets of symbols (old and new)
9350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # NOTE: remangling all symbols by the same mangler
9351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($MnglName=~/\A_ZN(V|)K/)
9352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # mangling may be incorrect on old ABI dumps
9353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # because of absent "Const" attribute
93541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $SymbolInfo{$LibVersion}{$InfoId}{"Const"} = 1;
9355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($MnglName=~/\A_ZN(K|)V/)
9357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # mangling may be incorrect on old ABI dumps
9358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # because of absent "Volatile" attribute
93591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $SymbolInfo{$LibVersion}{$InfoId}{"Volatile"} = 1;
9360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
93611693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if(($ClassID and $MnglName!~/\A(_Z|\?)/)
93621693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            or (not $ClassID and $CheckHeadersOnly)
93631693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            or (not $ClassID and not link_symbol($MnglName, $LibVersion, "-Deps")))
93641693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            { # support for old ABI dumps, GCC >= 4.0
93651693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko              # remangling all manually mangled symbols
93661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($MnglName = mangle_symbol($InfoId, $LibVersion, "GCC"))
9367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
93681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"} = $MnglName;
9369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $MangledNames{$LibVersion}{$MnglName} = 1;
9370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Remangle==-1)
9374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # remove mangling
9375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MnglName = "";
93761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"} = "";
9377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $MnglName) {
9379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
9380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $CompleteSignature{$LibVersion}{$MnglName}{"MnglName"})
9382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # NOTE: global data may enter here twice
93831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            %{$CompleteSignature{$LibVersion}{$MnglName}} = %{$SymbolInfo{$LibVersion}{$InfoId}};
93841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
9385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
938662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not checkDump($LibVersion, "2.6"))
9387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # support for old dumps
9388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # add "Volatile" attribute
9389ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($MnglName=~/_Z(K|)V/) {
9390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $CompleteSignature{$LibVersion}{$MnglName}{"Volatile"}=1;
9391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # symbol and its symlink have same signatures
9394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SymVer{$LibVersion}{$MnglName}) {
93951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            %{$CompleteSignature{$LibVersion}{$SymVer{$LibVersion}{$MnglName}}} = %{$SymbolInfo{$LibVersion}{$InfoId}};
9396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9397850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
9398fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my $Alias = $CompleteSignature{$LibVersion}{$MnglName}{"Alias"})
9399fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
9400fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            %{$CompleteSignature{$LibVersion}{$Alias}} = %{$SymbolInfo{$LibVersion}{$InfoId}};
9401fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($SymVer{$LibVersion}{$Alias}) {
9402fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                %{$CompleteSignature{$LibVersion}{$SymVer{$LibVersion}{$Alias}}} = %{$SymbolInfo{$LibVersion}{$InfoId}};
9403fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
9404fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
9405fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
9406850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        # clean memory
94071693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        delete($SymbolInfo{$LibVersion}{$InfoId});
9408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($COMMON_LANGUAGE{$LibVersion} eq "C++" or $OSgroup eq "windows") {
9410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        translateSymbols(keys(%{$CompleteSignature{$LibVersion}}), $LibVersion);
9411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ExtendedCheck)
9413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --ext option
9414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        addExtension($LibVersion);
9415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9416850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
9417850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
9418850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    delete($SymbolInfo{$LibVersion});
9419850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
9420850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    foreach my $Symbol (keys(%{$CompleteSignature{$LibVersion}}))
9421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # detect allocable classes with public exported constructors
9422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # or classes with auto-generated or inline-only constructors
94239927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko      # and other temp info
9424850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(my $ClassId = $CompleteSignature{$LibVersion}{$Symbol}{"Class"})
9425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
942662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $ClassName = $TypeInfo{$LibVersion}{$ClassId}{"Name"};
9427850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($CompleteSignature{$LibVersion}{$Symbol}{"Constructor"}
9428850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            and not $CompleteSignature{$LibVersion}{$Symbol}{"InLine"})
9429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # Class() { ... } will not be exported
9430850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(not $CompleteSignature{$LibVersion}{$Symbol}{"Private"})
9431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
9432850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    if($CheckHeadersOnly or link_symbol($Symbol, $LibVersion, "-Deps")) {
9433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $AllocableClass{$LibVersion}{$ClassName} = 1;
9434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
9435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9437850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if(not $CompleteSignature{$LibVersion}{$Symbol}{"Private"})
9438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # all imported class methods
9439850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(symbolFilter($Symbol, $LibVersion, "Affected", "Binary"))
9440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
9441850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    if($CheckHeadersOnly)
9442850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    {
9443850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        if(not $CompleteSignature{$LibVersion}{$Symbol}{"InLine"}
9444850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        or $CompleteSignature{$LibVersion}{$Symbol}{"Virt"})
9445850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        { # all symbols except non-virtual inline
9446850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            $ClassMethods{"Binary"}{$LibVersion}{$ClassName}{$Symbol} = 1;
9447850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        }
9448850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    }
9449850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    else {
9450850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        $ClassMethods{"Binary"}{$LibVersion}{$ClassName}{$Symbol} = 1;
9451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
9452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
945362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(symbolFilter($Symbol, $LibVersion, "Affected", "Source")) {
9454850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    $ClassMethods{"Source"}{$LibVersion}{$ClassName}{$Symbol} = 1;
9455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
94571693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $ClassNames{$LibVersion}{$ClassName} = 1;
9458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9459850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(my $RetId = $CompleteSignature{$LibVersion}{$Symbol}{"Return"})
9460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
946162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my %Base = get_BaseType($RetId, $LibVersion);
9462850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if(defined $Base{"Type"}
9463850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            and $Base{"Type"}=~/Struct|Class/)
9464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
946562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $Name = $TypeInfo{$LibVersion}{$Base{"Tid"}}{"Name"};
9466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Name=~/<([^<>\s]+)>/)
9467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
9468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(my $Tid = getTypeIdByName($1, $LibVersion)) {
9469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ReturnedClass{$LibVersion}{$Tid} = 1;
9470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
9471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
9473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ReturnedClass{$LibVersion}{$Base{"Tid"}} = 1;
9474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9477850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        foreach my $Num (keys(%{$CompleteSignature{$LibVersion}{$Symbol}{"Param"}}))
9478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
9479850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            my $PId = $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$Num}{"type"};
948062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(get_PLevel($PId, $LibVersion)>=1)
9481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
948262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(my %Base = get_BaseType($PId, $LibVersion))
9483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
94841693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    if($Base{"Type"}=~/Struct|Class/)
94851693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    {
9486850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        $ParamClass{$LibVersion}{$Base{"Tid"}}{$Symbol} = 1;
94871693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        foreach my $SubId (get_sub_classes($Base{"Tid"}, $LibVersion, 1))
94881693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        { # mark all derived classes
9489850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            $ParamClass{$LibVersion}{$SubId}{$Symbol} = 1;
94901693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        }
9491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
9492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
94959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
94969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        # mapping {short name => symbols}
94979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $Func_ShortName{$LibVersion}{$CompleteSignature{$LibVersion}{$Symbol}{"ShortName"}}{$Symbol} = 1;
9498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9499dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    foreach my $MnglName (keys(%VTableClass))
950074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    { # reconstruct attributes of v-tables
95019927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(index($MnglName, "_ZTV")==0)
9502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
9503dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(my $ClassName = $VTableClass{$MnglName})
9504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
950574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if(my $ClassId = $TName_Tid{$LibVersion}{$ClassName})
950674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                {
950762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $CompleteSignature{$LibVersion}{$MnglName}{"Header"} = $TypeInfo{$LibVersion}{$ClassId}{"Header"};
950874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $CompleteSignature{$LibVersion}{$MnglName}{"Class"} = $ClassId;
9509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
95131693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
95141693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    # types
951562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $TypeId (keys(%{$TypeInfo{$LibVersion}}))
95161693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    {
951762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $TName = $TypeInfo{$LibVersion}{$TypeId}{"Name"})
95181693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
951962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(defined $TypeInfo{$LibVersion}{$TypeId}{"VTable"}) {
952062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $ClassNames{$LibVersion}{$TName} = 1;
95211693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
952262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(defined $TypeInfo{$LibVersion}{$TypeId}{"Base"})
95231693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            {
952462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $ClassNames{$LibVersion}{$TName} = 1;
952562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                foreach my $Bid (keys(%{$TypeInfo{$LibVersion}{$TypeId}{"Base"}}))
95261693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                {
952762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if(my $BName = $TypeInfo{$LibVersion}{$Bid}{"Name"}) {
952862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $ClassNames{$LibVersion}{$BName} = 1;
95291693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    }
95301693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                }
95311693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
95321693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
95331693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
9534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
9535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
9536177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub getFirst($$)
9537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
9538177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($Tid, $LibVersion) = @_;
9539177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(not $Tid) {
9540177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return $Tid;
9541177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9542177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9543177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $Name = $TypeInfo{$LibVersion}{$Tid}{"Name"})
9544177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9545177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($TName_Tid{$LibVersion}{$Name}) {
9546177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return $TName_Tid{$LibVersion}{$Name};
9547177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9548177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9549177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9550177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    return $Tid;
9551177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
9552177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9553177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub register_SymbolUsage($$$)
9554177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{
9555177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($InfoId, $UsedType, $LibVersion) = @_;
9556177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9557177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my %FuncInfo = %{$SymbolInfo{$LibVersion}{$InfoId}};
9558177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $RTid = getFirst($FuncInfo{"Return"}, $LibVersion))
9559177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9560177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        register_TypeUsage($RTid, $UsedType, $LibVersion);
9561177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $SymbolInfo{$LibVersion}{$InfoId}{"Return"} = $RTid;
9562177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9563177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $FCid = getFirst($FuncInfo{"Class"}, $LibVersion))
9564177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9565177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        register_TypeUsage($FCid, $UsedType, $LibVersion);
9566177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $SymbolInfo{$LibVersion}{$InfoId}{"Class"} = $FCid;
9567177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9568177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $ThisId = getTypeIdByName($TypeInfo{$LibVersion}{$FCid}{"Name"}."*const", $LibVersion))
9569177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # register "this" pointer
9570177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            register_TypeUsage($ThisId, $UsedType, $LibVersion);
9571177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9572177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $ThisId_C = getTypeIdByName($TypeInfo{$LibVersion}{$FCid}{"Name"}."const*const", $LibVersion))
9573177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # register "this" pointer (const method)
9574177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            register_TypeUsage($ThisId_C, $UsedType, $LibVersion);
9575177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9576177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9577177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $PPos (keys(%{$FuncInfo{"Param"}}))
9578177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9579177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $PTid = getFirst($FuncInfo{"Param"}{$PPos}{"type"}, $LibVersion))
9580177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
9581177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            register_TypeUsage($PTid, $UsedType, $LibVersion);
9582177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $FuncInfo{"Param"}{$PPos}{"type"} = $PTid;
9583177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9584177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9585177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $TPos (keys(%{$FuncInfo{"TParam"}}))
9586177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9587177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        my $TPName = $FuncInfo{"TParam"}{$TPos}{"name"};
9588177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $TTid = $TName_Tid{$LibVersion}{$TPName}) {
9589177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            register_TypeUsage($TTid, $UsedType, $LibVersion);
9590177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9591177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9592177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
9593177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9594177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub register_TypeUsage($$$)
9595177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{
9596177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($TypeId, $UsedType, $LibVersion) = @_;
959762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not $TypeId) {
9598177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return;
9599989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
9600177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($UsedType->{$TypeId})
9601989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    { # already registered
9602177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return;
9603989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
9604177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
960562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %TInfo = get_Type($TypeId, $LibVersion);
9606850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($TInfo{"Type"})
9607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
9608177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $NS = $TInfo{"NameSpace"})
9609177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
9610177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(my $NSTid = $TName_Tid{$LibVersion}{$NS}) {
9611177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                register_TypeUsage($NSTid, $UsedType, $LibVersion);
9612177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
9613177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9614177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9615177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($TInfo{"Type"}=~/\A(Struct|Union|Class|FuncPtr|Func|MethodPtr|FieldPtr|Enum)\Z/)
9616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
9617177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $UsedType->{$TypeId} = 1;
9618850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($TInfo{"Type"}=~/\A(Struct|Class)\Z/)
9619989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
9620177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach my $BaseId (keys(%{$TInfo{"Base"}})) {
9621177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    register_TypeUsage($BaseId, $UsedType, $LibVersion);
9622989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
9623850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                foreach my $TPos (keys(%{$TInfo{"TParam"}}))
9624850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                {
9625850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    my $TPName = $TInfo{"TParam"}{$TPos}{"name"};
9626850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    if(my $TTid = $TName_Tid{$LibVersion}{$TPName}) {
9627177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        register_TypeUsage($TTid, $UsedType, $LibVersion);
9628850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    }
9629850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
96301693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
9631850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            foreach my $Memb_Pos (keys(%{$TInfo{"Memb"}}))
9632989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
9633177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(my $MTid = getFirst($TInfo{"Memb"}{$Memb_Pos}{"type"}, $LibVersion))
9634177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
9635177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    register_TypeUsage($MTid, $UsedType, $LibVersion);
9636177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $TInfo{"Memb"}{$Memb_Pos}{"type"} = $MTid;
9637989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
96381693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
9639850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($TInfo{"Type"} eq "FuncPtr"
9640177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            or $TInfo{"Type"} eq "MethodPtr"
9641177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            or $TInfo{"Type"} eq "Func")
9642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
9643850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(my $RTid = $TInfo{"Return"}) {
9644177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    register_TypeUsage($RTid, $UsedType, $LibVersion);
9645989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
9646177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach my $PPos (keys(%{$TInfo{"Param"}}))
9647989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                {
9648177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if(my $PTid = $TInfo{"Param"}{$PPos}{"type"}) {
9649177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        register_TypeUsage($PTid, $UsedType, $LibVersion);
9650989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    }
9651989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
9652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9653177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($TInfo{"Type"} eq "FieldPtr")
9654177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
9655177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(my $RTid = $TInfo{"Return"}) {
9656177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    register_TypeUsage($RTid, $UsedType, $LibVersion);
9657177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
9658177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(my $CTid = $TInfo{"Class"}) {
9659177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    register_TypeUsage($CTid, $UsedType, $LibVersion);
9660177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
9661177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
9662177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($TInfo{"Type"} eq "MethodPtr")
9663177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
9664177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(my $CTid = $TInfo{"Class"}) {
9665177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    register_TypeUsage($CTid, $UsedType, $LibVersion);
9666177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
9667177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
9668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9669850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        elsif($TInfo{"Type"}=~/\A(Const|ConstVolatile|Volatile|Pointer|Ref|Restrict|Array|Typedef)\Z/)
9670989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        {
9671177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $UsedType->{$TypeId} = 1;
9672177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(my $BTid = getFirst($TInfo{"BaseType"}, $LibVersion))
9673177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
9674177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                register_TypeUsage($BTid, $UsedType, $LibVersion);
9675177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $TypeInfo{$LibVersion}{$TypeId}{"BaseType"} = $BTid;
9676177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
96771693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
9678177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        else
9679177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # Intrinsic, TemplateParam, TypeName, SizeOf, etc.
9680177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $UsedType->{$TypeId} = 1;
96811693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
96821693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
96831693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko}
96841693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
9685850437949b65b213696469223d749c1f74c29601Andrey Ponomarenkosub selectSymbol($$$$)
968635c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko{ # select symbol to check or to dump
9687850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my ($Symbol, $SInfo, $Level, $LibVersion) = @_;
9688850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
968935c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    if($Level eq "Dump")
969035c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    {
969135c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        if($SInfo->{"Virt"} or $SInfo->{"PureVirt"})
969235c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        { # TODO: check if this symbol is from
969335c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko          # base classes of other target symbols
969435c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            return 1;
969535c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        }
969635c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    }
969735c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko
9698850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(not $STDCXX_TESTING and $Symbol=~/\A(_ZS|_ZNS|_ZNKS)/)
9699850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    { # stdc++ interfaces
9700850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return 0;
97010d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
9702850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
9703850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my $Target = 0;
9704850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(my $Header = $SInfo->{"Header"}) {
9705850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $Target = (is_target_header($Header, 1) or is_target_header($Header, 2));
9706850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
97078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($ExtendedCheck)
97088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
9709c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko        if(index($Symbol, "external_func_")==0) {
97108f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Target = 1;
97118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
97128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
9713177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($CheckHeadersOnly or $Level eq "Source")
9714850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
9715850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Target)
9716850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
9717850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($Level eq "Dump")
9718850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # dumped
9719850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($BinaryOnly)
97200d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                {
9721850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    if(not $SInfo->{"InLine"} or $SInfo->{"Data"}) {
97220d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        return 1;
97230d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
97240d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
9725850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                else {
9726850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    return 1;
9727850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
97280d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
9729850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            elsif($Level eq "Source")
9730850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # checked
9731850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                return 1;
9732850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
9733850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            elsif($Level eq "Binary")
9734850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # checked
9735850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(not $SInfo->{"InLine"} or $SInfo->{"Data"}
9736850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                or $SInfo->{"Virt"} or $SInfo->{"PureVirt"}) {
9737850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    return 1;
9738850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
9739850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
9740850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
9741850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
9742850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    else
9743850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    { # library is available
9744850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(link_symbol($Symbol, $LibVersion, "-Deps"))
9745850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # exported symbols
9746850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            return 1;
9747850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
9748850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Level eq "Dump")
9749850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # dumped
975035c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            if($BinaryOnly)
975135c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            {
975235c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                if($SInfo->{"Data"})
975335c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                {
975435c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                    if($Target) {
975535c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                        return 1;
975635c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                    }
9757850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
9758850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
975935c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            else
976035c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            { # SrcBin
9761850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($Target) {
9762850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    return 1;
9763850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
9764850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
9765850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
9766850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        elsif($Level eq "Source")
9767850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # checked
976801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if($SInfo->{"PureVirt"} or $SInfo->{"Data"} or $SInfo->{"InLine"}
976901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            or isInLineInst($Symbol, $SInfo, $LibVersion))
977035c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            { # skip LOCAL symbols
977135c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                if($Target) {
977235c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                    return 1;
977335c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                }
97740d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
97750d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
9776850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        elsif($Level eq "Binary")
9777850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # checked
9778850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($SInfo->{"PureVirt"} or $SInfo->{"Data"})
9779850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
9780850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($Target) {
9781850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    return 1;
9782850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
9783850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
9784850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
97850d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
97860d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return 0;
97870d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
97880d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
9789850437949b65b213696469223d749c1f74c29601Andrey Ponomarenkosub cleanDump($)
9790850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko{ # clean data
9791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
97921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $InfoId (keys(%{$SymbolInfo{$LibVersion}}))
9793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
9794177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not keys(%{$SymbolInfo{$LibVersion}{$InfoId}}))
9795177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
9796177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            delete($SymbolInfo{$LibVersion}{$InfoId});
9797177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            next;
9798177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
97991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $MnglName = $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"};
9800177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not $MnglName)
9801177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
98021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            delete($SymbolInfo{$LibVersion}{$InfoId});
9803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
9804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9805850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $ShortName = $SymbolInfo{$LibVersion}{$InfoId}{"ShortName"};
9806177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not $ShortName)
9807177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
9808989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            delete($SymbolInfo{$LibVersion}{$InfoId});
9809989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            next;
9810989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
9811850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($MnglName eq $ShortName)
9812850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # remove duplicate data
98131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            delete($SymbolInfo{$LibVersion}{$InfoId}{"MnglName"});
9814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9815850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(not keys(%{$SymbolInfo{$LibVersion}{$InfoId}{"Param"}})) {
9816850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            delete($SymbolInfo{$LibVersion}{$InfoId}{"Param"});
9817850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
981801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(not keys(%{$SymbolInfo{$LibVersion}{$InfoId}{"TParam"}})) {
981901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            delete($SymbolInfo{$LibVersion}{$InfoId}{"TParam"});
982001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
9821850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
982262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $Tid (keys(%{$TypeInfo{$LibVersion}}))
9823850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
9824177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not keys(%{$TypeInfo{$LibVersion}{$Tid}}))
9825177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
9826177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            delete($TypeInfo{$LibVersion}{$Tid});
9827177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            next;
9828177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
982901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        delete($TypeInfo{$LibVersion}{$Tid}{"Tid"});
983062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $Attr ("Header", "Line", "Size", "NameSpace")
9831850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
983262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(not $TypeInfo{$LibVersion}{$Tid}{$Attr}) {
983362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                delete($TypeInfo{$LibVersion}{$Tid}{$Attr});
9834850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
9835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
983601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(not keys(%{$TypeInfo{$LibVersion}{$Tid}{"TParam"}})) {
983701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            delete($TypeInfo{$LibVersion}{$Tid}{"TParam"});
983801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
9839850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
984062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
984162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
984262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub selectType($$)
984362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
984462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($Tid, $LibVersion) = @_;
98459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
98469927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(my $Dupl = $TypeTypedef{$LibVersion}{$Tid})
98479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
98489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(defined $TypeInfo{$LibVersion}{$Dupl})
98499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
98509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($TypeInfo{$LibVersion}{$Dupl}{"Name"} eq $TypeInfo{$LibVersion}{$Tid}{"Name"})
98519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # duplicate
98529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                return 0;
98539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
98549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
98559927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
98569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
985762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $THeader = $TypeInfo{$LibVersion}{$Tid}{"Header"})
9858850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
985962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not isBuiltIn($THeader))
986062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
986162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($TypeInfo{$LibVersion}{$Tid}{"Type"}=~/Class|Struct|Union|Enum|Typedef/)
986262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
986362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(not isAnon($TypeInfo{$LibVersion}{$Tid}{"Name"}))
986462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
986562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if(is_target_header($THeader, $LibVersion))
986662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    { # from target headers
986762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        if(not selfTypedef($Tid, $LibVersion)) {
986862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            return 1;
986962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        }
987062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
987162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
987262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
9873850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
9874850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
987562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return 0;
9876850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko}
9877850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
9878177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub remove_Unused($$)
9879850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko{ # remove unused data types from the ABI dump
9880850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my ($LibVersion, $Kind) = @_;
9881177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9882177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my %UsedType = ();
9883177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9884177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $InfoId (sort {int($a)<=>int($b)} keys(%{$SymbolInfo{$LibVersion}}))
9885850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
9886177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        register_SymbolUsage($InfoId, \%UsedType, $LibVersion);
9887177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9888177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $Tid (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
9889177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9890177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($UsedType{$Tid})
9891177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # All & Extended
9892177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            next;
9893177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9894177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9895177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($Kind eq "Extended")
9896177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
9897177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(selectType($Tid, $LibVersion))
9898177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
9899177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                my %Tree = ();
9900177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                register_TypeUsage($Tid, \%Tree, $LibVersion);
9901177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9902177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                my $Tmpl = 0;
9903177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach (sort {int($a)<=>int($b)} keys(%Tree))
9904177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
9905177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if(defined $TypeInfo{$LibVersion}{$_}{"Template"}
9906177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    or $TypeInfo{$LibVersion}{$_}{"Type"} eq "TemplateParam")
9907177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
9908177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $Tmpl = 1;
9909177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        last;
9910177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
9911177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
9912177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(not $Tmpl)
9913177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
9914177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    foreach (keys(%Tree)) {
9915177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $UsedType{$_} = 1;
9916177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
9917177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
9918177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
9919177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9920177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9921177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9922177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my %Delete = ();
9923177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9924177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $Tid (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
9925177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    { # remove unused types
9926177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($UsedType{$Tid})
9927177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # All & Extended
9928177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            next;
9929989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
9930177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9931177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($Kind eq "Extra")
9932850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
9933177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            my %Tree = ();
9934177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            register_TypeUsage($Tid, \%Tree, $LibVersion);
9935177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9936177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            foreach (sort {int($a)<=>int($b)} keys(%Tree))
9937177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
9938177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(defined $TypeInfo{$LibVersion}{$_}{"Template"}
9939177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                or $TypeInfo{$LibVersion}{$_}{"Type"} eq "TemplateParam")
9940177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
9941177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $Delete{$Tid} = 1;
9942177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    last;
9943850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
9944850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
9945989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
9946177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        else
9947177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
9948177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            # remove type
9949177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            delete($TypeInfo{$LibVersion}{$Tid});
9950177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9951177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9952177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9953177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($Kind eq "Extra")
9954177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    { # remove duplicates
9955177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Tid (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
9956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
9957177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($UsedType{$Tid})
9958177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            { # All & Extended
9959177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                next;
9960177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
9961177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9962177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            my $Name = $TypeInfo{$LibVersion}{$Tid}{"Name"};
9963177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9964177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($TName_Tid{$LibVersion}{$Name} ne $Tid) {
9965177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                delete($TypeInfo{$LibVersion}{$Tid});
9966989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
9967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9968177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9969177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9970177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $Tid (keys(%Delete))
9971177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9972177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        delete($TypeInfo{$LibVersion}{$Tid});
9973177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9974177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
9975177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9976177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub check_Completeness($$)
9977177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{
9978177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($Info, $LibVersion) = @_;
9979177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9980177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    # data types
9981177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Info->{"Memb"})
9982177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9983177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Pos (keys(%{$Info->{"Memb"}}))
9984850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
9985177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $Info->{"Memb"}{$Pos}{"type"}) {
9986177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                check_TypeInfo($Info->{"Memb"}{$Pos}{"type"}, $LibVersion);
9987850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
9988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9990177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Info->{"Base"})
999162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
9992177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Bid (keys(%{$Info->{"Base"}})) {
9993177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            check_TypeInfo($Bid, $LibVersion);
999462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
9995177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9996177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Info->{"BaseType"}) {
9997177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        check_TypeInfo($Info->{"BaseType"}, $LibVersion);
9998177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9999177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Info->{"TParam"})
10000177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
10001177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Pos (keys(%{$Info->{"TParam"}}))
10002ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
10003177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            my $TName = $Info->{"TParam"}{$Pos}{"name"};
10004177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($TName=~/\A\(.+\)(true|false|\d.*)\Z/) {
10005177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                next;
10006177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
10007177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($TName eq "_BoolType") {
10008177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                next;
10009177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
10010177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($TName=~/\Asizeof\(/) {
10011177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                next;
10012177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
10013177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(my $Tid = $TName_Tid{$LibVersion}{$TName}) {
10014177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                check_TypeInfo($Tid, $LibVersion);
10015177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
10016177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            else
10017177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
10018177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(defined $Debug) {
10019177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    printMsg("WARNING", "missed type $TName");
10020177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
10021850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
10022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10024177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
10025177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    # symbols
10026177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Info->{"Param"})
10027177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
10028177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Pos (keys(%{$Info->{"Param"}}))
10029177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
10030177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $Info->{"Param"}{$Pos}{"type"}) {
10031177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                check_TypeInfo($Info->{"Param"}{$Pos}{"type"}, $LibVersion);
10032177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
1003362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1003462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
10035177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Info->{"Return"}) {
10036177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        check_TypeInfo($Info->{"Return"}, $LibVersion);
10037177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
10038177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Info->{"Class"}) {
10039177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        check_TypeInfo($Info->{"Class"}, $LibVersion);
10040177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
10041177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
10042177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
10043177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub check_TypeInfo($$)
10044177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{
10045177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($Tid, $LibVersion) = @_;
10046850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
10047177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $CheckedTypeInfo{$LibVersion}{$Tid}) {
10048177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return;
10049177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
10050177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    $CheckedTypeInfo{$LibVersion}{$Tid} = 1;
10051177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
10052177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $TypeInfo{$LibVersion}{$Tid})
10053177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
10054177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not $TypeInfo{$LibVersion}{$Tid}{"Name"}) {
10055177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            printMsg("ERROR", "missed type name ($Tid)");
10056177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
10057177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        check_Completeness($TypeInfo{$LibVersion}{$Tid}, $LibVersion);
10058177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
10059177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    else {
10060177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        printMsg("ERROR", "missed type id $Tid");
10061177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
10062850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko}
10063850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
1006462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub selfTypedef($$)
10065850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko{
1006662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
1006762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type = get_Type($TypeId, $LibVersion);
10068850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($Type{"Type"} eq "Typedef")
10069dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
10070f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %Base = get_OneStep_BaseType($TypeId, $TypeInfo{$LibVersion});
10071850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Base{"Type"}=~/Class|Struct/)
10072850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
10073850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($Type{"Name"} eq $Base{"Name"}) {
10074850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                return 1;
10075850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
10076850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            elsif($Type{"Name"}=~/::(\w+)\Z/)
10077850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
10078850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($Type{"Name"} eq $Base{"Name"}."::".$1)
10079850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # QPointer<QWidget>::QPointer
10080850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    return 1;
10081850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
10082850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
10083dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
10084dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
10085850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return 0;
10086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
100881693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub addExtension($)
10089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
100901693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $LibVersion = $_[0];
100918f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $Tid (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
10092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1009362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(selectType($Tid, $LibVersion))
10094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
100958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $TName = $TypeInfo{$LibVersion}{$Tid}{"Name"};
100968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $TName=~s/\A(struct|union|class|enum) //;
100978f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $Symbol = "external_func_".$TName;
1009862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
1009962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            %{$CompleteSignature{$LibVersion}{$Symbol}} = (
1010062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                "Header" => "extended.h",
1010162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                "ShortName" => $Symbol,
1010262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                "MnglName" => $Symbol,
1010362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                "Param" => { 0 => { "type"=>$Tid, "name"=>"p1" } }
1010462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            );
1010562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
101068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $ExtendedSymbols{$Symbol} = 1;
101078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $CheckedSymbols{"Binary"}{$Symbol} = 1;
101088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $CheckedSymbols{"Source"}{$Symbol} = 1;
10109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
101118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $ExtendedSymbols{"external_func_0"} = 1;
101128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $CheckedSymbols{"Binary"}{"external_func_0"} = 1;
101138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $CheckedSymbols{"Source"}{"external_func_0"} = 1;
10114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub findMethod($$$)
10117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($VirtFunc, $ClassId, $LibVersion) = @_;
1011962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $BaseClass_Id (keys(%{$TypeInfo{$LibVersion}{$ClassId}{"Base"}}))
10120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
10121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $VirtMethodInClass = findMethod_Class($VirtFunc, $BaseClass_Id, $LibVersion)) {
10122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $VirtMethodInClass;
10123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(my $VirtMethodInBaseClasses = findMethod($VirtFunc, $BaseClass_Id, $LibVersion)) {
10125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $VirtMethodInBaseClasses;
10126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
10129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub findMethod_Class($$$)
10132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($VirtFunc, $ClassId, $LibVersion) = @_;
1013462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $ClassName = $TypeInfo{$LibVersion}{$ClassId}{"Name"};
10135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not defined $VirtualTable{$LibVersion}{$ClassName});
10136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TargetSuffix = get_symbol_suffix($VirtFunc, 1);
10137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TargetShortName = $CompleteSignature{$LibVersion}{$VirtFunc}{"ShortName"};
10138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Candidate (keys(%{$VirtualTable{$LibVersion}{$ClassName}}))
10139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search for interface with the same parameters suffix (overridden)
10140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($TargetSuffix eq get_symbol_suffix($Candidate, 1))
10141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
10142e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko            if($CompleteSignature{$LibVersion}{$VirtFunc}{"Destructor"})
10143e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko            {
10144989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                if($CompleteSignature{$LibVersion}{$Candidate}{"Destructor"})
10145989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                {
10146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(($VirtFunc=~/D0E/ and $Candidate=~/D0E/)
10147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    or ($VirtFunc=~/D1E/ and $Candidate=~/D1E/)
10148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    or ($VirtFunc=~/D2E/ and $Candidate=~/D2E/)) {
10149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        return $Candidate;
10150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10153e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko            else
10154e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko            {
10155ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($TargetShortName eq $CompleteSignature{$LibVersion}{$Candidate}{"ShortName"}) {
10156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    return $Candidate;
10157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
10162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
101641693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub registerVTable($)
10165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
101661693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $LibVersion = $_[0];
101671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (keys(%{$CompleteSignature{$LibVersion}}))
10168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
101691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CompleteSignature{$LibVersion}{$Symbol}{"Virt"}
101701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or $CompleteSignature{$LibVersion}{$Symbol}{"PureVirt"})
10171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1017262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $ClassName = $TypeInfo{$LibVersion}{$CompleteSignature{$LibVersion}{$Symbol}{"Class"}}{"Name"};
10173ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(not $STDCXX_TESTING and $ClassName=~/\A(std::|__cxxabi)/);
101741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($CompleteSignature{$LibVersion}{$Symbol}{"Destructor"}
101751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and $Symbol=~/D2E/)
10176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # pure virtual D2-destructors are marked as "virt" in the dump
10177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # virtual D2-destructors are NOT marked as "virt" in the dump
10178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # both destructors are not presented in the v-table
10179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
10180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
101811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my ($MnglName, $VersionSpec, $SymbolVersion) = separate_symbol($Symbol);
10182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $VirtualTable{$LibVersion}{$ClassName}{$MnglName} = 1;
10183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub registerOverriding($)
10188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
10190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Classes = keys(%{$VirtualTable{$LibVersion}});
10191850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    @Classes = sort {int($TName_Tid{$LibVersion}{$a})<=>int($TName_Tid{$LibVersion}{$b})} @Classes;
10192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $ClassName (@Classes)
10193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
10194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $VirtFunc (keys(%{$VirtualTable{$LibVersion}{$ClassName}}))
10195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
101961693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if($CompleteSignature{$LibVersion}{$VirtFunc}{"PureVirt"})
101971693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            { # pure virtuals
101981693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                next;
101991693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
102001693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            my $ClassId = $TName_Tid{$LibVersion}{$ClassName};
102011693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if(my $Overridden = findMethod($VirtFunc, $ClassId, $LibVersion))
10202850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
10203850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($CompleteSignature{$LibVersion}{$Overridden}{"Virt"}
10204850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                or $CompleteSignature{$LibVersion}{$Overridden}{"PureVirt"})
10205850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # both overridden virtual methods
10206850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                  # and implemented pure virtual methods
10207850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    $CompleteSignature{$LibVersion}{$VirtFunc}{"Override"} = $Overridden;
10208850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    $OverriddenMethods{$LibVersion}{$Overridden}{$VirtFunc} = 1;
10209850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    delete($VirtualTable{$LibVersion}{$ClassName}{$VirtFunc}); # remove from v-table model
10210850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
10211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not keys(%{$VirtualTable{$LibVersion}{$ClassName}})) {
10214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            delete($VirtualTable{$LibVersion}{$ClassName});
10215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setVirtFuncPositions($)
10220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
10222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $ClassName (keys(%{$VirtualTable{$LibVersion}}))
10223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
10224fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        my ($Num, $Rel) = (1, 0);
10225fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
10226fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my @Funcs = sort keys(%{$VirtualTable{$LibVersion}{$ClassName}}))
10227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
10228fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($UsedDump{$LibVersion}{"DWARF"}) {
10229fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                @Funcs = sort {int($CompleteSignature{$LibVersion}{$a}{"VirtPos"}) <=> int($CompleteSignature{$LibVersion}{$b}{"VirtPos"})} @Funcs;
10230fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
10231fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            else {
10232fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                @Funcs = sort {int($CompleteSignature{$LibVersion}{$a}{"Line"}) <=> int($CompleteSignature{$LibVersion}{$b}{"Line"})} @Funcs;
10233fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
10234fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            foreach my $VirtFunc (@Funcs)
10235fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
10236fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($UsedDump{$LibVersion}{"DWARF"}) {
10237fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $VirtualTable{$LibVersion}{$ClassName}{$VirtFunc} = $CompleteSignature{$LibVersion}{$VirtFunc}{"VirtPos"};
10238fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
10239fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else {
10240fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $VirtualTable{$LibVersion}{$ClassName}{$VirtFunc} = $Num++;
10241fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
10242fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
10243fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                # set relative positions
10244fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(defined $VirtualTable{1}{$ClassName} and defined $VirtualTable{1}{$ClassName}{$VirtFunc}
10245fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and defined $VirtualTable{2}{$ClassName} and defined $VirtualTable{2}{$ClassName}{$VirtFunc})
10246fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                { # relative position excluding added and removed virtual functions
10247fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(not $CompleteSignature{1}{$VirtFunc}{"Override"}
10248fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    and not $CompleteSignature{2}{$VirtFunc}{"Override"}) {
10249fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $CompleteSignature{$LibVersion}{$VirtFunc}{"RelPos"} = $Rel++;
10250fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
10251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
102551693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    foreach my $ClassName (keys(%{$ClassNames{$LibVersion}}))
10256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
10257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $AbsNum = 1;
102581693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        foreach my $VirtFunc (getVTable_Model($TName_Tid{$LibVersion}{$ClassName}, $LibVersion)) {
10259fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $VirtualTable_Model{$LibVersion}{$ClassName}{$VirtFunc} = $AbsNum++;
10260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_sub_classes($$$)
10265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassId, $LibVersion, $Recursive) = @_;
10267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not defined $Class_SubClasses{$LibVersion}{$ClassId});
10268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Subs = ();
10269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $SubId (keys(%{$Class_SubClasses{$LibVersion}{$ClassId}}))
10270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
102711693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($Recursive)
102721693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
10273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $SubSubId (get_sub_classes($SubId, $LibVersion, $Recursive)) {
10274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@Subs, $SubSubId);
10275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        push(@Subs, $SubId);
10278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @Subs;
10280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_base_classes($$$)
10283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassId, $LibVersion, $Recursive) = @_;
1028562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %ClassType = get_Type($ClassId, $LibVersion);
10286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not defined $ClassType{"Base"});
10287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Bases = ();
10288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $BaseId (sort {int($ClassType{"Base"}{$a}{"pos"})<=>int($ClassType{"Base"}{$b}{"pos"})}
10289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    keys(%{$ClassType{"Base"}}))
10290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
102911693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($Recursive)
102921693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
10293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $SubBaseId (get_base_classes($BaseId, $LibVersion, $Recursive)) {
10294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@Bases, $SubBaseId);
10295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        push(@Bases, $BaseId);
10298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @Bases;
10300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
103021693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub getVTable_Model($$)
103031693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{ # return an ordered list of v-table elements
10304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassId, $LibVersion) = @_;
10305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Bases = get_base_classes($ClassId, $LibVersion, 1);
10306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Elements = ();
10307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $BaseId (@Bases, $ClassId)
10308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1030962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $BName = $TypeInfo{$LibVersion}{$BaseId}{"Name"})
10310850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
10311850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if(defined $VirtualTable{$LibVersion}{$BName})
10312850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
10313fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my @VFuncs = keys(%{$VirtualTable{$LibVersion}{$BName}});
10314fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($UsedDump{$LibVersion}{"DWARF"}) {
10315fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    @VFuncs = sort {int($CompleteSignature{$LibVersion}{$a}{"VirtPos"}) <=> int($CompleteSignature{$LibVersion}{$b}{"VirtPos"})} @VFuncs;
10316fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
10317fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else {
10318fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    @VFuncs = sort {int($CompleteSignature{$LibVersion}{$a}{"Line"}) <=> int($CompleteSignature{$LibVersion}{$b}{"Line"})} @VFuncs;
10319fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
10320fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                foreach my $VFunc (@VFuncs) {
10321850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    push(@Elements, $VFunc);
10322850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
10323850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
10324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @Elements;
10327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getVShift($$)
10330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassId, $LibVersion) = @_;
10332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Bases = get_base_classes($ClassId, $LibVersion, 1);
10333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $VShift = 0;
10334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $BaseId (@Bases)
10335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1033662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $BName = $TypeInfo{$LibVersion}{$BaseId}{"Name"})
10337850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
10338850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if(defined $VirtualTable{$LibVersion}{$BName}) {
10339850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $VShift+=keys(%{$VirtualTable{$LibVersion}{$BName}});
10340850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
10341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $VShift;
10344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getShift($$)
10347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassId, $LibVersion) = @_;
10349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Bases = get_base_classes($ClassId, $LibVersion, 0);
10350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Shift = 0;
10351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $BaseId (@Bases)
10352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1035362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $Size = $TypeInfo{$LibVersion}{$BaseId}{"Size"})
10354dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
10355dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if($Size!=1)
10356dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            { # not empty base class
10357dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                $Shift+=$Size;
10358dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
10359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Shift;
10362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
103641693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub getVTable_Size($$)
103651693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{ # number of v-table elements
10366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassName, $LibVersion) = @_;
103671693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $Size = 0;
103681693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    # three approaches
103691693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not $Size)
103701693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # real size
103711693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(my %VTable = getVTable_Real($ClassName, $LibVersion)) {
103721693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $Size = keys(%VTable);
103731693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
10374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
103751693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not $Size)
103761693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # shared library symbol size
103771693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($Size = getSymbolSize($ClassVTable{$ClassName}, $LibVersion)) {
103781693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $Size /= $WORD_SIZE{$LibVersion};
103791693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
10380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
103811693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not $Size)
103821693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # model size
103831693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(defined $VirtualTable_Model{$LibVersion}{$ClassName}) {
103841693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $Size = keys(%{$VirtualTable_Model{$LibVersion}{$ClassName}}) + 2;
103851693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
103861693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
103871693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return $Size;
10388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10389ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isCopyingClass($$)
10391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
1039362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return $TypeInfo{$LibVersion}{$TypeId}{"Copied"};
10394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isLeafClass($$)
10397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassId, $LibVersion) = @_;
10399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return (not keys(%{$Class_SubClasses{$LibVersion}{$ClassId}}));
10400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub havePubFields($)
10403dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko{ # check structured type for public fields
10404dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return isAccessible($_[0], {}, 0, -1);
10405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isAccessible($$$$)
10408dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko{ # check interval in structured type for public fields
10409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypePtr, $Skip, $Start, $End) = @_;
10410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not $TypePtr);
10411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($End==-1) {
10412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $End = keys(%{$TypePtr->{"Memb"}})-1;
10413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $MemPos (keys(%{$TypePtr->{"Memb"}}))
10415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
10416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Skip and $Skip->{$MemPos})
10417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # skip removed/added fields
10418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
10419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(int($MemPos)>=$Start and int($MemPos)<=$End)
10421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
10422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(isPublic($TypePtr, $MemPos)) {
10423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return ($MemPos+1);
10424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
10428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isReserved($)
10431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # reserved fields == private
10432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $MName = $_[0];
10433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($MName=~/reserved|padding|f_spare/i) {
10434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
10435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
104369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($MName=~/\A[_]*(spare|pad|unused)[_\d]*\Z/i) {
10437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
10438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($MName=~/(pad\d+)/i) {
10440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
10441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
10443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isPublic($$)
10446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypePtr, $FieldPos) = @_;
10448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not $TypePtr);
10449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not defined $TypePtr->{"Memb"}{$FieldPos});
10450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not defined $TypePtr->{"Memb"}{$FieldPos}{"name"});
10451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $TypePtr->{"Memb"}{$FieldPos}{"access"})
10452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # by name in C language
10453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # FIXME: add other methods to detect private members
10454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $MName = $TypePtr->{"Memb"}{$FieldPos}{"name"};
10455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MName=~/priv|abidata|parent_object/i)
10456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # C-styled private data
10457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
10458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(lc($MName) eq "abi")
10460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # ABI information/reserved field
10461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
10462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(isReserved($MName))
10464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # reserved fields
10465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
10466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
10468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($TypePtr->{"Memb"}{$FieldPos}{"access"} ne "private")
10470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # by access in C++ language
10471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
10472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
10474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
104761693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub getVTable_Real($$)
104771693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{
104781693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my ($ClassName, $LibVersion) = @_;
104791693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(my $ClassId = $TName_Tid{$LibVersion}{$ClassName})
104801693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    {
1048162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Type = get_Type($ClassId, $LibVersion);
104821693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(defined $Type{"VTable"}) {
104831693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            return %{$Type{"VTable"}};
104841693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
104851693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
104861693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return ();
104871693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko}
104881693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
104891693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub cmpVTables($)
104901693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{
104911693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $ClassName = $_[0];
104921693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $Res = cmpVTables_Real($ClassName, 1);
104931693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($Res==-1) {
104941693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Res = cmpVTables_Model($ClassName);
104951693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
104961693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return $Res;
104971693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko}
104981693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
10499ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub cmpVTables_Model($)
10500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $ClassName = $_[0];
105021693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    foreach my $Symbol (keys(%{$VirtualTable_Model{1}{$ClassName}}))
10503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
105041693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(not defined $VirtualTable_Model{2}{$ClassName}{$Symbol}) {
10505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
10506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
10509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
105111693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub cmpVTables_Real($$)
10512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassName, $Strong) = @_;
105141693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(defined $Cache{"cmpVTables_Real"}{$Strong}{$ClassName}) {
105151693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        return $Cache{"cmpVTables_Real"}{$Strong}{$ClassName};
10516dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
105171693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %VTable_Old = getVTable_Real($ClassName, 1);
105181693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %VTable_New = getVTable_Real($ClassName, 2);
105191693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not %VTable_Old or not %VTable_New)
10520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # old ABI dumps
105211693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        return ($Cache{"cmpVTables_Real"}{$Strong}{$ClassName} = -1);
10522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
105231693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %Indexes = map {$_=>1} (keys(%VTable_Old), keys(%VTable_New));
10524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Offset (sort {int($a)<=>int($b)} keys(%Indexes))
10525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
105261693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(not defined $VTable_Old{$Offset})
10527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # v-table v.1 < v-table v.2
105281693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            return ($Cache{"cmpVTables_Real"}{$Strong}{$ClassName} = $Strong);
10529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
105301693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $Entry1 = $VTable_Old{$Offset};
105311693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(not defined $VTable_New{$Offset})
10532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # v-table v.1 > v-table v.2
105331693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            return ($Cache{"cmpVTables_Real"}{$Strong}{$ClassName} = ($Strong or $Entry1!~/__cxa_pure_virtual/));
10534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
105351693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $Entry2 = $VTable_New{$Offset};
10536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Entry1 = simpleVEntry($Entry1);
10537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Entry2 = simpleVEntry($Entry2);
10538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Entry1 ne $Entry2)
10539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # register as changed
10540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Entry1=~/::([^:]+)\Z/)
10541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
10542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $M1 = $1;
10543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Entry2=~/::([^:]+)\Z/)
10544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
10545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $M2 = $1;
10546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($M1 eq $M2)
10547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # overridden
10548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        next;
10549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10552989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if(differentDumps("G"))
10553989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
10554989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                if($Entry1=~/\A\-(0x|\d+)/ and $Entry2=~/\A\-(0x|\d+)/)
10555989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                {
10556989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    # GCC 4.6.1: -0x00000000000000010
10557989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    # GCC 4.7.0: -16
10558989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    next;
10559989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
10560989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
105611693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            return ($Cache{"cmpVTables_Real"}{$Strong}{$ClassName} = 1);
10562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
105641693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return ($Cache{"cmpVTables_Real"}{$Strong}{$ClassName} = 0);
10565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
105671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub mergeVTables($)
10568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # merging v-tables without diagnostics
105691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
10570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $ClassName (keys(%{$VirtualTable{1}}))
10571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
105721693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($VTableChanged_M{$ClassName})
10573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # already registered
10574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
10575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
105761693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(cmpVTables_Real($ClassName, 0)==1)
10577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
105781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my @Affected = (keys(%{$ClassMethods{$Level}{1}{$ClassName}}));
10579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Symbol (@Affected)
10580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
105811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Symbol}{"Virtual_Table_Changed_Unknown"}{$ClassName}}=(
10582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Type_Name"=>$ClassName,
10583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>$ClassName);
10584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
105891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub mergeBases($)
10590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
105911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
105921693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    foreach my $ClassName (keys(%{$ClassNames{1}}))
10593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # detect added and removed virtual functions
105941693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $ClassId = $TName_Tid{1}{$ClassName};
10595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $ClassId);
10596dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if(defined $VirtualTable{2}{$ClassName})
10597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
105981693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            foreach my $Symbol (keys(%{$VirtualTable{2}{$ClassName}}))
10599dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
106001693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                if($TName_Tid{1}{$ClassName}
106011693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                and not defined $VirtualTable{1}{$ClassName}{$Symbol})
10602dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                { # added to v-table
106031693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    if(defined $CompleteSignature{1}{$Symbol}
106041693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    and $CompleteSignature{1}{$Symbol}{"Virt"})
106051693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    { # override some method in v.1
106061693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        next;
10607dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
106081693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    $AddedInt_Virt{$Level}{$ClassName}{$Symbol} = 1;
10609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10612dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if(defined $VirtualTable{1}{$ClassName})
10613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
106141693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            foreach my $Symbol (keys(%{$VirtualTable{1}{$ClassName}}))
10615dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
106161693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                if($TName_Tid{2}{$ClassName}
106171693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                and not defined $VirtualTable{2}{$ClassName}{$Symbol})
10618dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                { # removed from v-table
106191693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    if(defined $CompleteSignature{2}{$Symbol}
106201693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    and $CompleteSignature{2}{$Symbol}{"Virt"})
106211693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    { # override some method in v.2
106221693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        next;
10623dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
106241693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    $RemovedInt_Virt{$Level}{$ClassName}{$Symbol} = 1;
10625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
106281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Binary")
106291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # Binary-level
1063062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my %Class_Type = get_Type($ClassId, 1);
106311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $AddedVFunc (keys(%{$AddedInt_Virt{$Level}{$ClassName}}))
106321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # check replacements, including pure virtual methods
106331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my $AddedPos = $VirtualTable{2}{$ClassName}{$AddedVFunc};
106341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $RemovedVFunc (keys(%{$RemovedInt_Virt{$Level}{$ClassName}}))
10635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
106361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my $RemovedPos = $VirtualTable{1}{$ClassName}{$RemovedVFunc};
106371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($AddedPos==$RemovedPos)
106381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
106391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $VirtualReplacement{$AddedVFunc} = $RemovedVFunc;
106401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $VirtualReplacement{$RemovedVFunc} = $AddedVFunc;
106411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        last; # other methods will be reported as "added" or "removed"
10642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
106441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if(my $RemovedVFunc = $VirtualReplacement{$AddedVFunc})
10645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
106461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if(lc($AddedVFunc) eq lc($RemovedVFunc))
106471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # skip: DomUi => DomUI parameter (Qt 4.2.3 to 4.3.0)
10648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        next;
10649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
106501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my $ProblemType = "Virtual_Replacement";
106511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my @Affected = ($RemovedVFunc);
106521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($CompleteSignature{1}{$RemovedVFunc}{"PureVirt"})
106531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # pure methods
106541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(not isUsedClass($ClassId, 1, $Level))
106551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        { # not a parameter of some exported method
106561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            next;
106571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
106581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $ProblemType = "Pure_Virtual_Replacement";
106599927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
106609927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        # affected all methods (both virtual and non-virtual ones)
106619927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        @Affected = (keys(%{$ClassMethods{$Level}{1}{$ClassName}}));
106629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        push(@Affected, keys(%{$OverriddenMethods{1}{$RemovedVFunc}}));
106631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
106649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $VTableChanged_M{$ClassName}=1;
106651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    foreach my $AffectedInt (@Affected)
106661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
106671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($CompleteSignature{1}{$AffectedInt}{"PureVirt"})
106681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        { # affected exported methods only
106691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            next;
106701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
106719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        if(not symbolFilter($AffectedInt, 1, "Affected", $Level)) {
106729927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            next;
106739927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
106741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        %{$CompatProblems{$Level}{$AffectedInt}{$ProblemType}{$tr_name{$AddedVFunc}}}=(
106751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Type_Name"=>$Class_Type{"Name"},
106761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>get_Signature($AddedVFunc, 2),
106771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Old_Value"=>get_Signature($RemovedVFunc, 1));
106781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
10679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1068362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not checkDump(1, "2.0")
1068462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    or not checkDump(2, "2.0"))
106851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # support for old ABI dumps
106869927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko      # "Base" attribute introduced in ACC 1.22 (ABI dump 2.0 format)
10687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
10688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
106891693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    foreach my $ClassName (sort keys(%{$ClassNames{1}}))
10690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
106911693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $ClassId_Old = $TName_Tid{1}{$ClassName};
10692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $ClassId_Old);
10693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not isCreatable($ClassId_Old, 1))
10694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # skip classes without public constructors (including auto-generated)
10695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # example: class has only a private exported or private inline constructor
10696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
10697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($ClassName=~/>/)
10699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # skip affected template instances
10700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
10701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1070262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Class_Old = get_Type($ClassId_Old, 1);
107031693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $ClassId_New = $TName_Tid{2}{$ClassName};
10704850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(not $ClassId_New) {
10705850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            next;
10706850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
1070762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Class_New = get_Type($ClassId_New, 2);
10708850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Class_New{"Type"}!~/Class|Struct/)
10709850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # became typedef
10710850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($Level eq "Binary") {
10711850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                next;
10712850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
10713850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($Level eq "Source")
10714850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
10715f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                %Class_New = get_PureType($ClassId_New, $TypeInfo{2});
10716850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($Class_New{"Type"}!~/Class|Struct/) {
10717850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    next;
10718850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
10719850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $ClassId_New = $Class_New{"Tid"};
10720850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
10721850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
10722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Bases_Old = sort {$Class_Old{"Base"}{$a}{"pos"}<=>$Class_Old{"Base"}{$b}{"pos"}} keys(%{$Class_Old{"Base"}});
10723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Bases_New = sort {$Class_New{"Base"}{$a}{"pos"}<=>$Class_New{"Base"}{$b}{"pos"}} keys(%{$Class_New{"Base"}});
10724f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
10725f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %Tr_Old = map {$TypeInfo{1}{$_}{"Name"} => uncover_typedefs($TypeInfo{1}{$_}{"Name"}, 1)} @Bases_Old;
10726f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %Tr_New = map {$TypeInfo{2}{$_}{"Name"} => uncover_typedefs($TypeInfo{2}{$_}{"Name"}, 2)} @Bases_New;
10727f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
10728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($BNum1, $BNum2) = (1, 1);
10729f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %BasePos_Old = map {$Tr_Old{$TypeInfo{1}{$_}{"Name"}} => $BNum1++} @Bases_Old;
10730f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %BasePos_New = map {$Tr_New{$TypeInfo{2}{$_}{"Name"}} => $BNum2++} @Bases_New;
1073174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my %ShortBase_Old = map {get_ShortClass($_, 1) => 1} @Bases_Old;
1073274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my %ShortBase_New = map {get_ShortClass($_, 2) => 1} @Bases_New;
10733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Shift_Old = getShift($ClassId_Old, 1);
10734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Shift_New = getShift($ClassId_New, 2);
10735f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %BaseId_New = map {$Tr_New{$TypeInfo{2}{$_}{"Name"}} => $_} @Bases_New;
10736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($Added, $Removed) = (0, 0);
10737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @StableBases_Old = ();
10738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $BaseId (@Bases_Old)
10739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1074062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $BaseName = $TypeInfo{1}{$BaseId}{"Name"};
10741f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($BasePos_New{$Tr_Old{$BaseName}}) {
10742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@StableBases_Old, $BaseId);
10743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10744f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            elsif(not $ShortBase_New{$Tr_Old{$BaseName}}
1074574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            and not $ShortBase_New{get_ShortClass($BaseId, 1)})
10746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # removed base
10747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # excluding namespace::SomeClass to SomeClass renaming
10748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $ProblemKind = "Removed_Base_Class";
107491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary")
107501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # Binary-level
107511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Shift_Old ne $Shift_New)
107521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # affected fields
107531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(havePubFields(\%Class_Old)) {
107541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemKind .= "_And_Shift";
107551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
107561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        elsif($Class_Old{"Size"} ne $Class_New{"Size"}) {
107571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemKind .= "_And_Size";
107581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
10759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
107601693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    if(keys(%{$VirtualTable_Model{1}{$BaseName}})
107611693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    and cmpVTables($ClassName)==1)
107621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # affected v-table
107631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $ProblemKind .= "_And_VTable";
107641693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        $VTableChanged_M{$ClassName}=1;
10765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
107671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my @Affected = keys(%{$ClassMethods{$Level}{1}{$ClassName}});
10768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $SubId (get_sub_classes($ClassId_Old, 1, 1))
10769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
10770f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    if(my $SubName = $TypeInfo{1}{$SubId}{"Name"})
10771f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    {
10772f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        push(@Affected, keys(%{$ClassMethods{$Level}{1}{$SubName}}));
10773f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if($ProblemKind=~/VTable/) {
10774f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            $VTableChanged_M{$SubName}=1;
10775f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
10776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Interface (@Affected)
10779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
107809927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if(not symbolFilter($Interface, 1, "Affected", $Level)) {
107819927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        next;
107829927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    }
107831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    %{$CompatProblems{$Level}{$Interface}{$ProblemKind}{"this"}}=(
10784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Type_Name"=>$ClassName,
10785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$BaseName,
10786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Size"=>$Class_Old{"Size"}*$BYTE_SIZE,
10787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Size"=>$Class_New{"Size"}*$BYTE_SIZE,
10788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Shift"=>abs($Shift_New-$Shift_Old)  );
10789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Removed+=1;
10791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @StableBases_New = ();
10794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $BaseId (@Bases_New)
10795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1079662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $BaseName = $TypeInfo{2}{$BaseId}{"Name"};
10797f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($BasePos_Old{$Tr_New{$BaseName}}) {
10798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@StableBases_New, $BaseId);
10799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10800f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            elsif(not $ShortBase_Old{$Tr_New{$BaseName}}
1080174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            and not $ShortBase_Old{get_ShortClass($BaseId, 2)})
10802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # added base
10803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # excluding namespace::SomeClass to SomeClass renaming
10804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $ProblemKind = "Added_Base_Class";
108051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary")
108061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # Binary-level
108071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Shift_Old ne $Shift_New)
108081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # affected fields
108091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(havePubFields(\%Class_Old)) {
108101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemKind .= "_And_Shift";
108111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
108121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        elsif($Class_Old{"Size"} ne $Class_New{"Size"}) {
108131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemKind .= "_And_Size";
108141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
10815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
108161693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    if(keys(%{$VirtualTable_Model{2}{$BaseName}})
108171693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    and cmpVTables($ClassName)==1)
108181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # affected v-table
108191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $ProblemKind .= "_And_VTable";
108201693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        $VTableChanged_M{$ClassName}=1;
10821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
108231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my @Affected = keys(%{$ClassMethods{$Level}{1}{$ClassName}});
10824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $SubId (get_sub_classes($ClassId_Old, 1, 1))
10825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
10826f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    if(my $SubName = $TypeInfo{1}{$SubId}{"Name"})
10827f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    {
10828f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        push(@Affected, keys(%{$ClassMethods{$Level}{1}{$SubName}}));
10829f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if($ProblemKind=~/VTable/) {
10830f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            $VTableChanged_M{$SubName}=1;
10831f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
10832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Interface (@Affected)
10835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
108369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if(not symbolFilter($Interface, 1, "Affected", $Level)) {
108379927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        next;
108389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    }
108391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    %{$CompatProblems{$Level}{$Interface}{$ProblemKind}{"this"}}=(
10840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Type_Name"=>$ClassName,
10841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$BaseName,
10842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Size"=>$Class_Old{"Size"}*$BYTE_SIZE,
10843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Size"=>$Class_New{"Size"}*$BYTE_SIZE,
10844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Shift"=>abs($Shift_New-$Shift_Old)  );
10845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Added+=1;
10847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
108491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Binary")
108501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # Binary-level
108511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            ($BNum1, $BNum2) = (1, 1);
10852f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            my %BaseRelPos_Old = map {$Tr_Old{$TypeInfo{1}{$_}{"Name"}} => $BNum1++} @StableBases_Old;
10853f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            my %BaseRelPos_New = map {$Tr_New{$TypeInfo{2}{$_}{"Name"}} => $BNum2++} @StableBases_New;
108541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $BaseId (@Bases_Old)
10855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
1085662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $BaseName = $TypeInfo{1}{$BaseId}{"Name"};
10857f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                if(my $NewPos = $BaseRelPos_New{$Tr_Old{$BaseName}})
108581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                {
10859f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    my $BaseNewId = $BaseId_New{$Tr_Old{$BaseName}};
10860f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    my $OldPos = $BaseRelPos_Old{$Tr_Old{$BaseName}};
108611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($NewPos!=$OldPos)
108621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # changed position of the base class
108631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        foreach my $Interface (keys(%{$ClassMethods{$Level}{1}{$ClassName}}))
108641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
108659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            if(not symbolFilter($Interface, 1, "Affected", $Level)) {
108669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                next;
108679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            }
108681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Interface}{"Base_Class_Position"}{"this"}}=(
108691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Type_Name"=>$ClassName,
108701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$BaseName,
108711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Old_Value"=>$OldPos-1,
108721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "New_Value"=>$NewPos-1  );
108731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
10874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
108751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Class_Old{"Base"}{$BaseId}{"virtual"}
108761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    and not $Class_New{"Base"}{$BaseNewId}{"virtual"})
108771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # became non-virtual base
108781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        foreach my $Interface (keys(%{$ClassMethods{$Level}{1}{$ClassName}}))
108791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
108809927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            if(not symbolFilter($Interface, 1, "Affected", $Level)) {
108819927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                next;
108829927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            }
108831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Interface}{"Base_Class_Became_Non_Virtually_Inherited"}{"this->".$BaseName}}=(
108841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Type_Name"=>$ClassName,
108851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$BaseName  );
108861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
10887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
108881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    elsif(not $Class_Old{"Base"}{$BaseId}{"virtual"}
108891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    and $Class_New{"Base"}{$BaseNewId}{"virtual"})
108901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # became virtual base
108911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        foreach my $Interface (keys(%{$ClassMethods{$Level}{1}{$ClassName}}))
108921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
108939927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            if(not symbolFilter($Interface, 1, "Affected", $Level)) {
108949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                next;
108959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            }
108961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Interface}{"Base_Class_Became_Virtually_Inherited"}{"this->".$BaseName}}=(
108971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Type_Name"=>$ClassName,
108981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$BaseName  );
108991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
10900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
109031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            # detect size changes in base classes
109041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Shift_Old!=$Shift_New)
109051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # size of allocable class
109061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $BaseId (@StableBases_Old)
109071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # search for changed base
1090862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my %BaseType = get_Type($BaseId, 1);
1090962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $Size_Old = $TypeInfo{1}{$BaseId}{"Size"};
10910f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    my $Size_New = $TypeInfo{2}{$BaseId_New{$Tr_Old{$BaseType{"Name"}}}}{"Size"};
109111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Size_Old ne $Size_New
109121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    and $Size_Old and $Size_New)
10913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
109141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        my $ProblemType = "";
109151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(isCopyingClass($BaseId, 1)) {
109161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemType = "Size_Of_Copying_Class";
10917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
109181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        elsif($AllocableClass{1}{$BaseType{"Name"}})
109191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
109201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            if($Size_New>$Size_Old)
109211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            { # increased size
109221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $ProblemType = "Size_Of_Allocable_Class_Increased";
109231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            }
109241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            else
109251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            { # decreased size
109261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $ProblemType = "Size_Of_Allocable_Class_Decreased";
109271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                if(not havePubFields(\%Class_Old))
109281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                { # affected class has no public members
109291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    next;
109301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                }
10931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
10932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
109331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        next if(not $ProblemType);
109341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        foreach my $Interface (keys(%{$ClassMethods{$Level}{1}{$ClassName}}))
109351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        { # base class size changes affecting current class
109369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            if(not symbolFilter($Interface, 1, "Affected", $Level)) {
109379927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                next;
109389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            }
109391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Interface}{$ProblemType}{"this->".$BaseType{"Name"}}}=(
109401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Type_Name"=>$BaseType{"Name"},
109411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$BaseType{"Name"},
109421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Old_Size"=>$Size_Old*$BYTE_SIZE,
109431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "New_Size"=>$Size_New*$BYTE_SIZE  );
109441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
10945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10948f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if(defined $VirtualTable_Model{1}{$ClassName}
109491693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            and cmpVTables_Real($ClassName, 1)==1
10950f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            and my @VFunctions = keys(%{$VirtualTable_Model{1}{$ClassName}}))
109511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # compare virtual tables size in base classes
109521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my $VShift_Old = getVShift($ClassId_Old, 1);
109531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my $VShift_New = getVShift($ClassId_New, 2);
109541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($VShift_Old ne $VShift_New)
109551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # changes in the base class or changes in the list of base classes
109561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my @AllBases_Old = get_base_classes($ClassId_Old, 1, 1);
109571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my @AllBases_New = get_base_classes($ClassId_New, 2, 1);
109581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    ($BNum1, $BNum2) = (1, 1);
10959f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    my %StableBase = map {$Tr_New{$TypeInfo{2}{$_}{"Name"}} => $_} @AllBases_New;
109601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    foreach my $BaseId (@AllBases_Old)
10961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
1096262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        my %BaseType = get_Type($BaseId, 1);
10963f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if(not $StableBase{$Tr_Old{$BaseType{"Name"}}})
109641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        { # lost base
109651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            next;
10966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
109671693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        my $VSize_Old = getVTable_Size($BaseType{"Name"}, 1);
109681693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        my $VSize_New = getVTable_Size($BaseType{"Name"}, 2);
109691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($VSize_Old!=$VSize_New)
10970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
10971850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            foreach my $Symbol (@VFunctions)
10972f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            { # TODO: affected non-virtual methods?
10973f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                                if(not defined $VirtualTable_Model{2}{$ClassName}{$Symbol})
109741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                { # Removed_Virtual_Method, will be registered in mergeVirtualTables()
109751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    next;
10976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                }
10977850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                if($VirtualTable_Model{2}{$ClassName}{$Symbol}-$VirtualTable_Model{1}{$ClassName}{$Symbol}==0)
109781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                { # skip interfaces that have not changed the absolute virtual position
109791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    next;
109801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                }
10981850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                if(not symbolFilter($Symbol, 1, "Affected", $Level)) {
10982850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                    next;
109831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                }
109841693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                                $VTableChanged_M{$BaseType{"Name"}} = 1;
109851693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                                $VTableChanged_M{$ClassName} = 1;
109861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                foreach my $VirtFunc (keys(%{$AddedInt_Virt{$Level}{$BaseType{"Name"}}}))
109871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                { # the reason of the layout change: added virtual functions
109881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    next if($VirtualReplacement{$VirtFunc});
109891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    my $ProblemType = "Added_Virtual_Method";
109901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    if($CompleteSignature{2}{$VirtFunc}{"PureVirt"}) {
109911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                        $ProblemType = "Added_Pure_Virtual_Method";
109921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    }
10993850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                    %{$CompatProblems{$Level}{$Symbol}{$ProblemType}{get_Signature($VirtFunc, 2)}}=(
109941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                        "Type_Name"=>$BaseType{"Name"},
109951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                        "Target"=>get_Signature($VirtFunc, 2)  );
109961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                }
109971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                foreach my $VirtFunc (keys(%{$RemovedInt_Virt{$Level}{$BaseType{"Name"}}}))
109981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                { # the reason of the layout change: removed virtual functions
109991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    next if($VirtualReplacement{$VirtFunc});
110001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    my $ProblemType = "Removed_Virtual_Method";
110011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    if($CompleteSignature{1}{$VirtFunc}{"PureVirt"}) {
110021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                        $ProblemType = "Removed_Pure_Virtual_Method";
110031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    }
11004850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                    %{$CompatProblems{$Level}{$Symbol}{$ProblemType}{get_Signature($VirtFunc, 1)}}=(
110051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                        "Type_Name"=>$BaseType{"Name"},
110061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                        "Target"=>get_Signature($VirtFunc, 1)  );
11007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                }
11008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
11009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
11010ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11011ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isCreatable($$)
11018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
11019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassId, $LibVersion) = @_;
1102062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($AllocableClass{$LibVersion}{$TypeInfo{$LibVersion}{$ClassId}{"Name"}}
11021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or isCopyingClass($ClassId, $LibVersion)) {
11022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
11023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(keys(%{$Class_SubClasses{$LibVersion}{$ClassId}}))
11025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # Fix for incomplete data: if this class has
11026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # a base class then it should also has a constructor
11027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
11028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReturnedClass{$LibVersion}{$ClassId})
11030ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # returned by some method of this class
11031ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # or any other class
11032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
11033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11034ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
11035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11036ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
110371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub isUsedClass($$$)
11038ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
110391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($ClassId, $LibVersion, $Level) = @_;
11040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(keys(%{$ParamClass{$LibVersion}{$ClassId}}))
11041ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # parameter of some exported method
11042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
11043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1104462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $CName = $TypeInfo{$LibVersion}{$ClassId}{"Name"};
1104562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(keys(%{$ClassMethods{$Level}{$LibVersion}{$CName}}))
11046ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # method from target class
11047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
11048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
11050ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11051ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
110521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub mergeVirtualTables($$)
11053ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # check for changes in the virtual table
110541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Interface, $Level) = @_;
110551693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    # affected methods:
11056ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #  - virtual
11057ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #  - pure-virtual
11058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #  - non-virtual
11059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($CompleteSignature{1}{$Interface}{"Data"})
11060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # global data is not affected
11061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
11062ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Class_Id = $CompleteSignature{1}{$Interface}{"Class"};
110641693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not $Class_Id) {
110651693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        return;
110661693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
1106762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $CName = $TypeInfo{1}{$Class_Id}{"Name"};
110681693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(cmpVTables_Real($CName, 1)==0)
110691693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # no changes
110701693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        return;
110711693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
110721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $CheckedTypes{$Level}{$CName} = 1;
110731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Level eq "Binary")
110741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # Binary-level
110751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CompleteSignature{1}{$Interface}{"PureVirt"}
110761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        and not isUsedClass($Class_Id, 1, $Level))
110771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # pure virtuals should not be affected
110780d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko          # if there are no exported methods using this class
110791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return;
110801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
110810d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
110820d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    foreach my $Func (keys(%{$VirtualTable{1}{$CName}}))
110830d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
110840d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(defined $VirtualTable{2}{$CName}{$Func}
110850d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and defined $CompleteSignature{2}{$Func})
110860d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
110870d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(not $CompleteSignature{1}{$Func}{"PureVirt"}
110880d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and $CompleteSignature{2}{$Func}{"PureVirt"})
110890d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            { # became pure virtual
110900d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                %{$CompatProblems{$Level}{$Interface}{"Virtual_Method_Became_Pure"}{$tr_name{$Func}}}=(
110910d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    "Type_Name"=>$CName,
110920d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    "Target"=>get_Signature_M($Func, 1)  );
110930d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $VTableChanged_M{$CName} = 1;
110940d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
110950d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            elsif($CompleteSignature{1}{$Func}{"PureVirt"}
110960d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and not $CompleteSignature{2}{$Func}{"PureVirt"})
110970d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            { # became non-pure virtual
110980d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                %{$CompatProblems{$Level}{$Interface}{"Virtual_Method_Became_Non_Pure"}{$tr_name{$Func}}}=(
110990d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    "Type_Name"=>$CName,
111000d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    "Target"=>get_Signature_M($Func, 1)  );
111010d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $VTableChanged_M{$CName} = 1;
111020d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
111030d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
111040d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
111050d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($Level eq "Binary")
111060d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # Binary-level
111071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        # check virtual table structure
111081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $AddedVFunc (keys(%{$AddedInt_Virt{$Level}{$CName}}))
111091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
111101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next if($Interface eq $AddedVFunc);
111111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next if($VirtualReplacement{$AddedVFunc});
111121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $VPos_Added = $VirtualTable{2}{$CName}{$AddedVFunc};
111131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($CompleteSignature{2}{$AddedVFunc}{"PureVirt"})
111141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # pure virtual methods affect all others (virtual and non-virtual)
111151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Interface}{"Added_Pure_Virtual_Method"}{$tr_name{$AddedVFunc}}}=(
11116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Type_Name"=>$CName,
11117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>get_Signature($AddedVFunc, 2)  );
111181693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $VTableChanged_M{$CName} = 1;
11119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11120dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            elsif(not defined $VirtualTable{1}{$CName}
11121dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            or $VPos_Added>keys(%{$VirtualTable{1}{$CName}}))
111221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # added virtual function at the end of v-table
111231693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                if(not keys(%{$VirtualTable_Model{1}{$CName}}))
111241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # became polymorphous class, added v-table pointer
111251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    %{$CompatProblems{$Level}{$Interface}{"Added_First_Virtual_Method"}{$tr_name{$AddedVFunc}}}=(
11126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Type_Name"=>$CName,
11127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>get_Signature($AddedVFunc, 2)  );
111281693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    $VTableChanged_M{$CName} = 1;
11129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else
11131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
111321693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    my $VSize_Old = getVTable_Size($CName, 1);
111331693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    my $VSize_New = getVTable_Size($CName, 2);
111349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    next if($VSize_Old==$VSize_New); # exception: register as removed and added virtual method
111351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if(isCopyingClass($Class_Id, 1))
111361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # class has no constructors and v-table will be copied by applications, this may affect all methods
111371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        my $ProblemType = "Added_Virtual_Method";
111381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(isLeafClass($Class_Id, 1)) {
111391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemType = "Added_Virtual_Method_At_End_Of_Leaf_Copying_Class";
111401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
111411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Interface}{$ProblemType}{$tr_name{$AddedVFunc}}}=(
111421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Type_Name"=>$CName,
111431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>get_Signature($AddedVFunc, 2)  );
111441693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        $VTableChanged_M{$CName} = 1;
111451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
111461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    else
111471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
111481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        my $ProblemType = "Added_Virtual_Method";
111491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(isLeafClass($Class_Id, 1)) {
111501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemType = "Added_Virtual_Method_At_End_Of_Leaf_Allocable_Class";
111511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
111521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Interface}{$ProblemType}{$tr_name{$AddedVFunc}}}=(
111531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Type_Name"=>$CName,
111541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>get_Signature($AddedVFunc, 2)  );
111551693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        $VTableChanged_M{$CName} = 1;
111561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
111571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
111581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
111591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            elsif($CompleteSignature{1}{$Interface}{"Virt"}
111601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            or $CompleteSignature{1}{$Interface}{"PureVirt"})
111611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
11162dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if(defined $VirtualTable{1}{$CName}
11163dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                and defined $VirtualTable{2}{$CName})
111641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                {
11165dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    my $VPos_Old = $VirtualTable{1}{$CName}{$Interface};
11166dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    my $VPos_New = $VirtualTable{2}{$CName}{$Interface};
11167fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11168dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    if($VPos_Added<=$VPos_Old and $VPos_Old!=$VPos_New)
111691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
11170dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        my @Affected = ($Interface, keys(%{$OverriddenMethods{1}{$Interface}}));
11171dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        foreach my $ASymbol (@Affected)
11172dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        {
11173850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            if(not $CompleteSignature{1}{$ASymbol}{"PureVirt"})
11174850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            {
111759927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                if(not symbolFilter($ASymbol, 1, "Affected", $Level)) {
11176850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                    next;
11177850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                }
11178dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            }
11179dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            $CheckedSymbols{$Level}{$ASymbol} = 1;
11180dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            %{$CompatProblems{$Level}{$ASymbol}{"Added_Virtual_Method"}{$tr_name{$AddedVFunc}}}=(
11181dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                                "Type_Name"=>$CName,
11182dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                                "Target"=>get_Signature($AddedVFunc, 2)  );
1118362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            $VTableChanged_M{$TypeInfo{1}{$CompleteSignature{1}{$ASymbol}{"Class"}}{"Name"}} = 1;
111841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
11185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
111881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            else {
111891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                # safe
111901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
11191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
111921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $RemovedVFunc (keys(%{$RemovedInt_Virt{$Level}{$CName}}))
11193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
111941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next if($VirtualReplacement{$RemovedVFunc});
111951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($RemovedVFunc eq $Interface
111961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and $CompleteSignature{1}{$RemovedVFunc}{"PureVirt"})
111971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # This case is for removed virtual methods
111989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko              # implemented in both versions of a library
111991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                next;
112001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
112011693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if(not keys(%{$VirtualTable_Model{2}{$CName}}))
112021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # became non-polymorphous class, removed v-table pointer
112031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Interface}{"Removed_Last_Virtual_Method"}{$tr_name{$RemovedVFunc}}}=(
112041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    "Type_Name"=>$CName,
112051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    "Target"=>get_Signature($RemovedVFunc, 1)  );
112061693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $VTableChanged_M{$CName} = 1;
112071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
112081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            elsif($CompleteSignature{1}{$Interface}{"Virt"}
112091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            or $CompleteSignature{1}{$Interface}{"PureVirt"})
11210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11211dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if(defined $VirtualTable{1}{$CName} and defined $VirtualTable{2}{$CName})
11212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
11213dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    if(not defined $VirtualTable{1}{$CName}{$Interface}) {
11214dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        next;
11215dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
11216dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    my $VPos_New = -1;
11217dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    if(defined $VirtualTable{2}{$CName}{$Interface})
112181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
11219dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        $VPos_New = $VirtualTable{2}{$CName}{$Interface};
11220dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
11221dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    else
11222dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    {
11223dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        if($Interface ne $RemovedVFunc) {
112241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            next;
112251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
11226dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
11227dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    my $VPos_Removed = $VirtualTable{1}{$CName}{$RemovedVFunc};
11228dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    my $VPos_Old = $VirtualTable{1}{$CName}{$Interface};
11229dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    if($VPos_Removed<=$VPos_Old and $VPos_Old!=$VPos_New)
11230dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    {
11231dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        my @Affected = ($Interface, keys(%{$OverriddenMethods{1}{$Interface}}));
11232dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        foreach my $ASymbol (@Affected)
11233dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        {
11234850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            if(not $CompleteSignature{1}{$ASymbol}{"PureVirt"})
11235850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            {
112369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                if(not symbolFilter($ASymbol, 1, "Affected", $Level)) {
11237850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                    next;
11238850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                }
11239dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            }
11240dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            my $ProblemType = "Removed_Virtual_Method";
11241dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            if($CompleteSignature{1}{$RemovedVFunc}{"PureVirt"}) {
11242dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                                $ProblemType = "Removed_Pure_Virtual_Method";
11243dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            }
11244dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            $CheckedSymbols{$Level}{$ASymbol} = 1;
11245dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            %{$CompatProblems{$Level}{$ASymbol}{$ProblemType}{$tr_name{$RemovedVFunc}}}=(
11246dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                                "Type_Name"=>$CName,
11247dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                                "Target"=>get_Signature($RemovedVFunc, 1)  );
1124862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            $VTableChanged_M{$TypeInfo{1}{$CompleteSignature{1}{$ASymbol}{"Class"}}{"Name"}} = 1;
112491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
11250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
112551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
112561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # Source-level
112571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $AddedVFunc (keys(%{$AddedInt_Virt{$Level}{$CName}}))
112581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
112591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next if($Interface eq $AddedVFunc);
112601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($CompleteSignature{2}{$AddedVFunc}{"PureVirt"})
112611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
112621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Interface}{"Added_Pure_Virtual_Method"}{$tr_name{$AddedVFunc}}}=(
112631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    "Type_Name"=>$CName,
112641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    "Target"=>get_Signature($AddedVFunc, 2)  );
112651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
11266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
112671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $RemovedVFunc (keys(%{$RemovedInt_Virt{$Level}{$CName}}))
11268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
112691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($CompleteSignature{1}{$RemovedVFunc}{"PureVirt"})
11270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
112711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Interface}{"Removed_Pure_Virtual_Method"}{$tr_name{$RemovedVFunc}}}=(
112721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    "Type_Name"=>$CName,
112731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    "Target"=>get_Signature($RemovedVFunc, 1)  );
11274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub find_MemberPair_Pos_byName($$)
11280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
11281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Member_Name, $Pair_Type) = @_;
11282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Member_Name=~s/\A[_]+|[_]+\Z//g;
11283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $MemberPair_Pos (sort {int($a)<=>int($b)} keys(%{$Pair_Type->{"Memb"}}))
11284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
11285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(defined $Pair_Type->{"Memb"}{$MemberPair_Pos})
11286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Name = $Pair_Type->{"Memb"}{$MemberPair_Pos}{"name"};
11288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Name=~s/\A[_]+|[_]+\Z//g;
11289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Name eq $Member_Name) {
11290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return $MemberPair_Pos;
11291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "lost";
11295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub find_MemberPair_Pos_byVal($$)
11298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
11299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Member_Value, $Pair_Type) = @_;
11300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $MemberPair_Pos (sort {int($a)<=>int($b)} keys(%{$Pair_Type->{"Memb"}}))
11301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
11302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(defined $Pair_Type->{"Memb"}{$MemberPair_Pos}
11303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Pair_Type->{"Memb"}{$MemberPair_Pos}{"value"} eq $Member_Value) {
11304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $MemberPair_Pos;
11305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "lost";
11308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11310dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenkomy %Severity_Val=(
11311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "High"=>3,
11312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Medium"=>2,
11313dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    "Low"=>1,
11314dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    "Safe"=>-1
11315dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko);
11316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11317dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenkosub maxSeverity($$)
11318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
11319dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my ($S1, $S2) = @_;
11320dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if(cmpSeverities($S1, $S2)) {
11321dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        return $S1;
11322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
11324dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        return $S2;
11325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11328dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenkosub cmpSeverities($$)
11329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
11330dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my ($S1, $S2) = @_;
11331dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if(not $S1) {
11332dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        return 0;
11333dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
11334dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    elsif(not $S2) {
11335dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        return 1;
11336dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
11337dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return ($Severity_Val{$S1}>$Severity_Val{$S2});
11338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getProblemSeverity($$)
11341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
11342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Level, $Kind) = @_;
11343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $CompatRules{$Level}{$Kind}{"Severity"};
11344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
113468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub isRecurType($$$)
11347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
113488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach (@{$_[2]})
11349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1135062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if( $_->{"T1"} eq $_[0]
1135162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        and $_->{"T2"} eq $_[1] )
11352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
11354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
11357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
113598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub pushType($$$)
11360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
113618f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my %IDs = (
113628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        "T1" => $_[0],
113638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        "T2" => $_[1]
113641693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    );
113658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    push(@{$_[2]}, \%IDs);
11366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isRenamed($$$$$)
11369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
11370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($MemPos, $Type1, $LVersion1, $Type2, $LVersion2) = @_;
11371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Member_Name = $Type1->{"Memb"}{$MemPos}{"name"};
11372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $MemberType_Id = $Type1->{"Memb"}{$MemPos}{"type"};
11373f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %MemberType_Pure = get_PureType($MemberType_Id, $TypeInfo{$LVersion1});
11374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not defined $Type2->{"Memb"}{$MemPos}) {
11375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
11376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1137762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $PairType_Id = $Type2->{"Memb"}{$MemPos}{"type"};
11378f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %PairType_Pure = get_PureType($PairType_Id, $TypeInfo{$LVersion2});
11379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1138062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $Pair_Name = $Type2->{"Memb"}{$MemPos}{"name"};
1138162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $MemberPair_Pos_Rev = ($Member_Name eq $Pair_Name)?$MemPos:find_MemberPair_Pos_byName($Pair_Name, $Type1);
11382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($MemberPair_Pos_Rev eq "lost")
11383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1138462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($MemberType_Pure{"Name"} eq $PairType_Pure{"Name"})
1138562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # base type match
1138662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $Pair_Name;
11387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1138862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($TypeInfo{$LVersion1}{$MemberType_Id}{"Name"} eq $TypeInfo{$LVersion2}{$PairType_Id}{"Name"})
1138962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # exact type match
1139062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $Pair_Name;
11391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1139262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($MemberType_Pure{"Size"} eq $PairType_Pure{"Size"})
1139362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # size match
1139462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $Pair_Name;
11395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1139662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(isReserved($Pair_Name))
1139762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # reserved fields
1139862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $Pair_Name;
11399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
11402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isLastElem($$)
11405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
11406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Pos, $TypeRef) = @_;
11407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $TypeRef->{"Memb"}{$Pos}{"name"};
11408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Name=~/last|count|max|total/i)
11409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # GST_LEVEL_COUNT, GST_RTSP_ELAST
11410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
11411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Name=~/END|NLIMITS\Z/)
11413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # __RLIMIT_NLIMITS
11414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
11415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Name=~/\AN[A-Z](.+)[a-z]+s\Z/
11417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Pos+1==keys(%{$TypeRef->{"Memb"}}))
11418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # NImageFormats, NColorRoles
11419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
11420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
11422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub nonComparable($$)
11425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
11426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($T1, $T2) = @_;
11427fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11428fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $N1 = $T1->{"Name"};
11429fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $N2 = $T2->{"Name"};
11430fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11431fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    $N1=~s/\A(struct|union|enum) //;
11432fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    $N2=~s/\A(struct|union|enum) //;
11433fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11434fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($N1 ne $N2
11435fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    and not isAnon($N1)
11436fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    and not isAnon($N2))
11437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # different names
11438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($T1->{"Type"} ne "Pointer"
11439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        or $T2->{"Type"} ne "Pointer")
11440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # compare base types
11441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
11442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11443fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($N1!~/\Avoid\s*\*/
11444fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        and $N2=~/\Avoid\s*\*/)
11445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
11447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($T1->{"Type"} ne $T2->{"Type"})
11450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # different types
11451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($T1->{"Type"} eq "Class"
11452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $T2->{"Type"} eq "Struct")
11453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # "class" to "struct"
11454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
11455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($T2->{"Type"} eq "Class"
11457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $T1->{"Type"} eq "Struct")
11458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # "struct" to "class"
11459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
11460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
11462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # "class" to "enum"
11463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # "union" to "class"
11464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          #  ...
11465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
11466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
11469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11471fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub isOpaque($)
11472fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko{
11473fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $T = $_[0];
11474fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(not defined $T->{"Memb"})
11475fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
11476fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return 1;
11477fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
11478fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return 0;
11479fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko}
11480fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11481fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub removeVPtr($)
11482fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko{ # support for old ABI dumps
11483fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $TPtr = $_[0];
11484fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my @Pos = sort {int($a)<=>int($b)} keys(%{$TPtr->{"Memb"}});
11485fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($#Pos>=1)
11486fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
11487fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        foreach my $Pos (0 .. $#Pos-1)
11488fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
11489fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            %{$TPtr->{"Memb"}{$Pos}} = %{$TPtr->{"Memb"}{$Pos+1}};
11490fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
11491fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        delete($TPtr->{"Memb"}{$#Pos});
11492fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
11493fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko}
11494fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
1149562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub mergeTypes($$$)
11496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1149762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($Type1_Id, $Type2_Id, $Level) = @_;
1149862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return () if(not $Type1_Id or not $Type2_Id);
11499ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my (%Sub_SubProblems, %SubProblems) = ();
1150062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($Cache{"mergeTypes"}{$Level}{$Type1_Id}{$Type2_Id})
11501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # already merged
1150262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return %{$Cache{"mergeTypes"}{$Level}{$Type1_Id}{$Type2_Id}};
11503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1150462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type1 = get_Type($Type1_Id, 1);
1150562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type2 = get_Type($Type2_Id, 2);
115061693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not $Type1{"Name"} or not $Type2{"Name"}) {
115071693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        return ();
115081693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
11509fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11510fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    $CheckedTypes{$Level}{$Type1{"Name"}} = 1;
11511f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type1_Pure = get_PureType($Type1_Id, $TypeInfo{1});
11512f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type2_Pure = get_PureType($Type2_Id, $TypeInfo{2});
11513fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    $CheckedTypes{$Level}{$Type1_Pure{"Name"}} = 1;
11514fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11515fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($Type1_Pure{"Name"} eq $Type2_Pure{"Name"})
11516fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
11517fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Type1_Pure{"Type"}=~/Struct|Union/
11518fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        and $Type2_Pure{"Type"}=~/Struct|Union/)
11519fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
11520fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(isOpaque(\%Type2_Pure) and not isOpaque(\%Type1_Pure))
11521fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
11522fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                %{$SubProblems{"Type_Became_Opaque"}{$Type1_Pure{"Name"}}}=(
11523fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    "Target"=>$Type1_Pure{"Name"},
11524fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    "Type_Name"=>$Type1_Pure{"Name"}  );
11525fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11526fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                %{$Cache{"mergeTypes"}{$Level}{$Type1_Id}{$Type2_Id}} = %SubProblems;
11527fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                return %SubProblems;
11528fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
11529fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
11530fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
11531fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11532177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(not $Type1_Pure{"Size"}
11533177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    or not $Type2_Pure{"Size"})
11534850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    { # including a case when "class Class { ... };" changed to "class Class;"
11535177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not defined $Type1_Pure{"Memb"} or not defined $Type2_Pure{"Memb"}
11536177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        or index($Type1_Pure{"Name"}, "<")==-1 or index($Type2_Pure{"Name"}, "<")==-1)
11537177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # NOTE: template instances have no size
11538177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return ();
11539177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
11540850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
115418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(isRecurType($Type1_Pure{"Tid"}, $Type2_Pure{"Tid"}, \@RecurTypes))
11542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # skip recursive declarations
11543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ();
11544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $Type1_Pure{"Name"} or not $Type2_Pure{"Name"});
11546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if($SkipTypes{1}{$Type1_Pure{"Name"}});
11547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if($SkipTypes{1}{$Type1{"Name"}});
11548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11549fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($Type1_Pure{"Type"}=~/Class|Struct/ and $Type2_Pure{"Type"}=~/Class|Struct/)
11550fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # support for old ABI dumps
11551fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko      # _vptr field added in 3.0
11552fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(not checkDump(1, "3.0") and checkDump(2, "3.0"))
11553fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
11554fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(defined $Type2_Pure{"Memb"}
11555fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            and $Type2_Pure{"Memb"}{0}{"name"} eq "_vptr")
11556fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
11557fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(keys(%{$Type2_Pure{"Memb"}})==1) {
11558fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    delete($Type2_Pure{"Memb"}{0});
11559fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
11560fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else {
11561fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    removeVPtr(\%Type2_Pure);
11562fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
11563fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
11564fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
11565fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(checkDump(1, "3.0") and not checkDump(2, "3.0"))
11566fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
11567fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(defined $Type1_Pure{"Memb"}
11568fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            and $Type1_Pure{"Memb"}{0}{"name"} eq "_vptr")
11569fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
11570fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(keys(%{$Type1_Pure{"Memb"}})==1) {
11571fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    delete($Type1_Pure{"Memb"}{0});
11572fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
11573fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else {
11574fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    removeVPtr(\%Type1_Pure);
11575fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
11576fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
11577fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
11578fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
11579fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
1158062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Typedef_1 = goToFirst($Type1{"Tid"}, 1, "Typedef");
1158162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Typedef_2 = goToFirst($Type2{"Tid"}, 2, "Typedef");
11582fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11583dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if(not $UseOldDumps and %Typedef_1 and %Typedef_2
11584dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    and $Typedef_1{"Type"} eq "Typedef" and $Typedef_2{"Type"} eq "Typedef"
11585dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    and $Typedef_1{"Name"} eq $Typedef_2{"Name"})
11586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
11587f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %Base_1 = get_OneStep_BaseType($Typedef_1{"Tid"}, $TypeInfo{1});
11588f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %Base_2 = get_OneStep_BaseType($Typedef_2{"Tid"}, $TypeInfo{2});
11589850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Base_1{"Name"} ne $Base_2{"Name"})
11590850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
11591850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if(differentDumps("G")
11592850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            or differentDumps("V"))
11593850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # different GCC versions or different dumps
11594850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $Base_1{"Name"} = uncover_typedefs($Base_1{"Name"}, 1);
11595850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $Base_2{"Name"} = uncover_typedefs($Base_2{"Name"}, 2);
11596850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                # std::__va_list and __va_list
11597850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $Base_1{"Name"}=~s/\A(\w+::)+//;
11598850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $Base_2{"Name"}=~s/\A(\w+::)+//;
115999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                $Base_1{"Name"} = formatName($Base_1{"Name"}, "T");
116009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                $Base_2{"Name"} = formatName($Base_2{"Name"}, "T");
11601850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
11602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Base_1{"Name"}!~/anon\-/ and $Base_2{"Name"}!~/anon\-/
11604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Base_1{"Name"} ne $Base_2{"Name"})
11605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
116061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Binary"
116071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and $Type1{"Size"} ne $Type2{"Size"})
11608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$SubProblems{"DataType_Size"}{$Typedef_1{"Name"}}}=(
11610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>$Typedef_1{"Name"},
11611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Type_Name"=>$Typedef_1{"Name"},
11612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Old_Size"=>$Type1{"Size"}*$BYTE_SIZE,
11613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "New_Size"=>$Type2{"Size"}*$BYTE_SIZE  );
11614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
116158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my %Base1_Pure = get_PureType($Base_1{"Tid"}, $TypeInfo{1});
116168f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my %Base2_Pure = get_PureType($Base_2{"Tid"}, $TypeInfo{2});
11617fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(tNameLock($Base_1{"Tid"}, $Base_2{"Tid"}))
116188f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
11619fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(diffTypes($Base1_Pure{"Tid"}, $Base2_Pure{"Tid"}, $Level))
11620fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
11621fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Typedef_BaseType_Format"}{$Typedef_1{"Name"}}}=(
11622fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Target"=>$Typedef_1{"Name"},
11623fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Type_Name"=>$Typedef_1{"Name"},
11624fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Old_Value"=>$Base_1{"Name"},
11625fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "New_Value"=>$Base_2{"Name"}  );
11626fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
11627fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else
11628fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
11629fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Typedef_BaseType"}{$Typedef_1{"Name"}}}=(
11630fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Target"=>$Typedef_1{"Name"},
11631fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Type_Name"=>$Typedef_1{"Name"},
11632fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Old_Value"=>$Base_1{"Name"},
11633fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "New_Value"=>$Base_2{"Name"}  );
11634fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
116358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
11636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(nonComparable(\%Type1_Pure, \%Type2_Pure))
11639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # different types (reported in detectTypeChange(...))
1164074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my $TT1 = $Type1_Pure{"Type"};
1164174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my $TT2 = $Type2_Pure{"Type"};
1164274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1164374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if($TT1 ne $TT2
1164474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        and $TT1!~/Intrinsic|Pointer|Ref|Typedef/)
11645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # different type of the type
1164674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $Short1 = $Type1_Pure{"Name"};
1164774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $Short2 = $Type2_Pure{"Name"};
1164874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1164974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $Short1=~s/\A\Q$TT1\E //ig;
1165074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $Short2=~s/\A\Q$TT2\E //ig;
1165174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1165274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if($Short1 eq $Short2)
1165374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            {
1165474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                %{$SubProblems{"DataType_Type"}{$Type1_Pure{"Name"}}}=(
1165574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    "Target"=>$Type1_Pure{"Name"},
1165674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    "Type_Name"=>$Type1_Pure{"Name"},
1165774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    "Old_Value"=>lc($Type1_Pure{"Type"}),
1165874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    "New_Value"=>lc($Type2_Pure{"Type"})  );
1165974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
11660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1166162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        %{$Cache{"mergeTypes"}{$Level}{$Type1_Id}{$Type2_Id}} = %SubProblems;
11662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return %SubProblems;
11663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
116648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    pushType($Type1_Pure{"Tid"}, $Type2_Pure{"Tid"}, \@RecurTypes);
11665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(($Type1_Pure{"Name"} eq $Type2_Pure{"Name"}
11666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or (isAnon($Type1_Pure{"Name"}) and isAnon($Type2_Pure{"Name"})))
11667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Type1_Pure{"Type"}=~/\A(Struct|Class|Union)\Z/)
11668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # checking size
116691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Binary"
116701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        and $Type1_Pure{"Size"} ne $Type2_Pure{"Size"})
11671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $ProblemKind = "DataType_Size";
11673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type1_Pure{"Type"} eq "Class"
116741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and keys(%{$ClassMethods{$Level}{1}{$Type1_Pure{"Name"}}}))
11675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(isCopyingClass($Type1_Pure{"Tid"}, 1)) {
11677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ProblemKind = "Size_Of_Copying_Class";
11678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                elsif($AllocableClass{1}{$Type1_Pure{"Name"}})
11680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
11681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(int($Type2_Pure{"Size"})>int($Type1_Pure{"Size"})) {
11682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ProblemKind = "Size_Of_Allocable_Class_Increased";
11683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11684fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    else
11685fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    {
11686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        # descreased size of allocable class
11687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        # it has no special effects
11688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            %{$SubProblems{$ProblemKind}{$Type1_Pure{"Name"}}}=(
11692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                "Target"=>$Type1_Pure{"Name"},
11693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                "Type_Name"=>$Type1_Pure{"Name"},
11694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                "Old_Size"=>$Type1_Pure{"Size"}*$BYTE_SIZE,
11695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                "New_Size"=>$Type2_Pure{"Size"}*$BYTE_SIZE,
11696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                "InitialType_Type"=>$Type1_Pure{"Type"}  );
11697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11699fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(defined $Type1_Pure{"BaseType"}
11700fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    and defined $Type2_Pure{"BaseType"})
117010d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # checking base types
11702fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        %Sub_SubProblems = mergeTypes($Type1_Pure{"BaseType"}, $Type2_Pure{"BaseType"}, $Level);
11703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Sub_SubProblemType (keys(%Sub_SubProblems))
11704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Sub_SubLocation (keys(%{$Sub_SubProblems{$Sub_SubProblemType}}))
11706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Attr (keys(%{$Sub_SubProblems{$Sub_SubProblemType}{$Sub_SubLocation}})) {
11708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $SubProblems{$Sub_SubProblemType}{$Sub_SubLocation}{$Attr} = $Sub_SubProblems{$Sub_SubProblemType}{$Sub_SubLocation}{$Attr};
11709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $SubProblems{$Sub_SubProblemType}{$Sub_SubLocation}{"InitialType_Type"} = $Type1_Pure{"Type"};
11711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my (%AddedField, %RemovedField, %RenamedField, %RenamedField_Rev, %RelatedField, %RelatedField_Rev) = ();
11715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %NameToPosA = map {$Type1_Pure{"Memb"}{$_}{"name"}=>$_} keys(%{$Type1_Pure{"Memb"}});
11716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %NameToPosB = map {$Type2_Pure{"Memb"}{$_}{"name"}=>$_} keys(%{$Type2_Pure{"Memb"}});
11717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Member_Pos (sort {int($a) <=> int($b)} keys(%{$Type1_Pure{"Memb"}}))
11718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # detect removed and renamed fields
11719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Member_Name = $Type1_Pure{"Memb"}{$Member_Pos}{"name"};
11720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Member_Name);
11721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey 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);
11722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MemberPair_Pos eq "lost")
11723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type2_Pure{"Type"}=~/\A(Struct|Class|Union)\Z/)
11725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(isUnnamed($Member_Name))
11727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # support for old-version dumps
11728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  # unnamed fields have been introduced in the ACC 1.23 (dump 2.1 format)
1172962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if(not checkDump(2, "2.1")) {
11730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        next;
11731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(my $RenamedTo = isRenamed($Member_Pos, \%Type1_Pure, 1, \%Type2_Pure, 2))
11734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # renamed
11735082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                    $RenamedField{$Member_Pos} = $RenamedTo;
11736082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                    $RenamedField_Rev{$NameToPosB{$RenamedTo}} = $Member_Name;
11737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else
11739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # removed
11740082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                    $RemovedField{$Member_Pos} = 1;
11741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Type1_Pure{"Type"} eq "Enum")
11744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Member_Value1 = $Type1_Pure{"Memb"}{$Member_Pos}{"value"};
11746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next if($Member_Value1 eq "");
11747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $MemberPair_Pos = find_MemberPair_Pos_byVal($Member_Value1, \%Type2_Pure);
11748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($MemberPair_Pos ne "lost")
11749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # renamed
11750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $RenamedTo = $Type2_Pure{"Memb"}{$MemberPair_Pos}{"name"};
11751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $MemberPair_Pos_Rev = find_MemberPair_Pos_byName($RenamedTo, \%Type1_Pure);
11752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($MemberPair_Pos_Rev eq "lost")
11753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
11754082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                        $RenamedField{$Member_Pos} = $RenamedTo;
11755082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                        $RenamedField_Rev{$NameToPosB{$RenamedTo}} = $Member_Name;
11756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    else {
11758082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                        $RemovedField{$Member_Pos} = 1;
11759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else
11762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # removed
11763082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                    $RemovedField{$Member_Pos} = 1;
11764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
11768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # related
11769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $RelatedField{$Member_Pos} = $MemberPair_Pos;
11770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $RelatedField_Rev{$MemberPair_Pos} = $Member_Pos;
11771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Member_Pos (sort {int($a) <=> int($b)} keys(%{$Type2_Pure{"Memb"}}))
11774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # detect added fields
11775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Member_Name = $Type2_Pure{"Memb"}{$Member_Pos}{"name"};
11776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Member_Name);
11777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey 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);
11778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MemberPair_Pos eq "lost")
11779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(isUnnamed($Member_Name))
11781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # support for old-version dumps
117821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            # unnamed fields have been introduced in the ACC 1.23 (dump 2.1 format)
1178362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(not checkDump(1, "2.1")) {
11784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
11785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type2_Pure{"Type"}=~/\A(Struct|Class|Union|Enum)\Z/)
11788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not $RenamedField_Rev{$Member_Pos})
11790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # added
11791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $AddedField{$Member_Pos}=1;
11792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type2_Pure{"Type"}=~/\A(Struct|Class)\Z/)
11797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # detect moved fields
11798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my (%RelPos, %RelPosName, %AbsPos) = ();
11799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Pos = 0;
11800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Member_Pos (sort {int($a) <=> int($b)} keys(%{$Type1_Pure{"Memb"}}))
11801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # relative positions in 1st version
11802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Member_Name = $Type1_Pure{"Memb"}{$Member_Pos}{"name"};
11803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(not $Member_Name);
11804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $RemovedField{$Member_Pos})
11805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # old type without removed fields
11806082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                $RelPos{1}{$Member_Name} = $Pos;
11807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $RelPosName{1}{$Pos} = $Member_Name;
11808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $AbsPos{1}{$Pos++} = $Member_Pos;
11809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Pos = 0;
11812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Member_Pos (sort {int($a) <=> int($b)} keys(%{$Type2_Pure{"Memb"}}))
11813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # relative positions in 2nd version
11814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Member_Name = $Type2_Pure{"Memb"}{$Member_Pos}{"name"};
11815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(not $Member_Name);
11816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $AddedField{$Member_Pos})
11817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # new type without added fields
11818082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                $RelPos{2}{$Member_Name} = $Pos;
11819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $RelPosName{2}{$Pos} = $Member_Name;
11820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $AbsPos{2}{$Pos++} = $Member_Pos;
11821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Member_Name (keys(%{$RelPos{1}}))
11824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $RPos1 = $RelPos{1}{$Member_Name};
11826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $AbsPos1 = $NameToPosA{$Member_Name};
11827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Member_Name2 = $Member_Name;
11828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my $RenamedTo = $RenamedField{$AbsPos1})
11829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # renamed
11830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Member_Name2 = $RenamedTo;
11831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $RPos2 = $RelPos{2}{$Member_Name2};
11833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($RPos2 ne "" and $RPos1 ne $RPos2)
11834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # different relative positions
11835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $AbsPos2 = $NameToPosB{$Member_Name2};
11836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($AbsPos1 ne $AbsPos2)
11837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # different absolute positions
11838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $ProblemType = "Moved_Field";
11839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(not isPublic(\%Type1_Pure, $AbsPos1))
11840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # may change layout and size of type
118411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($Level eq "Source") {
118421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            next;
118431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
11844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ProblemType = "Moved_Private_Field";
11845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
118461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Level eq "Binary"
118471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    and $Type1_Pure{"Size"} ne $Type2_Pure{"Size"})
11848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # affected size
1184962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        my $MemSize1 = $TypeInfo{1}{$Type1_Pure{"Memb"}{$AbsPos1}{"type"}}{"Size"};
11850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $MovedAbsPos = $AbsPos{1}{$RPos2};
1185162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        my $MemSize2 = $TypeInfo{1}{$Type1_Pure{"Memb"}{$MovedAbsPos}{"type"}}{"Size"};
11852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($MemSize1 ne $MemSize2) {
11853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType .= "_And_Size";
11854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
11855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($ProblemType eq "Moved_Private_Field") {
11857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        next;
11858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{$ProblemType}{$Member_Name}}=(
11860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
11861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"},
11862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Value"=>$RPos1,
11863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Value"=>$RPos2 );
11864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Member_Pos (sort {int($a) <=> int($b)} keys(%{$Type1_Pure{"Memb"}}))
118691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # check older fields, public and private
11870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Member_Name = $Type1_Pure{"Memb"}{$Member_Pos}{"name"};
11871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Member_Name);
11872082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko        next if($Member_Name eq "_vptr");
11873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $RenamedTo = $RenamedField{$Member_Pos})
11874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # renamed
118758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(defined $Constants{2}{$Member_Name})
118768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
118778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if($Constants{2}{$Member_Name}{"Value"} eq $RenamedTo)
118788f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                { # define OLD NEW
118798f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    next; # Safe
118808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
118818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
118828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
11883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type2_Pure{"Type"}=~/\A(Struct|Class|Union)\Z/)
11884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(isPublic(\%Type1_Pure, $Member_Pos))
11886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
11887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{"Renamed_Field"}{$Member_Name}}=(
11888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
11889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"},
11890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Value"=>$Member_Name,
11891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Value"=>$RenamedTo  );
11892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
118939927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                elsif(isReserved($Member_Name))
118949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                {
118959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    %{$SubProblems{"Used_Reserved_Field"}{$Member_Name}}=(
118969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        "Target"=>$Member_Name,
118979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"},
118989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        "Old_Value"=>$Member_Name,
118999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        "New_Value"=>$RenamedTo  );
119009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
11901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Type1_Pure{"Type"} eq "Enum")
11903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$SubProblems{"Enum_Member_Name"}{$Type1_Pure{"Memb"}{$Member_Pos}{"value"}}}=(
11905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>$Type1_Pure{"Memb"}{$Member_Pos}{"value"},
11906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Type_Name"=>$Type1_Pure{"Name"},
11907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Old_Value"=>$Member_Name,
11908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "New_Value"=>$RenamedTo  );
11909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($RemovedField{$Member_Pos})
11912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # removed
11913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type2_Pure{"Type"}=~/\A(Struct|Class)\Z/)
11914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $ProblemType = "Removed_Field";
11916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not isPublic(\%Type1_Pure, $Member_Pos)
119171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                or isUnnamed($Member_Name))
119181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                {
119191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Level eq "Source") {
119201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        next;
119211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
11922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ProblemType = "Removed_Private_Field";
11923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
119241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary"
11925fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and not isMemPadded($Member_Pos, -1, \%Type1_Pure, \%RemovedField, $TypeInfo{1}, getArch(1), $WORD_SIZE{1}))
11926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
11927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(my $MNum = isAccessible(\%Type1_Pure, \%RemovedField, $Member_Pos+1, -1))
11928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # affected fields
11929fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey 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}))
11930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        { # changed offset
11931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType .= "_And_Layout";
11932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
11933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($Type1_Pure{"Size"} ne $Type2_Pure{"Size"})
11935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # affected size
11936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ProblemType .= "_And_Size";
11937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($ProblemType eq "Removed_Private_Field") {
11940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
11941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$SubProblems{$ProblemType}{$Member_Name}}=(
11943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>$Member_Name,
1194474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    "Type_Name"=>$Type1_Pure{"Name"}  );
11945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Type2_Pure{"Type"} eq "Union")
11947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
119481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary"
119491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                and $Type1_Pure{"Size"} ne $Type2_Pure{"Size"})
11950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
11951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{"Removed_Union_Field_And_Size"}{$Member_Name}}=(
11952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
1195374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"}  );
11954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else
11956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
11957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{"Removed_Union_Field"}{$Member_Name}}=(
11958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
1195974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"}  );
11960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Type1_Pure{"Type"} eq "Enum")
11963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$SubProblems{"Enum_Member_Removed"}{$Member_Name}}=(
11965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>$Member_Name,
11966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Type_Name"=>$Type1_Pure{"Name"},
11967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Old_Value"=>$Member_Name  );
11968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
11971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # changed
11972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $MemberPair_Pos = $RelatedField{$Member_Pos};
11973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type1_Pure{"Type"} eq "Enum")
11974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Member_Value1 = $Type1_Pure{"Memb"}{$Member_Pos}{"value"};
11976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next if($Member_Value1 eq "");
11977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Member_Value2 = $Type2_Pure{"Memb"}{$MemberPair_Pos}{"value"};
11978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next if($Member_Value2 eq "");
11979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Member_Value1 ne $Member_Value2)
11980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
11981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $ProblemType = "Enum_Member_Value";
11982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(isLastElem($Member_Pos, \%Type1_Pure)) {
11983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ProblemType = "Enum_Last_Member_Value";
11984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11985fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if($SkipConstants{1}{$Member_Name}) {
11986fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $ProblemType = "Enum_Private_Member_Value";
11987fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
11988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{$ProblemType}{$Member_Name}}=(
11989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
11990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"},
11991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Value"=>$Member_Value1,
11992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Value"=>$Member_Value2  );
11993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Type2_Pure{"Type"}=~/\A(Struct|Class|Union)\Z/)
11996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11997fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Access1 = $Type1_Pure{"Memb"}{$Member_Pos}{"access"};
11998fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Access2 = $Type2_Pure{"Memb"}{$MemberPair_Pos}{"access"};
11999fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
12000fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Access1 ne "private"
12001fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and $Access2 eq "private")
12002fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
12003fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Field_Became_Private"}{$Member_Name}}=(
12004fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Target"=>$Member_Name,
12005fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"});
12006fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
12007fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                elsif($Access1 ne "protected"
12008fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and $Access1 ne "private"
12009fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and $Access2 eq "protected")
12010fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
12011fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Field_Became_Protected"}{$Member_Name}}=(
12012fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Target"=>$Member_Name,
12013fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"});
12014fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
12015fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
12016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $MemberType1_Id = $Type1_Pure{"Memb"}{$Member_Pos}{"type"};
12017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $MemberType2_Id = $Type2_Pure{"Memb"}{$MemberPair_Pos}{"type"};
1201862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $SizeV1 = $TypeInfo{1}{$MemberType1_Id}{"Size"}*$BYTE_SIZE;
12019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(my $BSize1 = $Type1_Pure{"Memb"}{$Member_Pos}{"bitfield"}) {
12020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $SizeV1 = $BSize1;
12021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1202262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $SizeV2 = $TypeInfo{2}{$MemberType2_Id}{"Size"}*$BYTE_SIZE;
12023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(my $BSize2 = $Type2_Pure{"Memb"}{$MemberPair_Pos}{"bitfield"}) {
12024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $SizeV2 = $BSize2;
12025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1202662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $MemberType1_Name = $TypeInfo{1}{$MemberType1_Id}{"Name"};
1202762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $MemberType2_Name = $TypeInfo{2}{$MemberType2_Id}{"Name"};
120281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary"
120291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                and $SizeV1 ne $SizeV2)
12030ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
12031ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($MemberType1_Name eq $MemberType2_Name or (isAnon($MemberType1_Name) and isAnon($MemberType2_Name))
12032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    or ($Type1_Pure{"Memb"}{$Member_Pos}{"bitfield"} and $Type2_Pure{"Memb"}{$MemberPair_Pos}{"bitfield"}))
12033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # field size change (including anon-structures and unions)
12034ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                      # - same types
12035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                      # - unnamed types
12036ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                      # - bitfields
12037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $ProblemType = "Field_Size";
12038ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if(not isPublic(\%Type1_Pure, $Member_Pos)
12039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        or isUnnamed($Member_Name))
12040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        { # should not be accessed by applications, goes to "Low Severity"
12041ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                          # example: "abidata" members in GStreamer types
12042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType = "Private_".$ProblemType;
12043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
12044fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if(not isMemPadded($Member_Pos, $TypeInfo{2}{$MemberType2_Id}{"Size"}*$BYTE_SIZE, \%Type1_Pure, \%RemovedField, $TypeInfo{1}, getArch(1), $WORD_SIZE{1}))
12045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        { # check an effect
12046fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            if($Type2_Pure{"Type"} ne "Union"
12047fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            and my $MNum = isAccessible(\%Type1_Pure, \%RemovedField, $Member_Pos+1, -1))
12048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            { # public fields after the current
12049fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey 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}))
12050ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                { # changed offset
12051ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                    $ProblemType .= "_And_Layout";
12052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                }
12053ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
12054ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if($Type1_Pure{"Size"} ne $Type2_Pure{"Size"}) {
12055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                $ProblemType .= "_And_Type_Size";
12056ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
12057ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
12058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($ProblemType eq "Private_Field_Size")
12059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        { # private field size with no effect
12060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType = "";
12061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
1206246bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                        if($ProblemType eq "Field_Size")
1206346bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                        {
1206446bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                            if($Type1_Pure{"Type"}=~/Union|Struct/ and $SizeV1<$SizeV2)
1206546bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                            { # Low severity
1206646bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                                $ProblemType = "Struct_Field_Size_Increased";
1206746bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                            }
1206846bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                        }
12069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($ProblemType)
12070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        { # register a problem
12071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            %{$SubProblems{$ProblemType}{$Member_Name}}=(
12072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                "Target"=>$Member_Name,
12073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                "Type_Name"=>$Type1_Pure{"Name"},
12074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                "Old_Size"=>$SizeV1,
12075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                "New_Size"=>$SizeV2);
12076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
12077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12078ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Type1_Pure{"Memb"}{$Member_Pos}{"bitfield"}
12080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                or $Type2_Pure{"Memb"}{$MemberPair_Pos}{"bitfield"})
12081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # do NOT check bitfield type changes
12082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
12083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1208462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(checkDump(1, "2.13") and checkDump(2, "2.13"))
120850d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                {
120860d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    if(not $Type1_Pure{"Memb"}{$Member_Pos}{"mutable"}
120870d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    and $Type2_Pure{"Memb"}{$MemberPair_Pos}{"mutable"})
120880d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    {
120890d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        %{$SubProblems{"Field_Became_Mutable"}{$Member_Name}}=(
120900d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Target"=>$Member_Name,
1209174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                            "Type_Name"=>$Type1_Pure{"Name"});
120920d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
120930d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    elsif($Type1_Pure{"Memb"}{$Member_Pos}{"mutable"}
120940d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    and not $Type2_Pure{"Memb"}{$MemberPair_Pos}{"mutable"})
120950d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    {
12096fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        %{$SubProblems{"Field_Became_Non_Mutable"}{$Member_Name}}=(
120970d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Target"=>$Member_Name,
1209874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                            "Type_Name"=>$Type1_Pure{"Name"});
120990d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
121000d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
121011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %Sub_SubProblems = detectTypeChange($MemberType1_Id, $MemberType2_Id, "Field", $Level);
12102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $ProblemType (keys(%Sub_SubProblems))
12103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
12104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $Old_Value = $Sub_SubProblems{$ProblemType}{"Old_Value"};
12105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $New_Value = $Sub_SubProblems{$ProblemType}{"New_Value"};
12106fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
12107fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    # quals
12108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($ProblemType eq "Field_Type"
12109fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    or $ProblemType eq "Field_Type_And_Size"
12110fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    or $ProblemType eq "Field_Type_Format")
12111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
1211262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        if(checkDump(1, "2.6") and checkDump(2, "2.6"))
12113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
12114fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            if(addedQual($Old_Value, $New_Value, "volatile")) {
121150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                %{$Sub_SubProblems{"Field_Became_Volatile"}} = %{$Sub_SubProblems{$ProblemType}};
121160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            }
12117fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            elsif(removedQual($Old_Value, $New_Value, "volatile")) {
12118fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                                %{$Sub_SubProblems{"Field_Became_Non_Volatile"}} = %{$Sub_SubProblems{$ProblemType}};
12119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
12120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
121210d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        if(my $RA = addedQual($Old_Value, $New_Value, "const"))
121220d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        {
121230d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            if($RA==2) {
121240d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                %{$Sub_SubProblems{"Field_Added_Const"}} = %{$Sub_SubProblems{$ProblemType}};
121250d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            }
121260d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            else {
121270d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                %{$Sub_SubProblems{"Field_Became_Const"}} = %{$Sub_SubProblems{$ProblemType}};
121280d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            }
121290d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        }
121300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        elsif(my $RR = removedQual($Old_Value, $New_Value, "const"))
121310d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        {
121320d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            if($RR==2) {
121330d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                %{$Sub_SubProblems{"Field_Removed_Const"}} = %{$Sub_SubProblems{$ProblemType}};
121340d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            }
121350d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            else {
12136fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                                %{$Sub_SubProblems{"Field_Became_Non_Const"}} = %{$Sub_SubProblems{$ProblemType}};
121370d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            }
12138fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
12139fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
12140fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
12141fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
12142fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Level eq "Source")
12143fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
12144fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    foreach my $ProblemType (keys(%Sub_SubProblems))
12145fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    {
12146fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        my $Old_Value = $Sub_SubProblems{$ProblemType}{"Old_Value"};
12147fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        my $New_Value = $Sub_SubProblems{$ProblemType}{"New_Value"};
12148fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
12149fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if($ProblemType eq "Field_Type")
12150fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        {
12151fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            if(cmpBTypes($Old_Value, $New_Value, 1, 2)) {
121520d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                delete($Sub_SubProblems{$ProblemType});
121530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            }
121540d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        }
12155ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12157fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
12158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $ProblemType (keys(%Sub_SubProblems))
12159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
12160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $ProblemType_Init = $ProblemType;
12161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($ProblemType eq "Field_Type_And_Size")
121621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # Binary
12163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if(not isPublic(\%Type1_Pure, $Member_Pos)
12164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        or isUnnamed($Member_Name)) {
12165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType = "Private_".$ProblemType;
12166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
12167fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if(not isMemPadded($Member_Pos, $TypeInfo{2}{$MemberType2_Id}{"Size"}*$BYTE_SIZE, \%Type1_Pure, \%RemovedField, $TypeInfo{1}, getArch(1), $WORD_SIZE{1}))
12168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        { # check an effect
12169fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            if($Type2_Pure{"Type"} ne "Union"
12170fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            and my $MNum = isAccessible(\%Type1_Pure, \%RemovedField, $Member_Pos+1, -1))
12171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            { # public fields after the current
12172fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey 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}))
12173ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                { # changed offset
12174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                    $ProblemType .= "_And_Layout";
12175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                }
12176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
12177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if($Type1_Pure{"Size"} ne $Type2_Pure{"Size"}) {
12178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                $ProblemType .= "_And_Type_Size";
12179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
12180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
12181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    else
12183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
12184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if(not isPublic(\%Type1_Pure, $Member_Pos)
12185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        or isUnnamed($Member_Name)) {
12186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            next;
12187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
12188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($ProblemType eq "Private_Field_Type_And_Size")
12190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # private field change with no effect
12191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        next;
12192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{$ProblemType}{$Member_Name}}=(
12194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
1219574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"});
1219674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
12197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    foreach my $Attr (keys(%{$Sub_SubProblems{$ProblemType_Init}}))
12198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # other properties
12199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $SubProblems{$ProblemType}{$Member_Name}{$Attr} = $Sub_SubProblems{$ProblemType_Init}{$Attr};
12200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not isPublic(\%Type1_Pure, $Member_Pos))
12203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # do NOT check internal type changes
12204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
12205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($MemberType1_Id and $MemberType2_Id)
12207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {# checking member type changes (replace)
1220862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    %Sub_SubProblems = mergeTypes($MemberType1_Id, $MemberType2_Id, $Level);
12209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    foreach my $Sub_SubProblemType (keys(%Sub_SubProblems))
12210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
12211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        foreach my $Sub_SubLocation (keys(%{$Sub_SubProblems{$Sub_SubProblemType}}))
12212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
12213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            my $NewLocation = ($Sub_SubLocation)?$Member_Name."->".$Sub_SubLocation:$Member_Name;
12214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $SubProblems{$Sub_SubProblemType}{$NewLocation}{"IsInTypeInternals"}=1;
12215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            foreach my $Attr (keys(%{$Sub_SubProblems{$Sub_SubProblemType}{$Sub_SubLocation}})) {
12216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                $SubProblems{$Sub_SubProblemType}{$NewLocation}{$Attr} = $Sub_SubProblems{$Sub_SubProblemType}{$Sub_SubLocation}{$Attr};
12217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
12218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if($Sub_SubLocation!~/\-\>/) {
12219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                $SubProblems{$Sub_SubProblemType}{$NewLocation}{"Start_Type_Name"} = $MemberType1_Name;
12220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
12221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
12222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Member_Pos (sort {int($a) <=> int($b)} keys(%{$Type2_Pure{"Memb"}}))
12228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # checking added members, public and private
12229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Member_Name = $Type2_Pure{"Memb"}{$Member_Pos}{"name"};
12230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Member_Name);
12231082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko        next if($Member_Name eq "_vptr");
12232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($AddedField{$Member_Pos})
12233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # added
12234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type2_Pure{"Type"}=~/\A(Struct|Class)\Z/)
12235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
12236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $ProblemType = "Added_Field";
12237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not isPublic(\%Type2_Pure, $Member_Pos)
122381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                or isUnnamed($Member_Name))
122391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                {
122401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Level eq "Source") {
122411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        next;
122421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
12243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ProblemType = "Added_Private_Field";
12244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
122451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary"
12246fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and not isMemPadded($Member_Pos, -1, \%Type2_Pure, \%AddedField, $TypeInfo{2}, getArch(2), $WORD_SIZE{2}))
12247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
12248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(my $MNum = isAccessible(\%Type2_Pure, \%AddedField, $Member_Pos, -1))
12249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # public fields after the current
12250fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey 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}))
12251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        { # changed offset
12252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType .= "_And_Layout";
12253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
12254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($Type1_Pure{"Size"} ne $Type2_Pure{"Size"}) {
12256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ProblemType .= "_And_Size";
12257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($ProblemType eq "Added_Private_Field")
12260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # skip added private fields
12261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
12262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$SubProblems{$ProblemType}{$Member_Name}}=(
12264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>$Member_Name,
1226574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    "Type_Name"=>$Type1_Pure{"Name"});
12266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Type2_Pure{"Type"} eq "Union")
12268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
122691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary"
122701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                and $Type1_Pure{"Size"} ne $Type2_Pure{"Size"})
12271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
12272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{"Added_Union_Field_And_Size"}{$Member_Name}}=(
12273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
1227474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"});
12275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else
12277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
12278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{"Added_Union_Field"}{$Member_Name}}=(
12279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
1228074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"});
12281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Type2_Pure{"Type"} eq "Enum")
12284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
12285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Member_Value = $Type2_Pure{"Memb"}{$Member_Pos}{"value"};
12286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next if($Member_Value eq "");
12287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$SubProblems{"Added_Enum_Member"}{$Member_Name}}=(
12288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>$Member_Name,
12289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Type_Name"=>$Type2_Pure{"Name"},
1229074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    "New_Value"=>$Member_Value);
12291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1229462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    %{$Cache{"mergeTypes"}{$Level}{$Type1_Id}{$Type2_Id}} = %SubProblems;
12295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    pop(@RecurTypes);
12296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return %SubProblems;
12297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
12299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isUnnamed($) {
12300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $_[0]=~/\Aunnamed\d+\Z/;
12301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1230374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkosub get_ShortClass($$)
12304dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko{
12305dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
1230674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $TypeName = $TypeInfo{$LibVersion}{$TypeId}{"Name"};
1230774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($TypeInfo{$LibVersion}{$TypeId}{"Type"}!~/Intrinsic|Class|Struct|Union|Enum/) {
1230874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $TypeName = uncover_typedefs($TypeName, $LibVersion);
1230974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
1231062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $NameSpace = $TypeInfo{$LibVersion}{$TypeId}{"NameSpace"}) {
1231174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $TypeName=~s/\A(struct |)\Q$NameSpace\E\:\://g;
12312dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
12313dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return $TypeName;
12314dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko}
12315dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko
1231662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub goToFirst($$$)
12317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1231862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $LibVersion, $Type_Type) = @_;
123191693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return () if(not $TypeId);
1232062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"goToFirst"}{$TypeId}{$LibVersion}{$Type_Type}) {
1232162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return %{$Cache{"goToFirst"}{$TypeId}{$LibVersion}{$Type_Type}};
12322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1232362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return () if(not $TypeInfo{$LibVersion}{$TypeId});
1232462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type = %{$TypeInfo{$LibVersion}{$TypeId}};
12325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $Type{"Type"});
12326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type{"Type"} ne $Type_Type)
12327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
12328fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return () if(not $Type{"BaseType"});
12329fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        %Type = goToFirst($Type{"BaseType"}, $LibVersion, $Type_Type);
12330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1233162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    $Cache{"goToFirst"}{$TypeId}{$LibVersion}{$Type_Type} = \%Type;
12332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return %Type;
12333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
12335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TypeSpecAttributes = (
12336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Const" => 1,
12337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Volatile" => 1,
12338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ConstVolatile" => 1,
12339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Restrict" => 1,
12340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Typedef" => 1
12341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
12342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1234362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub get_PureType($$)
12344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
12345f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my ($TypeId, $Info) = @_;
12346f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(not $TypeId or not $Info
12347f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    or not $Info->{$TypeId}) {
12348f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        return ();
12349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12350f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(defined $Cache{"get_PureType"}{$TypeId}{$Info}) {
12351f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        return %{$Cache{"get_PureType"}{$TypeId}{$Info}};
12352f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
12353f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type = %{$Info->{$TypeId}};
12354fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return %Type if(not $Type{"BaseType"});
12355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TypeSpecAttributes{$Type{"Type"}}) {
12356fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        %Type = get_PureType($Type{"BaseType"}, $Info);
12357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12358f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    $Cache{"get_PureType"}{$TypeId}{$Info} = \%Type;
12359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return %Type;
12360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1236262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub get_PLevel($$)
12363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1236462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
12365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not $TypeId);
1236662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"get_PLevel"}{$TypeId}{$LibVersion}) {
1236762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"get_PLevel"}{$TypeId}{$LibVersion};
12368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1236962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return 0 if(not $TypeInfo{$LibVersion}{$TypeId});
1237062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type = %{$TypeInfo{$LibVersion}{$TypeId}};
12371fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return 1 if($Type{"Type"}=~/FuncPtr|FieldPtr/);
12372fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $PLevel = 0;
12373fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($Type{"Type"} =~/Pointer|Ref|FuncPtr|FieldPtr/) {
12374fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $PLevel += 1;
12375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12376fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return $PLevel if(not $Type{"BaseType"});
12377fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    $PLevel += get_PLevel($Type{"BaseType"}, $LibVersion);
12378fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    $Cache{"get_PLevel"}{$TypeId}{$LibVersion} = $PLevel;
12379fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return $PLevel;
12380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1238262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub get_BaseType($$)
12383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1238462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
12385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $TypeId);
1238662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"get_BaseType"}{$TypeId}{$LibVersion}) {
1238762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return %{$Cache{"get_BaseType"}{$TypeId}{$LibVersion}};
12388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1238962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return () if(not $TypeInfo{$LibVersion}{$TypeId});
1239062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type = %{$TypeInfo{$LibVersion}{$TypeId}};
12391fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return %Type if(not $Type{"BaseType"});
12392fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    %Type = get_BaseType($Type{"BaseType"}, $LibVersion);
1239362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    $Cache{"get_BaseType"}{$TypeId}{$LibVersion} = \%Type;
12394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return %Type;
12395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1239762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub get_BaseTypeQual($$)
12398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1239962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
12400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $TypeId);
1240162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "" if(not $TypeInfo{$LibVersion}{$TypeId});
1240262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type = %{$TypeInfo{$LibVersion}{$TypeId}};
12403fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return "" if(not $Type{"BaseType"});
12404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Qual = "";
12405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type{"Type"} eq "Pointer") {
12406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Qual .= "*";
12407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Type{"Type"} eq "Ref") {
12409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Qual .= "&";
12410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Type{"Type"} eq "ConstVolatile") {
12412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Qual .= "const volatile";
12413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Type{"Type"} eq "Const"
12415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $Type{"Type"} eq "Volatile"
12416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $Type{"Type"} eq "Restrict") {
12417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Qual .= lc($Type{"Type"});
12418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12419fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $BQual = get_BaseTypeQual($Type{"BaseType"}, $LibVersion);
12420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $BQual.$Qual;
12421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1242362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub get_OneStep_BaseType($$)
12424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
12425f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my ($TypeId, $Info) = @_;
12426f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(not $TypeId or not $Info
12427f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    or not $Info->{$TypeId}) {
12428f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        return ();
12429f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
12430f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type = %{$Info->{$TypeId}};
12431fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return %Type if(not $Type{"BaseType"});
12432fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(my $BTid = $Type{"BaseType"})
12433f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    {
12434f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($Info->{$BTid}) {
12435f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            return %{$Info->{$BTid}};
12436f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
12437f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        else { # something is going wrong
12438f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            return ();
12439f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
12440f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
12441f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    else {
12442f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        return %Type;
12443f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
12444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1244662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub get_Type($$)
12447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1244862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
12449dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return () if(not $TypeId);
1245062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return () if(not $TypeInfo{$LibVersion}{$TypeId});
1245162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return %{$TypeInfo{$LibVersion}{$TypeId}};
12452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
12454989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenkosub isPrivateData($)
124550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{ # non-public global data
12456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Symbol = $_[0];
12457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Symbol=~/\A(_ZGV|_ZTI|_ZTS|_ZTT|_ZTV|_ZTC|_ZThn|_ZTv0_n)/);
12458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1246001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenkosub isInLineInst($$$) {
1246101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    return (isTemplateInstance(@_) and not isTemplateSpec(@_));
1246201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko}
1246301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
1246401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenkosub isTemplateInstance($$$)
12465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1246601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my ($Symbol, $SInfo, $LibVersion) = @_;
1246762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($CheckObjectsOnly)
1246862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
1246962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Symbol!~/\A(_Z|\?)/) {
1247062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return 0;
1247162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1247262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $Signature = $tr_name{$Symbol})
1247362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
1247462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(index($Signature,">")==-1) {
1247562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return 0;
1247662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
1247762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $ShortName = substr($Signature, 0, find_center($Signature, "(")))
1247862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
1247901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                if(index($ShortName,"<")!=-1
1248001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                and index($ShortName,">")!=-1) {
1248162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    return 1;
1248262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
1248362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
1248462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1248562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
1248662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    else
1248762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
1248801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(my $ClassId = $SInfo->{"Class"})
1248962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
1249062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $ClassName = $TypeInfo{$LibVersion}{$ClassId}{"Name"})
1249162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
1249262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(index($ClassName,"<")!=-1) {
1249362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    return 1;
1249462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
1249562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
1249662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1249701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(my $ShortName = $SInfo->{"ShortName"})
1249862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
1249901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if(index($ShortName,"<")!=-1
1250001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            and index($ShortName,">")!=-1) {
1250162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return 1;
1250262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
1250362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1250462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
1250562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return 0;
12506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1250801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenkosub isTemplateSpec($$$)
12509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1251001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my ($Symbol, $SInfo, $LibVersion) = @_;
1251101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(my $ClassId = $SInfo->{"Class"})
12512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1251362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($TypeInfo{$LibVersion}{$ClassId}{"Spec"})
12514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # class specialization
12515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
12516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1251701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        elsif($SInfo->{"Spec"})
12518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # method specialization
12519ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
12520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
12523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
125251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub symbolFilter($$$$)
12526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # some special cases when the symbol cannot be imported
125271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Symbol, $LibVersion, $Type, $Level) = @_;
12528989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(isPrivateData($Symbol))
12529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # non-public global data
12530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
12531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($CheckObjectsOnly) {
12533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0 if($Symbol=~/\A(_init|_fini)\Z/);
12534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1253562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($CheckHeadersOnly and not checkDump($LibVersion, "2.7"))
12536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps in --headers-only mode
12537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Pos (keys(%{$CompleteSignature{$LibVersion}{$Symbol}{"Param"}}))
12538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
12539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my $Pid = $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$Pos}{"type"})
12540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
1254162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $PType = $TypeInfo{$LibVersion}{$Pid}{"Type"};
12542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not $PType or $PType eq "Unknown") {
12543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    return 0;
12544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12548850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($Type=~/Affected/)
12549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
12550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $ClassId = $CompleteSignature{$LibVersion}{$Symbol}{"Class"};
12551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SkipSymbols{$LibVersion}{$Symbol})
12552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # user defined symbols to ignore
12553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
12554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $NameSpace = $CompleteSignature{$LibVersion}{$Symbol}{"NameSpace"};
12556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $NameSpace and $ClassId)
12557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # class methods have no "NameSpace" attribute
1255862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $NameSpace = $TypeInfo{$LibVersion}{$ClassId}{"NameSpace"};
12559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($NameSpace)
12561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # user defined namespaces to ignore
12562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($SkipNameSpaces{$LibVersion}{$NameSpace}) {
12563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return 0;
12564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $NS (keys(%{$SkipNameSpaces{$LibVersion}}))
12566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # nested namespaces
12567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($NameSpace=~/\A\Q$NS\E(\:\:|\Z)/) {
12568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    return 0;
12569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $Header = $CompleteSignature{$LibVersion}{$Symbol}{"Header"})
12573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1257462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $Skip = skipHeader($Header, $LibVersion))
12575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # --skip-headers or <skip_headers> (not <skip_including>)
12576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Skip==1) {
12577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    return 0;
12578ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SymbolsListPath and not $SymbolsList{$Symbol})
12582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # user defined symbols
12583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
12584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12585fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($SkipSymbolsListPath and $SkipSymbolsList{$Symbol})
12586fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # user defined symbols
12587fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            return 0;
12588fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
12589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($AppPath and not $SymbolsList_App{$Symbol})
12590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # user defined symbols (in application)
12591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
12592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12593850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(not selectSymbol($Symbol, $CompleteSignature{$LibVersion}{$Symbol}, $Level, $LibVersion))
12594850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # non-target symbols
12595850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            return 0;
12596850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
125971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Binary")
12598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1259962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($CheckObjectsOnly)
1260062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
1260101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                if(isTemplateInstance($Symbol, $CompleteSignature{$LibVersion}{$Symbol}, $LibVersion)) {
1260262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    return 0;
1260362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
1260462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
1260562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            else
126061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
1260762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($CompleteSignature{$LibVersion}{$Symbol}{"InLine"}
1260801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                or isInLineInst($Symbol, $CompleteSignature{$LibVersion}{$Symbol}, $LibVersion))
1260962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
1261062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($ClassId and $CompleteSignature{$LibVersion}{$Symbol}{"Virt"})
1261162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    { # inline virtual methods
1261262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        if($Type=~/InlineVirt/) {
1261362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            return 1;
1261462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        }
1261562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        my $Allocable = (not isCopyingClass($ClassId, $LibVersion));
1261662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        if(not $Allocable)
1261762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        { # check bases
1261862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            foreach my $DCId (get_sub_classes($ClassId, $LibVersion, 1))
1261962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            {
1262062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                if(not isCopyingClass($DCId, $LibVersion))
1262162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                { # exists a derived class without default c-tor
1262262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                    $Allocable=1;
1262362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                    last;
1262462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                }
126251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            }
12626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
1262762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        if(not $Allocable) {
1262862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            return 0;
1262962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        }
12630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
1263162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    else
1263262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    { # inline non-virtual methods
126331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        return 0;
126341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
12635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1;
12640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
12642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub mergeImpl()
12643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
12644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $DiffCmd = get_CmdPath("diff");
12645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $DiffCmd) {
12646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Not_Found", "can't find \"diff\"");
12647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Interface (sort keys(%{$Symbol_Library{1}}))
12649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # implementation changes
12650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($CompleteSignature{1}{$Interface}{"Private"});
12651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $CompleteSignature{1}{$Interface}{"Header"} and not $CheckObjectsOnly);
12652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Symbol_Library{2}{$Interface} and not $Symbol_Library{2}{$SymVer{2}{$Interface}});
12653850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(not symbolFilter($Interface, 1, "Affected", "Binary")) {
12654850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            next;
12655850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
126561693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $Impl1 = canonifyImpl($Interface_Impl{1}{$Interface});
12657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Impl1);
126581693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $Impl2 = canonifyImpl($Interface_Impl{2}{$Interface});
12659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Impl2);
12660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Impl1 ne $Impl2)
12661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
12662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            writeFile("$TMP_DIR/impl1", $Impl1);
12663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            writeFile("$TMP_DIR/impl2", $Impl2);
12664a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            my $Diff = `$DiffCmd -rNau \"$TMP_DIR/impl1\" \"$TMP_DIR/impl2\"`;
12665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Diff=~s/(---|\+\+\+).+\n//g;
12666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Diff=~s/[ ]{3,}/ /g;
12667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Diff=~s/\n\@\@/\n \n\@\@/g;
12668a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            unlink("$TMP_DIR/impl1");
12669a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            unlink("$TMP_DIR/impl2");
126708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            %{$CompatProblems_Impl{$Interface}}=(
12671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                "Diff" => get_CodeView($Diff)  );
12672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12674850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
12675850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
12676850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %Interface_Impl = ();
12677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
126791693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub canonifyImpl($)
12680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
12681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $FuncBody=  $_[0];
12682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $FuncBody);
12683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $FuncBody=~s/0x[a-f\d]+/0x?/g;# addr
12684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $FuncBody=~s/((\A|\n)[a-z]+[\t ]+)[a-f\d]+([^x]|\Z)/$1?$3/g;# call, jump
12685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $FuncBody=~s/# [a-f\d]+ /# ? /g;# call, jump
12686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $FuncBody=~s/%([a-z]+[a-f\d]*)/\%reg/g;# registers
12687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($FuncBody=~s/\nnop[ \t]*(\n|\Z)/$1/g){};# empty op
12688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $FuncBody=~s/<.+?\.cpp.+?>/<name.cpp>/g;
12689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $FuncBody=~s/(\A|\n)[a-f\d]+ </$1? </g;# 5e74 <_ZN...
12690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $FuncBody=~s/\.L\d+/.L/g;
12691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $FuncBody=~s/#(-?)\d+/#$1?/g;# r3, [r3, #120]
12692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $FuncBody=~s/[\n]{2,}/\n/g;
12693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $FuncBody;
12694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
12696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_CodeView($)
12697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
12698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Code = $_[0];
12699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $View = "";
12700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Line (split(/\n/, $Code))
12701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
12702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Line=~s/\A(\+|-)/$1 /g)
12703dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        { # bold line
12704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $View .= "<tr><td><b>".htmlSpecChars($Line)."</b></td></tr>\n";
12705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
12707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $View .= "<tr><td>".htmlSpecChars($Line)."</td></tr>\n";
12708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "<table class='code_view'>$View</table>\n";
12711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
12713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getImplementations($$)
12714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
12715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($LibVersion, $Path) = @_;
12716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(not $LibVersion or not -e $Path);
12717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup eq "macos")
12718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
12719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $OtoolCmd = get_CmdPath("otool");
12720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $OtoolCmd) {
12721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"otool\"");
12722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $CurInterface = "";
12724a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        foreach my $Line (split(/\n/, `$OtoolCmd -tv \"$Path\" 2>\"$TMP_DIR/null\"`))
12725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
12726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Line=~/\A\s*_(\w+)\s*:/i) {
12727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $CurInterface = $1;
12728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Line=~/\A\s*[\da-z]+\s+(.+?)\Z/i) {
1273062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $Interface_Impl{$LibVersion}{$CurInterface} .= $1."\n";
12731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
12735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
12736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $ObjdumpCmd = get_CmdPath("objdump");
12737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $ObjdumpCmd) {
12738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"objdump\"");
12739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $CurInterface = "";
12741a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        foreach my $Line (split(/\n/, `$ObjdumpCmd -d \"$Path\" 2>\"$TMP_DIR/null\"`))
12742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
12743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Line=~/\A[\da-z]+\s+<(\w+)>/i) {
12744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $CurInterface = $1;
12745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
12747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # x86:    51fa:(\t)89 e5               (\t)mov    %esp,%ebp
12748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # arm:    5020:(\t)e24cb004(\t)sub(\t)fp, ip, #4(\t); 0x4
12749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Line=~/\A\s*[a-f\d]+:\s+([a-f\d]+\s+)+([a-z]+\s+.*?)\s*(;.*|)\Z/i) {
1275062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $Interface_Impl{$LibVersion}{$CurInterface} .= $2."\n";
12751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
127571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub detectAdded($)
12758ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
127591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
12760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Symbol (keys(%{$Symbol_Library{2}}))
12761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
12762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(link_symbol($Symbol, 1, "+Deps"))
12763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # linker can find a new symbol
12764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # in the old-version library
12765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # So, it's not a new symbol
12766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
12767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $VSym = $SymVer{2}{$Symbol}
1276962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        and index($Symbol,"\@")==-1) {
12770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
12771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
127721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $AddedInt{$Level}{$Symbol} = 1;
12773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
127761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub detectRemoved($)
12777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
127781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
12779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Symbol (keys(%{$Symbol_Library{1}}))
12780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
12781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CheckObjectsOnly) {
127821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $CheckedSymbols{"Binary"}{$Symbol} = 1;
12783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(link_symbol($Symbol, 2, "+Deps"))
12785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # linker can find an old symbol
12786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # in the new-version library
12787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
12788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $VSym = $SymVer{1}{$Symbol}
1279062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        and index($Symbol,"\@")==-1) {
12791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
12792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
127931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $RemovedInt{$Level}{$Symbol} = 1;
12794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
127971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub mergeLibs($)
12798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
127991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
128001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$AddedInt{$Level}}))
12801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # checking added symbols
12802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($CompleteSignature{2}{$Symbol}{"Private"});
12803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $CompleteSignature{2}{$Symbol}{"Header"} and not $CheckObjectsOnly);
12804c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko        next if(not symbolFilter($Symbol, 2, "Affected + InlineVirt", $Level));
128051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        %{$CompatProblems{$Level}{$Symbol}{"Added_Symbol"}{""}}=();
12806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
128071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$RemovedInt{$Level}}))
12808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # checking removed symbols
12809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($CompleteSignature{1}{$Symbol}{"Private"});
12810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $CompleteSignature{1}{$Symbol}{"Header"} and not $CheckObjectsOnly);
128119927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(index($Symbol, "_ZTV")==0)
12812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # skip v-tables for templates, that should not be imported by applications
12813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if($tr_name{$Symbol}=~/</);
12814dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(my $CName = $VTableClass{$Symbol})
12815dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
12816dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if(not keys(%{$ClassMethods{$Level}{1}{$CName}}))
12817dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                { # vtables for "private" classes
128180d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                  # use case: vtable for QDragManager (Qt 4.5.3 to 4.6.0) became HIDDEN symbol
12819dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    next;
12820dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                }
12821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
12824c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko            next if(not symbolFilter($Symbol, 1, "Affected + InlineVirt", $Level));
12825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CompleteSignature{1}{$Symbol}{"PureVirt"})
12827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # symbols for pure virtual methods cannot be called by clients
12828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
12829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
128301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        %{$CompatProblems{$Level}{$Symbol}{"Removed_Symbol"}{""}}=();
12831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1283462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub checkDump($$)
128351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
1283662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($LibVersion, $V) = @_;
1283762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"checkDump"}{$LibVersion}{$V}) {
1283862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"checkDump"}{$LibVersion}{$V};
1283962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
1284062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return ($Cache{"checkDump"}{$LibVersion}{$V} = (not $UsedDump{$LibVersion}{"V"} or cmpVersions($UsedDump{$LibVersion}{"V"}, $V)>=0));
128411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
128421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
128431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub detectAdded_H($)
12844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
128451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
12846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$CompleteSignature{2}}))
12847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
128481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Source")
128491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # remove symbol version
128501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my ($SN, $SS, $SV) = separate_symbol($Symbol);
128511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Symbol=$SN;
12852b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko
12853b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if($CompleteSignature{2}{$Symbol}{"Artificial"})
12854b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            { # skip artificial constructors
12855b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko                next;
12856b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            }
128571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
128581693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(not $CompleteSignature{2}{$Symbol}{"Header"}
128591693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        or not $CompleteSignature{2}{$Symbol}{"MnglName"}) {
128601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
128611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
1286262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($ExtendedSymbols{$Symbol}) {
12863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
12864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
128651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not defined $CompleteSignature{1}{$Symbol}
128661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or not $CompleteSignature{1}{$Symbol}{"MnglName"})
128671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
128681693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if($UsedDump{2}{"SrcBin"})
128691693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            {
1287062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($UsedDump{1}{"BinOnly"} or not checkDump(1, "2.11"))
128711693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                { # support for old and different (!) ABI dumps
128721693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    if(not $CompleteSignature{2}{$Symbol}{"Virt"}
128731693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    and not $CompleteSignature{2}{$Symbol}{"PureVirt"})
128741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
128751693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        if($CheckHeadersOnly)
12876850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        {
12877850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            if(my $Lang = $CompleteSignature{2}{$Symbol}{"Lang"})
12878850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            {
12879850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                if($Lang eq "C")
12880850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                { # support for old ABI dumps: missed extern "C" functions
12881850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                    next;
12882850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                }
12883850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            }
128841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
128851693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        else
128861693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        {
128871693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            if(not link_symbol($Symbol, 2, "-Deps"))
128880d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            { # skip added inline symbols and const global data
128891693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                                next;
128901693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            }
128911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
128921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
128931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
128941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
128951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $AddedInt{$Level}{$Symbol} = 1;
12896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
129001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub detectRemoved_H($)
12901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
129021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
12903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$CompleteSignature{1}}))
12904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
129051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Source")
129061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # remove symbol version
129071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my ($SN, $SS, $SV) = separate_symbol($Symbol);
129081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Symbol=$SN;
129091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
129101693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(not $CompleteSignature{1}{$Symbol}{"Header"}
129111693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        or not $CompleteSignature{1}{$Symbol}{"MnglName"}) {
129121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
129131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
1291462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($ExtendedSymbols{$Symbol}) {
12915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
12916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
129171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not defined $CompleteSignature{2}{$Symbol}
129181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or not $CompleteSignature{2}{$Symbol}{"MnglName"})
12919850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
129201693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if($UsedDump{1}{"SrcBin"})
129211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
1292262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($UsedDump{2}{"BinOnly"} or not checkDump(2, "2.11"))
12923850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # support for old and different (!) ABI dumps
129241693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    if(not $CompleteSignature{1}{$Symbol}{"Virt"}
129251693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    and not $CompleteSignature{1}{$Symbol}{"PureVirt"})
129261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
129271693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        if($CheckHeadersOnly)
129281693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        { # skip all removed symbols
12929850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            if(my $Lang = $CompleteSignature{1}{$Symbol}{"Lang"})
12930850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            {
12931850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                if($Lang eq "C")
12932850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                { # support for old ABI dumps: missed extern "C" functions
12933850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                    next;
12934850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                }
12935850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            }
129361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
129371693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        else
129381693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        {
129391693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            if(not link_symbol($Symbol, 1, "-Deps"))
129401693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            { # skip removed inline symbols
129411693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                                next;
129421693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            }
129431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
129441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
129451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
129461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
12947b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if(not checkDump(1, "2.15"))
12948b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            {
12949b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko                if($Symbol=~/_IT_E\Z/)
12950b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko                { # _ZN28QExplicitlySharedDataPointerI22QSslCertificatePrivateEC1IT_EERKS_IT_E
12951b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko                    next;
12952b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko                }
12953b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            }
129549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(not $CompleteSignature{1}{$Symbol}{"Class"})
129559927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
129569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if(my $Short = $CompleteSignature{1}{$Symbol}{"ShortName"})
129579927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                {
129589927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if(defined $Constants{2}{$Short})
129599927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    {
129609927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        my $Val = $Constants{2}{$Short}{"Value"};
129619927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        if(defined $Func_ShortName{2}{$Val})
129629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        { # old name defined to new
129639927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            next;
129649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
129659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    }
129669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
129679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
129689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
129691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $RemovedInt{$Level}{$Symbol} = 1;
129701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Source")
129711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # search for a source-compatible equivalent
129721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                setAlternative($Symbol, $Level);
129731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
12974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
129781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub mergeHeaders($)
12979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
129801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
129811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$AddedInt{$Level}}))
12982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # checking added symbols
12983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($CompleteSignature{2}{$Symbol}{"PureVirt"});
129849927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        next if($CompleteSignature{2}{$Symbol}{"Private"});
129859927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        next if(not symbolFilter($Symbol, 2, "Affected", $Level));
12986850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Level eq "Binary")
12987850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
12988850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($CompleteSignature{2}{$Symbol}{"InLine"})
12989850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
12990850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(not $CompleteSignature{2}{$Symbol}{"Virt"})
12991850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # skip inline non-virtual functions
12992850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    next;
12993850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
12994850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
129951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
129961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
129971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # Source
129981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($SourceAlternative_B{$Symbol}) {
129991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                next;
130001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
130011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
130021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        %{$CompatProblems{$Level}{$Symbol}{"Added_Symbol"}{""}}=();
13003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
130041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$RemovedInt{$Level}}))
13005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # checking removed symbols
13006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($CompleteSignature{1}{$Symbol}{"PureVirt"});
130079927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        next if($CompleteSignature{1}{$Symbol}{"Private"});
130089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        next if(not symbolFilter($Symbol, 1, "Affected", $Level));
13009850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Level eq "Binary")
13010850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
13011850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($CompleteSignature{1}{$Symbol}{"InLine"})
13012850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
13013850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(not $CompleteSignature{1}{$Symbol}{"Virt"})
13014850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # skip inline non-virtual functions
13015850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    next;
13016850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
13017850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
130181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
130191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
130201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # Source
130210d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(my $Alt = $SourceAlternative{$Symbol})
130220d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
130230d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if(defined $CompleteSignature{1}{$Alt}
130240d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                and $CompleteSignature{1}{$Symbol}{"Const"})
130250d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                {
1302662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $Cid = $CompleteSignature{1}{$Symbol}{"Class"};
130270d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    %{$CompatProblems{$Level}{$Symbol}{"Removed_Const_Overload"}{$tr_name{$Symbol}}}=(
1302862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        "Type_Name"=>$TypeInfo{1}{$Cid}{"Name"},
1302974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        "Target"=>get_Signature($Alt, 1));
130300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
130310d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                else
130320d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                { # do NOT show removed symbol
130330d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    next;
130340d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
130351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
130361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
130371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        %{$CompatProblems{$Level}{$Symbol}{"Removed_Symbol"}{""}}=();
13038ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
13039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
13040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
13041ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub addParamNames($)
13042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
13043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibraryVersion = $_[0];
13044ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(not keys(%AddIntParams));
13045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $SecondVersion = $LibraryVersion==1?2:1;
13046ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Interface (sort keys(%{$CompleteSignature{$LibraryVersion}}))
13047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
13048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not keys(%{$AddIntParams{$Interface}}));
13049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $ParamPos (sort {int($a)<=>int($b)} keys(%{$CompleteSignature{$LibraryVersion}{$Interface}{"Param"}}))
13050850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # add absent parameter names
13051ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $ParamName = $CompleteSignature{$LibraryVersion}{$Interface}{"Param"}{$ParamPos}{"name"};
13052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ParamName=~/\Ap\d+\Z/ and my $NewParamName = $AddIntParams{$Interface}{$ParamPos})
13053850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # names from the external file
13054ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(defined $CompleteSignature{$SecondVersion}{$Interface}
13055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                and defined $CompleteSignature{$SecondVersion}{$Interface}{"Param"}{$ParamPos})
13056ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
13057ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($CompleteSignature{$SecondVersion}{$Interface}{"Param"}{$ParamPos}{"name"}=~/\Ap\d+\Z/) {
13058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $CompleteSignature{$LibraryVersion}{$Interface}{"Param"}{$ParamPos}{"name"} = $NewParamName;
13059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
13062ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $CompleteSignature{$LibraryVersion}{$Interface}{"Param"}{$ParamPos}{"name"} = $NewParamName;
13063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13064ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
13067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
13068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
13069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detectChangedTypedefs()
13070989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko{ # detect changed typedefs to show
13071989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko  # correct function signatures
13072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Typedef (keys(%{$Typedef_BaseName{1}}))
13073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
13074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Typedef);
13075989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        my $BName1 = $Typedef_BaseName{1}{$Typedef};
13076989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if(not $BName1 or isAnon($BName1)) {
13077989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            next;
13078989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
13079989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        my $BName2 = $Typedef_BaseName{2}{$Typedef};
13080989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if(not $BName2 or isAnon($BName2)) {
13081989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            next;
13082989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
13083989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($BName1 ne $BName2) {
13084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ChangedTypedef{$Typedef} = 1;
13085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
13087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
13088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
13089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_symbol_suffix($$)
13090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
130911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Symbol, $Full) = @_;
130921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($SN, $SO, $SV) = separate_symbol($Symbol);
13093570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $Symbol=$SN; # remove version
130941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Signature = $tr_name{$Symbol};
130951693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $Suffix = substr($Signature, find_center($Signature, "("));
13096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Full) {
13097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Suffix=~s/(\))\s*(const volatile|volatile const|const|volatile)\Z/$1/g;
13098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
13099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Suffix;
13100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
13101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
13102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_symbol_prefix($$)
13103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
13104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
13105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $ShortName = $CompleteSignature{$LibVersion}{$Symbol}{"ShortName"};
13106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $ClassId = $CompleteSignature{$LibVersion}{$Symbol}{"Class"})
13107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # methods
1310862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $ShortName = $TypeInfo{$LibVersion}{$ClassId}{"Name"}."::".$ShortName;
13109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
13110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $ShortName;
13111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
13112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
131131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub setAlternative($)
131141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
131151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Symbol = $_[0];
131161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $PSymbol = $Symbol;
131171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(not defined $CompleteSignature{2}{$PSymbol}
131181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or (not $CompleteSignature{2}{$PSymbol}{"MnglName"}
131191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    and not $CompleteSignature{2}{$PSymbol}{"ShortName"}))
131201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # search for a pair
13121dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if(my $ShortName = $CompleteSignature{1}{$PSymbol}{"ShortName"})
131221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
13123dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if($CompleteSignature{1}{$PSymbol}{"Data"})
131241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
13125dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if($PSymbol=~s/L(\d+$ShortName(E)\Z)/$1/
13126dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                or $PSymbol=~s/(\d+$ShortName(E)\Z)/L$1/)
131271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                {
131281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if(defined $CompleteSignature{2}{$PSymbol}
131291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    and $CompleteSignature{2}{$PSymbol}{"MnglName"})
131301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
131311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $SourceAlternative{$Symbol} = $PSymbol;
131321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $SourceAlternative_B{$PSymbol} = $Symbol;
131331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(not defined $CompleteSignature{1}{$PSymbol}
131341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        or not $CompleteSignature{1}{$PSymbol}{"MnglName"}) {
131351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $SourceReplacement{$Symbol} = $PSymbol;
131361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
131371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
131381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
13139dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
13140dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            else
13141dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
13142dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                foreach my $Sp ("KV", "VK", "K", "V")
13143dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                {
13144dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    if($PSymbol=~s/\A_ZN$Sp/_ZN/
13145dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    or $PSymbol=~s/\A_ZN/_ZN$Sp/)
13146dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    {
13147dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        if(defined $CompleteSignature{2}{$PSymbol}
13148dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        and $CompleteSignature{2}{$PSymbol}{"MnglName"})
13149dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        {
13150dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            $SourceAlternative{$Symbol} = $PSymbol;
13151dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            $SourceAlternative_B{$PSymbol} = $Symbol;
13152dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            if(not defined $CompleteSignature{1}{$PSymbol}
13153dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            or not $CompleteSignature{1}{$PSymbol}{"MnglName"}) {
13154dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                                $SourceReplacement{$Symbol} = $PSymbol;
13155dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            }
13156dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        }
13157dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
13158dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    $PSymbol = $Symbol;
13159dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                }
131601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
131611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
131621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
131631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    return "";
131641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
131651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
131660d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub getSymKind($$)
131670d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
131680d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
131690d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($CompleteSignature{$LibVersion}{$Symbol}{"Data"})
131700d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
131710d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return "Global_Data";
131720d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
131730d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    elsif($CompleteSignature{$LibVersion}{$Symbol}{"Class"})
131740d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
131750d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return "Method";
131760d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
131770d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return "Function";
131780d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
131790d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
131808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub mergeSymbols($)
13181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
131821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
13183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %SubProblems = ();
13184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
131851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    mergeBases($Level);
131861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
13187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %AddedOverloads = ();
131881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$AddedInt{$Level}}))
13189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # check all added exported symbols
131901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $CompleteSignature{2}{$Symbol}{"Header"}) {
13191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
13192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
131930d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(defined $CompleteSignature{1}{$Symbol}
131940d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $CompleteSignature{1}{$Symbol}{"Header"})
131950d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # double-check added symbol
131960d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            next;
131971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
13198850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(not symbolFilter($Symbol, 2, "Affected", $Level)) {
131991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
132001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
132011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Symbol=~/\A(_Z|\?)/)
13202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # C++
132031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $AddedOverloads{get_symbol_prefix($Symbol, 2)}{get_symbol_suffix($Symbol, 1)} = $Symbol;
13204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
132051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(my $OverriddenMethod = $CompleteSignature{2}{$Symbol}{"Override"})
132061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # register virtual overridings
1320762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $Cid = $CompleteSignature{2}{$Symbol}{"Class"};
1320862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $AffectedClass_Name = $TypeInfo{2}{$Cid}{"Name"};
132090d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(defined $CompleteSignature{1}{$OverriddenMethod} and $CompleteSignature{1}{$OverriddenMethod}{"Virt"}
13210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and not $CompleteSignature{1}{$OverriddenMethod}{"Private"})
132110d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
132120d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if($TName_Tid{1}{$AffectedClass_Name})
132130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                { # class should exist in previous version
132140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    if(not isCopyingClass($TName_Tid{1}{$AffectedClass_Name}, 1))
132150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    { # old v-table is NOT copied by old applications
132160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$OverriddenMethod}{"Overridden_Virtual_Method"}{$tr_name{$Symbol}}}=(
132170d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Type_Name"=>$AffectedClass_Name,
132180d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Target"=>get_Signature($Symbol, 2),
132190d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Old_Value"=>get_Signature($OverriddenMethod, 2),
1322074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                            "New_Value"=>get_Signature($Symbol, 2));
132210d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
13222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
132261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$RemovedInt{$Level}}))
132271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # check all removed exported symbols
132281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $CompleteSignature{1}{$Symbol}{"Header"}) {
13229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
13230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
132310d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(defined $CompleteSignature{2}{$Symbol}
132320d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $CompleteSignature{2}{$Symbol}{"Header"})
132330d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # double-check removed symbol
132340d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            next;
132351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
132361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CompleteSignature{1}{$Symbol}{"Private"})
132371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # skip private methods
132381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
132391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
13240850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(not symbolFilter($Symbol, 1, "Affected", $Level)) {
132411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
132421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
132431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $CheckedSymbols{$Level}{$Symbol} = 1;
132441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(my $OverriddenMethod = $CompleteSignature{1}{$Symbol}{"Override"})
132451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # register virtual overridings
1324662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $Cid = $CompleteSignature{1}{$Symbol}{"Class"};
1324762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $AffectedClass_Name = $TypeInfo{1}{$Cid}{"Name"};
13248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(defined $CompleteSignature{2}{$OverriddenMethod}
132490d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and $CompleteSignature{2}{$OverriddenMethod}{"Virt"})
132500d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
132510d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if($TName_Tid{2}{$AffectedClass_Name})
132520d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                { # class should exist in newer version
132530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    if(not isCopyingClass($CompleteSignature{1}{$Symbol}{"Class"}, 1))
132540d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    { # old v-table is NOT copied by old applications
132550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{"Overridden_Virtual_Method_B"}{$tr_name{$OverriddenMethod}}}=(
132560d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Type_Name"=>$AffectedClass_Name,
132570d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Target"=>get_Signature($OverriddenMethod, 1),
132580d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Old_Value"=>get_Signature($Symbol, 1),
1325974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                            "New_Value"=>get_Signature($OverriddenMethod, 1));
132600d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
13261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
132641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Binary"
132651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        and $OSgroup eq "windows")
13266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # register the reason of symbol name change
1326762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $NewSym = $mangled_name{2}{$tr_name{$Symbol}})
13268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
1326962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($AddedInt{$Level}{$NewSym})
13270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
1327162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($CompleteSignature{1}{$Symbol}{"Static"} ne $CompleteSignature{2}{$NewSym}{"Static"})
13272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
1327362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        if($CompleteSignature{2}{$NewSym}{"Static"})
132741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
132751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{"Symbol_Became_Static"}{$tr_name{$Symbol}}}=(
132761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$tr_name{$Symbol},
132771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Old_Value"=>$Symbol,
1327862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                "New_Value"=>$NewSym  );
13279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
132801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        else
132811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
13282fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{"Symbol_Became_Non_Static"}{$tr_name{$Symbol}}}=(
132831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$tr_name{$Symbol},
132841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Old_Value"=>$Symbol,
1328562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                "New_Value"=>$NewSym  );
13286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
13287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
1328862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($CompleteSignature{1}{$Symbol}{"Virt"} ne $CompleteSignature{2}{$NewSym}{"Virt"})
13289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
1329062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        if($CompleteSignature{2}{$NewSym}{"Virt"})
132911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
132921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{"Symbol_Became_Virtual"}{$tr_name{$Symbol}}}=(
132931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$tr_name{$Symbol},
132941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Old_Value"=>$Symbol,
1329562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                "New_Value"=>$NewSym  );
13296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
132971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        else
132981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
13299fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{"Symbol_Became_Non_Virtual"}{$tr_name{$Symbol}}}=(
133001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$tr_name{$Symbol},
133011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Old_Value"=>$Symbol,
1330262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                "New_Value"=>$NewSym  );
13303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
13304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
1330562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $RTId1 = $CompleteSignature{1}{$Symbol}{"Return"};
1330662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $RTId2 = $CompleteSignature{2}{$NewSym}{"Return"};
1330762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $RTName1 = $TypeInfo{1}{$RTId1}{"Name"};
1330862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $RTName2 = $TypeInfo{2}{$RTId2}{"Name"};
1330962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($RTName1 ne $RTName2)
13310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
13311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $ProblemType = "Symbol_Changed_Return";
133121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($CompleteSignature{1}{$Symbol}{"Data"}) {
13313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType = "Global_Data_Symbol_Changed_Type";
13314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
133151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{$ProblemType}{$tr_name{$Symbol}}}=(
133161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>$tr_name{$Symbol},
1331762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "Old_Type"=>$RTName1,
1331862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Type"=>$RTName2,
133191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Old_Value"=>$Symbol,
1332062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Value"=>$NewSym  );
13321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
133251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Symbol=~/\A(_Z|\?)/)
13326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # C++
133271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Prefix = get_symbol_prefix($Symbol, 1);
13328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my @Overloads = sort keys(%{$AddedOverloads{$Prefix}})
133291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and not $AddedOverloads{$Prefix}{get_symbol_suffix($Symbol, 1)})
13330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # changed signature: params, "const"-qualifier
1333162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $NewSym = $AddedOverloads{$Prefix}{$Overloads[0]};
133321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($CompleteSignature{1}{$Symbol}{"Constructor"})
133331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                {
13334989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    if($Symbol=~/(C1E|C2E)/)
13335989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    {
13336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $CtorType = $1;
1333762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $NewSym=~s/(C1E|C2E)/$CtorType/g;
13338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
133401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                elsif($CompleteSignature{1}{$Symbol}{"Destructor"})
133411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                {
13342989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    if($Symbol=~/(D0E|D1E|D2E)/)
13343989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    {
13344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $DtorType = $1;
1334562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $NewSym=~s/(D0E|D1E|D2E)/$DtorType/g;
13346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13348dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                my $NS1 = $CompleteSignature{1}{$Symbol}{"NameSpace"};
1334962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $NS2 = $CompleteSignature{2}{$NewSym}{"NameSpace"};
13350dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if((not $NS1 and not $NS2) or ($NS1 and $NS2 and $NS1 eq $NS2))
13351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # from the same class and namespace
133521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($CompleteSignature{1}{$Symbol}{"Const"}
1335362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    and not $CompleteSignature{2}{$NewSym}{"Const"})
13354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # "const" to non-"const"
13355fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{"Method_Became_Non_Const"}{$tr_name{$Symbol}}}=(
1335662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "Type_Name"=>$TypeInfo{1}{$CompleteSignature{1}{$Symbol}{"Class"}}{"Name"},
133571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>$tr_name{$Symbol},
1335862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Signature"=>get_Signature($NewSym, 2),
133591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Old_Value"=>$Symbol,
1336062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Value"=>$NewSym  );
13361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
133621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    elsif(not $CompleteSignature{1}{$Symbol}{"Const"}
1336362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    and $CompleteSignature{2}{$NewSym}{"Const"})
13364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # non-"const" to "const"
133650d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{"Method_Became_Const"}{$tr_name{$Symbol}}}=(
133661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>$tr_name{$Symbol},
1336762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Signature"=>get_Signature($NewSym, 2),
133681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Old_Value"=>$Symbol,
1336962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Value"=>$NewSym  );
13370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
133711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($CompleteSignature{1}{$Symbol}{"Volatile"}
1337262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    and not $CompleteSignature{2}{$NewSym}{"Volatile"})
13373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # "volatile" to non-"volatile"
13374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
13375fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{"Method_Became_Non_Volatile"}{$tr_name{$Symbol}}}=(
133761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>$tr_name{$Symbol},
1337762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Signature"=>get_Signature($NewSym, 2),
133781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Old_Value"=>$Symbol,
1337962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Value"=>$NewSym  );
13380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
133811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    elsif(not $CompleteSignature{1}{$Symbol}{"Volatile"}
1338262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    and $CompleteSignature{2}{$NewSym}{"Volatile"})
13383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # non-"volatile" to "volatile"
133840d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{"Method_Became_Volatile"}{$tr_name{$Symbol}}}=(
133851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>$tr_name{$Symbol},
1338662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Signature"=>get_Signature($NewSym, 2),
133871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Old_Value"=>$Symbol,
1338862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Value"=>$NewSym  );
13389ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
1339062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if(get_symbol_suffix($Symbol, 0) ne get_symbol_suffix($NewSym, 0))
13391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # params list
133921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{"Symbol_Changed_Parameters"}{$tr_name{$Symbol}}}=(
133931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>$tr_name{$Symbol},
1339462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Signature"=>get_Signature($NewSym, 2),
133951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Old_Value"=>$Symbol,
1339662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Value"=>$NewSym  );
13397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
134021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$CompleteSignature{1}}))
134031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # checking symbols
134041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my ($SN, $SS, $SV) = separate_symbol($Symbol);
134051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Source")
134061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # remove symbol version
134071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Symbol=$SN;
134081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
134091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
134101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # Binary
134111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if(not $SV)
134121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # symbol without version
134131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if(my $VSym = $SymVer{1}{$Symbol})
134141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # the symbol is linked with versioned symbol
134151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($CompleteSignature{2}{$VSym}{"MnglName"})
134161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # show report for symbol@ver only
134171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        next;
134181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
134191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    elsif(not link_symbol($VSym, 2, "-Deps"))
134201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # changed version: sym@v1 to sym@v2
134211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                      # do NOT show report for symbol
134221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        next;
134231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
13424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
134271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $PSymbol = $Symbol;
134281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Source"
134291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        and my $S = $SourceReplacement{$Symbol})
134301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # take a source-compatible replacement function
134311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $PSymbol = $S;
134321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
134331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CompleteSignature{1}{$Symbol}{"Private"})
13434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # private symbols
13435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
13436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
134371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not defined $CompleteSignature{1}{$Symbol}
134381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or not defined $CompleteSignature{2}{$PSymbol})
134391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # no info
134401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
134411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
134421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $CompleteSignature{1}{$Symbol}{"MnglName"}
134431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or not $CompleteSignature{2}{$PSymbol}{"MnglName"})
134441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # no mangled name
13445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
13446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
134471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $CompleteSignature{1}{$Symbol}{"Header"}
134481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or not $CompleteSignature{2}{$PSymbol}{"Header"})
13449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # without a header
13450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
13451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
134529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
134539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(not $CompleteSignature{1}{$Symbol}{"PureVirt"}
134549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        and $CompleteSignature{2}{$PSymbol}{"PureVirt"})
134559927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # became pure
134569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            next;
134579927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
134589927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($CompleteSignature{1}{$Symbol}{"PureVirt"}
134599927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        and not $CompleteSignature{2}{$PSymbol}{"PureVirt"})
134609927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # became non-pure
134619927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            next;
134629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
134639927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
134649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(not symbolFilter($Symbol, 1, "Affected + InlineVirt", $Level))
134659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # exported, target, inline virtual and pure virtual
134669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            next;
134679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
134689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(not symbolFilter($PSymbol, 2, "Affected + InlineVirt", $Level))
134699927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # exported, target, inline virtual and pure virtual
134709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            next;
134719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
134729927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
1347362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(checkDump(1, "2.13") and checkDump(2, "2.13"))
134740d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
134750d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if($CompleteSignature{1}{$Symbol}{"Data"}
134760d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and $CompleteSignature{2}{$PSymbol}{"Data"})
134770d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
134780d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                my $Value1 = $CompleteSignature{1}{$Symbol}{"Value"};
134790d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                my $Value2 = $CompleteSignature{2}{$PSymbol}{"Value"};
134800d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if(defined $Value1)
134810d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                {
134820d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    $Value1 = showVal($Value1, $CompleteSignature{1}{$Symbol}{"Return"}, 1);
134830d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    if(defined $Value2)
134840d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    {
134850d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        $Value2 = showVal($Value2, $CompleteSignature{2}{$PSymbol}{"Return"}, 2);
134860d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        if($Value1 ne $Value2)
134870d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        {
134880d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{"Global_Data_Value_Changed"}{""}}=(
134890d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                "Old_Value"=>$Value1,
134900d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                "New_Value"=>$Value2,
134910d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                "Target"=>get_Signature($Symbol, 1)  );
134920d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        }
134930d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
134940d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
134950d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
134960d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
13497850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
134980d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($CompleteSignature{2}{$PSymbol}{"Private"})
134990d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
135000d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            %{$CompatProblems{$Level}{$Symbol}{getSymKind($Symbol, 1)."_Became_Private"}{""}}=(
135010d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                "Target"=>get_Signature_M($PSymbol, 2)  );
135020d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
135030d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        elsif(not $CompleteSignature{1}{$Symbol}{"Protected"}
135040d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $CompleteSignature{2}{$PSymbol}{"Protected"})
135050d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
135060d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            %{$CompatProblems{$Level}{$Symbol}{getSymKind($Symbol, 1)."_Became_Protected"}{""}}=(
135070d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                "Target"=>get_Signature_M($PSymbol, 2)  );
135080d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
135090d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        elsif($CompleteSignature{1}{$Symbol}{"Protected"}
135100d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and not $CompleteSignature{2}{$PSymbol}{"Protected"})
135110d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
135120d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            %{$CompatProblems{$Level}{$Symbol}{getSymKind($Symbol, 1)."_Became_Public"}{""}}=(
135130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                "Target"=>get_Signature_M($PSymbol, 2)  );
135140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
135150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
13516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # checking virtual table
135171693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        mergeVirtualTables($Symbol, $Level);
135181693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
13519ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($COMPILE_ERRORS)
13520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # if some errors occurred at the compiling stage
13521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # then some false positives can be skipped here
135221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if(not $CompleteSignature{1}{$Symbol}{"Data"} and $CompleteSignature{2}{$PSymbol}{"Data"}
1352362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            and not $GlobalDataObject{2}{$Symbol})
13524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # missed information about parameters in newer version
13525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
13526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1352762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($CompleteSignature{1}{$Symbol}{"Data"} and not $GlobalDataObject{1}{$Symbol}
135281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and not $CompleteSignature{2}{$PSymbol}{"Data"})
135299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # missed information about parameters in older version
13530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
13531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
135331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my ($MnglName, $VersionSpec, $SymbolVersion) = separate_symbol($Symbol);
13534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # checking attributes
135351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CompleteSignature{2}{$PSymbol}{"Static"}
135369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        and not $CompleteSignature{1}{$Symbol}{"Static"} and $Symbol=~/\A(_Z|\?)/)
135379927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
135381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            %{$CompatProblems{$Level}{$Symbol}{"Method_Became_Static"}{""}}=(
135391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                "Target"=>get_Signature($Symbol, 1)
135401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            );
13541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
135421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif(not $CompleteSignature{2}{$PSymbol}{"Static"}
135439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        and $CompleteSignature{1}{$Symbol}{"Static"} and $Symbol=~/\A(_Z|\?)/)
135449927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
13545fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            %{$CompatProblems{$Level}{$Symbol}{"Method_Became_Non_Static"}{""}}=(
135461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                "Target"=>get_Signature($Symbol, 1)
135471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            );
13548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
135491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(($CompleteSignature{1}{$Symbol}{"Virt"} and $CompleteSignature{2}{$PSymbol}{"Virt"})
135501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or ($CompleteSignature{1}{$Symbol}{"PureVirt"} and $CompleteSignature{2}{$PSymbol}{"PureVirt"}))
13551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # relative position of virtual and pure virtual methods
135521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Binary")
13553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
13554dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if(defined $CompleteSignature{1}{$Symbol}{"RelPos"} and defined $CompleteSignature{2}{$PSymbol}{"RelPos"}
13555dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                and $CompleteSignature{1}{$Symbol}{"RelPos"}!=$CompleteSignature{2}{$PSymbol}{"RelPos"})
13556dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                { # top-level virtual methods only
135571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my $Class_Id = $CompleteSignature{1}{$Symbol}{"Class"};
1355862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $Class_Name = $TypeInfo{1}{$Class_Id}{"Name"};
13559dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    if(defined $VirtualTable{1}{$Class_Name} and defined $VirtualTable{2}{$Class_Name}
13560dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    and $VirtualTable{1}{$Class_Name}{$Symbol}!=$VirtualTable{2}{$Class_Name}{$Symbol})
135611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # check the absolute position of virtual method (including added and removed methods)
1356262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        my %Class_Type = get_Type($Class_Id, 1);
135631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        my $ProblemType = "Virtual_Method_Position";
135641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($CompleteSignature{1}{$Symbol}{"PureVirt"}) {
135651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemType = "Pure_Virtual_Method_Position";
135661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
135671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(isUsedClass($Class_Id, 1, $Level))
13568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
135691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            my @Affected = ($Symbol, keys(%{$OverriddenMethods{1}{$Symbol}}));
135709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            foreach my $ASymbol (@Affected)
135711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            {
135729927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                if(not symbolFilter($ASymbol, 1, "Affected", $Level)) {
135739927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                    next;
135749927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                }
135759927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                %{$CompatProblems{$Level}{$ASymbol}{$ProblemType}{$tr_name{$MnglName}}}=(
135761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    "Type_Name"=>$Class_Type{"Name"},
135771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    "Old_Value"=>$CompleteSignature{1}{$Symbol}{"RelPos"},
135781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    "New_Value"=>$CompleteSignature{2}{$PSymbol}{"RelPos"},
1357974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                                    "Target"=>get_Signature($Symbol, 1));
135801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            }
135811693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            $VTableChanged_M{$Class_Type{"Name"}} = 1;
13582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
13583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
135871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CompleteSignature{1}{$Symbol}{"PureVirt"}
135881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or $CompleteSignature{2}{$PSymbol}{"PureVirt"})
13589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # do NOT check type changes in pure virtuals
13590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
13591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13592ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        $CheckedSymbols{$Level}{$Symbol} = 1;
135931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Symbol=~/\A(_Z|\?)/
135941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or keys(%{$CompleteSignature{1}{$Symbol}{"Param"}})==keys(%{$CompleteSignature{2}{$PSymbol}{"Param"}}))
13595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # C/C++: changes in parameters
135961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $ParamPos (sort {int($a) <=> int($b)} keys(%{$CompleteSignature{1}{$Symbol}{"Param"}}))
13597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # checking parameters
13598ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                mergeParameters($Symbol, $PSymbol, $ParamPos, $ParamPos, $Level, 1);
13599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
13602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # C: added/removed parameters
136031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $ParamPos (sort {int($a) <=> int($b)} keys(%{$CompleteSignature{2}{$PSymbol}{"Param"}}))
13604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # checking added parameters
13605dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                my $PType2_Id = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos}{"type"};
1360662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $PType2_Name = $TypeInfo{2}{$PType2_Id}{"Name"};
1360762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                last if($PType2_Name eq "...");
1360862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $PName = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos}{"name"};
1360962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $PName_Old = (defined $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos})?$CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos}{"name"}:"";
13610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $ParamPos_Prev = "-1";
1361162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($PName=~/\Ap\d+\Z/i)
13612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # added unnamed parameter ( pN )
1361362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my @Positions1 = find_ParamPair_Pos_byTypeAndPos($PType2_Name, $ParamPos, "backward", $Symbol, 1);
1361462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my @Positions2 = find_ParamPair_Pos_byTypeAndPos($PType2_Name, $ParamPos, "backward", $Symbol, 2);
13615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($#Positions1==-1 or $#Positions2>$#Positions1) {
13616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ParamPos_Prev = "lost";
13617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
1362062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $ParamPos_Prev = find_ParamPair_Pos_byName($PName, $Symbol, 1);
13621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($ParamPos_Prev eq "lost")
13623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
136241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($ParamPos>keys(%{$CompleteSignature{1}{$Symbol}{"Param"}})-1)
13625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
13626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $ProblemType = "Added_Parameter";
1362762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        if($PName=~/\Ap\d+\Z/) {
13628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType = "Added_Unnamed_Parameter";
13629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
136300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{$ProblemType}{showPos($ParamPos)." Parameter"}}=(
1363162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "Target"=>$PName,
13632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            "Param_Pos"=>$ParamPos,
1363362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "Param_Type"=>$PType2_Name,
136341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "New_Signature"=>get_Signature($Symbol, 2)  );
13635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    else
13637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
13638f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        my %ParamType_Pure = get_PureType($PType2_Id, $TypeInfo{2});
1363962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        my $PairType_Id = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos}{"type"};
13640f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        my %PairType_Pure = get_PureType($PairType_Id, $TypeInfo{1});
1364162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        if(($ParamType_Pure{"Name"} eq $PairType_Pure{"Name"} or $PType2_Name eq $TypeInfo{1}{$PairType_Id}{"Name"})
1364262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        and find_ParamPair_Pos_byName($PName_Old, $Symbol, 2) eq "lost")
13643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
1364462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            if($PName_Old!~/\Ap\d+\Z/ and $PName!~/\Ap\d+\Z/)
13645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            {
136460d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                %{$CompatProblems{$Level}{$Symbol}{"Renamed_Parameter"}{showPos($ParamPos)." Parameter"}}=(
1364762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                    "Target"=>$PName_Old,
13648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                    "Param_Pos"=>$ParamPos,
1364962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                    "Param_Type"=>$PType2_Name,
1365062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                    "Old_Value"=>$PName_Old,
1365162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                    "New_Value"=>$PName,
136521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    "New_Signature"=>get_Signature($Symbol, 2)  );
13653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
13654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
13655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        else
13656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
13657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            my $ProblemType = "Added_Middle_Parameter";
1365862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            if($PName=~/\Ap\d+\Z/) {
13659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                $ProblemType = "Added_Middle_Unnamed_Parameter";
13660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
136610d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{$ProblemType}{showPos($ParamPos)." Parameter"}}=(
1366262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                "Target"=>$PName,
13663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                "Param_Pos"=>$ParamPos,
1366462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                "Param_Type"=>$PType2_Name,
136651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "New_Signature"=>get_Signature($Symbol, 2)  );
13666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
13667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
136701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $ParamPos (sort {int($a) <=> int($b)} keys(%{$CompleteSignature{1}{$Symbol}{"Param"}}))
13671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # check relevant parameters
13672dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                my $PType1_Id = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos}{"type"};
136731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my $ParamName1 = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos}{"name"};
13674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                # FIXME: find relevant parameter by name
136751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if(defined $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos})
13676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
13677dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    my $PType2_Id = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos}{"type"};
136781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my $ParamName2 = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos}{"name"};
1367962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($TypeInfo{1}{$PType1_Id}{"Name"} eq $TypeInfo{2}{$PType2_Id}{"Name"}
1368062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    or ($ParamName1!~/\Ap\d+\Z/i and $ParamName1 eq $ParamName2)) {
13681ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                        mergeParameters($Symbol, $PSymbol, $ParamPos, $ParamPos, $Level, 0);
13682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
136851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $ParamPos (sort {int($a) <=> int($b)} keys(%{$CompleteSignature{1}{$Symbol}{"Param"}}))
13686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # checking removed parameters
13687dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                my $PType1_Id = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos}{"type"};
1368862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $PType1_Name = $TypeInfo{1}{$PType1_Id}{"Name"};
1368962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                last if($PType1_Name eq "...");
13690ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                my $PName = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos}{"name"};
13691ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                my $PName_New = (defined $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos})?$CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos}{"name"}:"";
13692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $ParamPos_New = "-1";
13693ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                if($PName=~/\Ap\d+\Z/i)
13694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # removed unnamed parameter ( pN )
1369562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my @Positions1 = find_ParamPair_Pos_byTypeAndPos($PType1_Name, $ParamPos, "forward", $Symbol, 1);
1369662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my @Positions2 = find_ParamPair_Pos_byTypeAndPos($PType1_Name, $ParamPos, "forward", $Symbol, 2);
13697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($#Positions2==-1 or $#Positions2<$#Positions1) {
13698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ParamPos_New = "lost";
13699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
13702ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                    $ParamPos_New = find_ParamPair_Pos_byName($PName, $Symbol, 2);
13703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($ParamPos_New eq "lost")
13705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
137061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($ParamPos>keys(%{$CompleteSignature{2}{$PSymbol}{"Param"}})-1)
13707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
13708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $ProblemType = "Removed_Parameter";
13709ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                        if($PName=~/\Ap\d+\Z/) {
13710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType = "Removed_Unnamed_Parameter";
13711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
137120d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{$ProblemType}{showPos($ParamPos)." Parameter"}}=(
13713ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                            "Target"=>$PName,
13714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            "Param_Pos"=>$ParamPos,
1371562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "Param_Type"=>$PType1_Name,
137161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "New_Signature"=>get_Signature($Symbol, 2)  );
13717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
137181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    elsif($ParamPos<keys(%{$CompleteSignature{1}{$Symbol}{"Param"}})-1)
13719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
13720f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        my %ParamType_Pure = get_PureType($PType1_Id, $TypeInfo{1});
1372162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        my $PairType_Id = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos}{"type"};
13722f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        my %PairType_Pure = get_PureType($PairType_Id, $TypeInfo{2});
1372362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        if(($ParamType_Pure{"Name"} eq $PairType_Pure{"Name"} or $PType1_Name eq $TypeInfo{2}{$PairType_Id}{"Name"})
13724ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                        and find_ParamPair_Pos_byName($PName_New, $Symbol, 1) eq "lost")
13725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
13726ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                            if($PName_New!~/\Ap\d+\Z/ and $PName!~/\Ap\d+\Z/)
13727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            {
137280d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                %{$CompatProblems{$Level}{$Symbol}{"Renamed_Parameter"}{showPos($ParamPos)." Parameter"}}=(
13729ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                                    "Target"=>$PName,
13730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                    "Param_Pos"=>$ParamPos,
1373162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                    "Param_Type"=>$PType1_Name,
13732ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                                    "Old_Value"=>$PName,
13733ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                                    "New_Value"=>$PName_New,
137341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    "New_Signature"=>get_Signature($Symbol, 2)  );
13735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
13736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
13737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        else
13738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
13739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            my $ProblemType = "Removed_Middle_Parameter";
13740ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                            if($PName=~/\Ap\d+\Z/) {
13741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                $ProblemType = "Removed_Middle_Unnamed_Parameter";
13742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
137430d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{$ProblemType}{showPos($ParamPos)." Parameter"}}=(
13744ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                                "Target"=>$PName,
13745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                "Param_Pos"=>$ParamPos,
1374662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                "Param_Type"=>$PType1_Name,
137471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "New_Signature"=>get_Signature($Symbol, 2)  );
13748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
13749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # checking return type
137541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $ReturnType1_Id = $CompleteSignature{1}{$Symbol}{"Return"};
137551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $ReturnType2_Id = $CompleteSignature{2}{$PSymbol}{"Return"};
137561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        %SubProblems = detectTypeChange($ReturnType1_Id, $ReturnType2_Id, "Return", $Level);
13757fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
13758ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $SubProblemType (keys(%SubProblems))
13759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
13760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $New_Value = $SubProblems{$SubProblemType}{"New_Value"};
13761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Old_Value = $SubProblems{$SubProblemType}{"Old_Value"};
13762fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my %ProblemTypes = ();
13763f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
13764fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($CompleteSignature{1}{$Symbol}{"Data"})
13765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
13766fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($SubProblemType eq "Return_Type_And_Size") {
13767fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $ProblemTypes{"Global_Data_Type_And_Size"} = 1;
13768fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
13769fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                elsif($SubProblemType eq "Return_Type_Format") {
13770fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $ProblemTypes{"Global_Data_Type_Format"} = 1;
13771fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
13772fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else {
13773fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $ProblemTypes{"Global_Data_Type"} = 1;
13774fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
13775fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
13776fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                # quals
13777fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($SubProblemType eq "Return_Type"
13778fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                or $SubProblemType eq "Return_Type_And_Size"
13779fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                or $SubProblemType eq "Return_Type_Format")
13780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
13781fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(my $RR = removedQual($Old_Value, $New_Value, "const"))
13782fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    { # const to non-const
13783fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if($RR==2) {
13784fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Global_Data_Removed_Const"} = 1;
13785fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13786fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        else {
13787fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Global_Data_Became_Non_Const"} = 1;
13788fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13789fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $ProblemTypes{"Global_Data_Type"} = 1;
13790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13791fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    elsif(my $RA = addedQual($Old_Value, $New_Value, "const"))
13792fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    { # non-const to const
13793fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if($RA==2) {
13794fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Global_Data_Added_Const"} = 1;
13795fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13796fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        else {
13797fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Global_Data_Became_Const"} = 1;
13798fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13799fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $ProblemTypes{"Global_Data_Type"} = 1;
13800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13802fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
13803fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            else
13804fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
13805fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                # quals
13806fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($SubProblemType eq "Return_Type"
13807fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                or $SubProblemType eq "Return_Type_And_Size"
13808fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                or $SubProblemType eq "Return_Type_Format")
13809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
13810fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(checkDump(1, "2.6") and checkDump(2, "2.6"))
13811fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    {
13812fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if(addedQual($Old_Value, $New_Value, "volatile"))
13813fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        {
13814fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Value_Became_Volatile"} = 1;
13815fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            if($Level ne "Source"
13816fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            or not cmpBTypes($Old_Value, $New_Value, 1, 2)) {
13817fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                                $ProblemTypes{"Return_Type"} = 1;
13818fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            }
13819fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13820fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
13821fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(my $RA = addedQual($Old_Value, $New_Value, "const"))
138229927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    {
13823fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if($RA==2) {
13824fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_Added_Const"} = 1;
13825fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13826fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        else {
13827fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_Became_Const"} = 1;
13828fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13829fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if($Level ne "Source"
13830fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        or not cmpBTypes($Old_Value, $New_Value, 1, 2)) {
13831fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type"} = 1;
13832fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13836f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($Level eq "Binary"
13837f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            and not $CompleteSignature{1}{$Symbol}{"Data"})
13838f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            {
13839f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                my ($Arch1, $Arch2) = (getArch(1), getArch(2));
13840f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                if($Arch1 eq "unknown" or $Arch2 eq "unknown")
13841f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                { # if one of the architectures is unknown
13842f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    # then set other arhitecture to unknown too
13843f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    ($Arch1, $Arch2) = ("unknown", "unknown");
13844f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                }
13845f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                my (%Conv1, %Conv2) = ();
13846fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($UseConv_Real{1}{"R"} and $UseConv_Real{2}{"R"})
13847f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
13848f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    %Conv1 = callingConvention_R_Real($CompleteSignature{1}{$Symbol});
13849f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    %Conv2 = callingConvention_R_Real($CompleteSignature{2}{$PSymbol});
13850f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                }
13851f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                else
13852f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
13853f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    %Conv1 = callingConvention_R_Model($CompleteSignature{1}{$Symbol}, $TypeInfo{1}, $Arch1, $OStarget, $WORD_SIZE{1});
13854f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    %Conv2 = callingConvention_R_Model($CompleteSignature{2}{$PSymbol}, $TypeInfo{2}, $Arch2, $OStarget, $WORD_SIZE{2});
13855f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                }
13856f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
13857f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                if($SubProblemType eq "Return_Type_Became_Void")
13858f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
13859f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    if(keys(%{$CompleteSignature{1}{$Symbol}{"Param"}}))
13860f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    { # parameters stack has been affected
13861f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if($Conv1{"Method"} eq "stack") {
13862fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_Became_Void_And_Stack_Layout"} = 1;
13863f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
13864f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        elsif($Conv1{"Hidden"}) {
13865fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_Became_Void_And_Register"} = 1;
13866f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
13867f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    }
13868f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                }
13869f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                elsif($SubProblemType eq "Return_Type_From_Void")
13870f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
13871f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    if(keys(%{$CompleteSignature{1}{$Symbol}{"Param"}}))
13872f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    { # parameters stack has been affected
13873f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if($Conv2{"Method"} eq "stack") {
13874fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_From_Void_And_Stack_Layout"} = 1;
13875f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
13876f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        elsif($Conv2{"Hidden"}) {
13877fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_From_Void_And_Register"} = 1;
13878f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
13879f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    }
13880f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                }
13881f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                elsif($SubProblemType eq "Return_Type"
13882f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                or $SubProblemType eq "Return_Type_And_Size"
13883f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                or $SubProblemType eq "Return_Type_Format")
13884f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
13885f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    if($Conv1{"Method"} ne $Conv2{"Method"})
13886f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    {
13887f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if($Conv1{"Method"} eq "stack")
13888f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        { # returns in a register instead of a hidden first parameter
13889fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_From_Stack_To_Register"} = 1;
13890f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
13891f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        else {
13892fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_From_Register_To_Stack"} = 1;
13893f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
13894f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    }
13895f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    else
13896f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    {
13897f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if($Conv1{"Method"} eq "reg")
13898f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        {
13899f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            if($Conv1{"Registers"} ne $Conv2{"Registers"})
13900f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            {
13901f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                                if($Conv1{"Hidden"}) {
13902fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                                    $ProblemTypes{"Return_Type_And_Register_Was_Hidden_Parameter"} = 1;
13903f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                                }
13904f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                                elsif($Conv2{"Hidden"}) {
13905fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                                    $ProblemTypes{"Return_Type_And_Register_Became_Hidden_Parameter"} = 1;
13906f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                                }
13907f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                                else {
13908fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                                    $ProblemTypes{"Return_Type_And_Register"} = 1;
13909f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                                }
13910f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            }
13911f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
13912f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    }
13913f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                }
13914f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
13915fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
13916fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(not keys(%ProblemTypes))
13917fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            { # default
13918fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $ProblemTypes{$SubProblemType} = 1;
13919fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
13920fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
13921fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            foreach my $ProblemType (keys(%ProblemTypes))
13922fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            { # additional
13923fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                @{$CompatProblems{$Level}{$Symbol}{$ProblemType}{"retval"}}{keys(%{$SubProblems{$SubProblemType}})} = values %{$SubProblems{$SubProblemType}};
139249927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
13925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($ReturnType1_Id and $ReturnType2_Id)
13927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
13928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @RecurTypes = ();
1392962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            %SubProblems = mergeTypes($ReturnType1_Id, $ReturnType2_Id, $Level);
13930fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
13931fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($CompleteSignature{1}{$Symbol}{"Data"})
13932fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
13933fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Level eq "Binary")
13934fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
13935fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(get_PLevel($ReturnType1_Id, 1)==0)
13936fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    {
13937fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        foreach my $SubProblemType (keys(%SubProblems))
13938fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        { # add "Global_Data_Size" problem
13939fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            my $New_Value = $SubProblems{$SubProblemType}{"New_Value"};
13940fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            my $Old_Value = $SubProblems{$SubProblemType}{"Old_Value"};
13941fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            if($SubProblemType eq "DataType_Size")
13942fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            { # add a new problem
13943fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                                %{$SubProblems{"Global_Data_Size"}} = %{$SubProblems{$SubProblemType}};
13944fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            }
13945fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13946fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
13947fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(not defined $SubProblems{"Global_Data_Size"})
13948fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    {
13949fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if(defined $GlobalDataObject{1}{$Symbol}
13950fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        and defined $GlobalDataObject{2}{$Symbol})
13951fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        {
13952fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            my $Old_Size = $GlobalDataObject{1}{$Symbol};
13953fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            my $New_Size = $GlobalDataObject{2}{$Symbol};
13954fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            if($Old_Size!=$New_Size)
13955fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            {
13956fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                                %{$SubProblems{"Global_Data_Size"}{"retval"}} = (
13957fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                                    "Old_Size"=>$Old_Size*$BYTE_SIZE,
13958fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                                    "New_Size"=>$New_Size*$BYTE_SIZE );
13959fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            }
13960fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13961fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
13962fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
13963fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
13964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $SubProblemType (keys(%SubProblems))
13965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
13966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $SubLocation (keys(%{$SubProblems{$SubProblemType}}))
13967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
13968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $NewLocation = ($SubLocation)?"retval->".$SubLocation:"retval";
139691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    %{$CompatProblems{$Level}{$Symbol}{$SubProblemType}{$NewLocation}}=(
1397062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        "Return_Type_Name"=>$TypeInfo{1}{$ReturnType1_Id}{"Name"} );
139711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    @{$CompatProblems{$Level}{$Symbol}{$SubProblemType}{$NewLocation}}{keys(%{$SubProblems{$SubProblemType}{$SubLocation}})} = values %{$SubProblems{$SubProblemType}{$SubLocation}};
13972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($SubLocation!~/\-\>/) {
1397362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $CompatProblems{$Level}{$Symbol}{$SubProblemType}{$NewLocation}{"Start_Type_Name"} = $TypeInfo{1}{$ReturnType1_Id}{"Name"};
13974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
13979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # checking object type
1398062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ObjTId1 = $CompleteSignature{1}{$Symbol}{"Class"};
1398162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ObjTId2 = $CompleteSignature{2}{$PSymbol}{"Class"};
1398262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($ObjTId1 and $ObjTId2
139831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        and not $CompleteSignature{1}{$Symbol}{"Static"})
13984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1398562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $ThisPtr1_Id = getTypeIdByName($TypeInfo{1}{$ObjTId1}{"Name"}."*const", 1);
1398662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $ThisPtr2_Id = getTypeIdByName($TypeInfo{2}{$ObjTId2}{"Name"}."*const", 2);
13987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ThisPtr1_Id and $ThisPtr2_Id)
13988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
13989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @RecurTypes = ();
1399062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                %SubProblems = mergeTypes($ThisPtr1_Id, $ThisPtr2_Id, $Level);
13991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $SubProblemType (keys(%SubProblems))
13992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
13993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    foreach my $SubLocation (keys(%{$SubProblems{$SubProblemType}}))
13994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
13995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $NewLocation = ($SubLocation)?"this->".$SubLocation:"this";
139961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{$SubProblemType}{$NewLocation}}=(
1399762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "Object_Type_Name"=>$TypeInfo{1}{$ObjTId1}{"Name"} );
139981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        @{$CompatProblems{$Level}{$Symbol}{$SubProblemType}{$NewLocation}}{keys(%{$SubProblems{$SubProblemType}{$SubLocation}})} = values %{$SubProblems{$SubProblemType}{$SubLocation}};
13999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($SubLocation!~/\-\>/) {
1400062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            $CompatProblems{$Level}{$Symbol}{$SubProblemType}{$NewLocation}{"Start_Type_Name"} = $TypeInfo{1}{$ObjTId1}{"Name"};
14001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
14002ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
14003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
140071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Level eq "Binary") {
140081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        mergeVTables($Level);
140091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
14010850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    foreach my $Symbol (keys(%{$CompatProblems{$Level}})) {
14011850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $CheckedSymbols{$Level}{$Symbol} = 1;
14012850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
14013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
140150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub rmQuals($$)
140160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
140170d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Value, $Qual) = @_;
140180d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(not $Qual) {
140190d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return $Value;
140200d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
140210d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($Qual eq "all")
140220d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # all quals
140230d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        $Qual = "const|volatile|restrict";
140240d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
1402562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    while($Value=~s/\b$Qual\b//) {
140269927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $Value = formatName($Value, "T");
140270d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
140280d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return $Value;
140290d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
140300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
140310d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub cmpBTypes($$$$)
140320d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
140330d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($T1, $T2, $V1, $V2) = @_;
140340d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $T1 = uncover_typedefs($T1, $V1);
140350d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $T2 = uncover_typedefs($T2, $V2);
140360d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return (rmQuals($T1, "all") eq rmQuals($T2, "all"));
140370d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
140380d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
140390d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub addedQual($$$)
140400d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
140410d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Old_Value, $New_Value, $Qual) = @_;
14042fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return removedQual_I($New_Value, $Old_Value, 2, 1, $Qual);
140430d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
140440d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
140451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub removedQual($$$)
14046ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
140471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Old_Value, $New_Value, $Qual) = @_;
14048fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return removedQual_I($Old_Value, $New_Value, 1, 2, $Qual);
140490d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
140500d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
14051fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub removedQual_I($$$$$)
140520d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
140530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Old_Value, $New_Value, $V1, $V2, $Qual) = @_;
140540d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $Old_Value = uncover_typedefs($Old_Value, $V1);
140550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $New_Value = uncover_typedefs($New_Value, $V2);
140560d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($Old_Value eq $New_Value)
140570d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # equal types
14058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
14059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1406062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($Old_Value!~/\b$Qual\b/)
140610d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # without a qual
140620d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return 0;
140630d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
1406462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif($New_Value!~/\b$Qual\b/)
140650d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # became non-qual
140660d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return 1;
140670d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
140680d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    else
140690d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
140700d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        my @BQ1 = getQualModel($Old_Value, $Qual);
140710d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        my @BQ2 = getQualModel($New_Value, $Qual);
140720d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        foreach (0 .. $#BQ1)
140730d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # removed qual
140740d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if($BQ1[$_]==1
140750d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and $BQ2[$_]!=1)
140760d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
140770d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                return 2;
140780d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
14079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
14082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
140840d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub getQualModel($$)
140850d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
140860d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Value, $Qual) = @_;
140870d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(not $Qual) {
140880d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return $Value;
140890d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
140900d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
140910d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    # cleaning
1409262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    while($Value=~/(\w+)/ and $1 ne $Qual) {
1409362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $Value=~s/\b$1\b//g;
140940d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
140950d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $Value=~s/[^\*\&\w]+//g;
140960d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
140970d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    # modeling
140980d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    # int*const*const == 011
140990d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    # int**const == 001
141000d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my @Model = ();
141010d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my @Elems = split(/[\*\&]/, $Value);
141020d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(not @Elems) {
141030d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return (0);
141040d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
141050d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    foreach (@Elems)
141060d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
141070d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($_ eq $Qual) {
141080d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            push(@Model, 1);
141090d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
141100d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        else {
141110d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            push(@Model, 0);
141120d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
141130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
141140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
141150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return @Model;
141160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
141170d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
141184b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenkomy %StringTypes = map {$_=>1} (
141194b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    "char*",
141204b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    "char const*"
141214b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko);
141224b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko
141234b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenkomy %CharTypes = map {$_=>1} (
141244b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    "char",
141254b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    "char const"
141264b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko);
141274b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko
141280d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub showVal($$$)
141290d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
141300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Value, $TypeId, $LibVersion) = @_;
14131f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %PureType = get_PureType($TypeId, $TypeInfo{$LibVersion});
14132a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    my $TName = uncover_typedefs($PureType{"Name"}, $LibVersion);
1413301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(substr($Value, 0, 2) eq "_Z")
1413401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    {
1413501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(my $Unmangled = $tr_name{$Value}) {
1413601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            return $Unmangled;
1413701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
1413801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    }
141394b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    elsif(defined $StringTypes{$TName} or $TName=~/string/i)
141400d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # strings
141410d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return "\"$Value\"";
141420d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
141434b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    elsif(defined $CharTypes{$TName})
141440d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # characters
141450d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return "\'$Value\'";
141460d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
141474b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    if($Value eq "")
141484b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    { # other
141494b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        return "\'\'";
141504b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    }
141510d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return $Value;
141520d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
141530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
14154fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub getRegs($$$)
14155fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko{
14156fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my ($LibVersion, $Symbol, $Pos) = @_;
14157fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14158fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(defined $CompleteSignature{$LibVersion}{$Symbol}{"Reg"})
14159fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
14160fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        my %Regs = ();
14161fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        foreach my $Elem (sort keys(%{$CompleteSignature{$LibVersion}{$Symbol}{"Reg"}}))
14162fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
14163ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko            if($Elem=~/\A$Pos([\.\+]|\Z)/) {
14164fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $Regs{$CompleteSignature{$LibVersion}{$Symbol}{"Reg"}{$Elem}} = 1;
14165fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
14166fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
14167fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14168fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return join(", ", sort keys(%Regs));
14169fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
14170fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14171fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return undef;
14172fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko}
14173fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14174ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenkosub mergeParameters($$$$$$)
14175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
14176ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko    my ($Symbol, $PSymbol, $ParamPos1, $ParamPos2, $Level, $ChkRnmd) = @_;
141770d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(not $Symbol) {
141780d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return;
141790d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
14180dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my $PType1_Id = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos1}{"type"};
14181dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my $PName1 = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos1}{"name"};
14182dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my $PType2_Id = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos2}{"type"};
14183dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my $PName2 = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos2}{"name"};
141840d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(not $PType1_Id
141850d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    or not $PType2_Id) {
141860d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return;
141870d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
14188ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko
14189177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(index($Symbol, "_Z")==0)
14190177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    { # do not merge "this"
14191177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($PName1 eq "this" or $PName2 eq "this") {
14192177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return;
14193177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
14194ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko    }
14195ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko
1419662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type1 = get_Type($PType1_Id, 1);
1419762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type2 = get_Type($PType2_Id, 2);
1419862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %BaseType1 = get_BaseType($PType1_Id, 1);
1419962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %BaseType2 = get_BaseType($PType2_Id, 2);
142000d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $Parameter_Location = ($PName1)?$PName1:showPos($ParamPos1)." Parameter";
14201ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko
142021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Level eq "Binary")
142031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
1420462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(checkDump(1, "2.6.1") and checkDump(2, "2.6.1"))
142051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # "reg" attribute added in ACC 1.95.1 (dump 2.6.1 format)
142061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos1}{"reg"}
142071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and not $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos2}{"reg"})
142081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
142091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Symbol}{"Parameter_Became_Non_Register"}{$Parameter_Location}}=(
14210dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    "Target"=>$PName1,
142111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    "Param_Pos"=>$ParamPos1  );
142121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
142131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            elsif(not $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos1}{"reg"}
142141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos2}{"reg"})
142151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
142161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Symbol}{"Parameter_Became_Register"}{$Parameter_Location}}=(
14217dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    "Target"=>$PName1,
142181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    "Param_Pos"=>$ParamPos1  );
142191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
14220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14221fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14222fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(defined $UsedDump{1}{"DWARF"}
14223fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        and defined $UsedDump{2}{"DWARF"})
14224fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
14225fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(checkDump(1, "3.0") and checkDump(2, "3.0"))
14226fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
14227fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Old_Regs = getRegs(1, $Symbol, $ParamPos1);
14228fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $New_Regs = getRegs(2, $PSymbol, $ParamPos2);
14229fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Old_Regs and $New_Regs)
14230fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
14231fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if($Old_Regs ne $New_Regs)
14232fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    {
14233fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{"Parameter_Changed_Register"}{$Parameter_Location}}=(
14234fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            "Target"=>$PName1,
14235fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            "Param_Pos"=>$ParamPos1,
14236fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            "Old_Value"=>$Old_Regs,
14237fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            "New_Value"=>$New_Regs  );
14238fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
14239fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
14240fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                elsif($Old_Regs and not $New_Regs)
14241fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
14242fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$CompatProblems{$Level}{$Symbol}{"Parameter_From_Register"}{$Parameter_Location}}=(
14243fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Target"=>$PName1,
14244fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Param_Pos"=>$ParamPos1,
14245fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Old_Value"=>$Old_Regs  );
14246fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
14247fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                elsif(not $Old_Regs and $New_Regs)
14248fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
14249fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$CompatProblems{$Level}{$Symbol}{"Parameter_To_Register"}{$Parameter_Location}}=(
14250fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Target"=>$PName1,
14251fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Param_Pos"=>$ParamPos1,
14252fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "New_Value"=>$New_Regs  );
14253fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
14254fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if((my $Old_Offset = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos1}{"offset"}) ne ""
14255fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and (my $New_Offset = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos2}{"offset"}) ne "")
14256fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
14257fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if($Old_Offset ne $New_Offset)
14258fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    {
14259fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{"Parameter_Changed_Offset"}{$Parameter_Location}}=(
14260fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            "Target"=>$PName1,
14261fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            "Param_Pos"=>$ParamPos1,
14262fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            "Old_Value"=>$Old_Offset,
14263fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            "New_Value"=>$New_Offset  );
14264fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
14265fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
14266fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
14267fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
14268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14269177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(checkDump(1, "2.0") and checkDump(2, "2.0")
14270177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    and $UsedDump{1}{"V"} ne "3.1" and $UsedDump{2}{"V"} ne "3.1")
14271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # "default" attribute added in ACC 1.22 (dump 2.0 format)
14272177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko      # broken in 3.1, fixed in 3.2
142730d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        my $Value_Old = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos1}{"default"};
142740d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        my $Value_New = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos2}{"default"};
1427562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not checkDump(1, "2.13")
1427662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        and checkDump(2, "2.13"))
142770d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # support for old ABI dumps
142780d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(defined $Value_Old and defined $Value_New)
142790d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
142800d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if($Type1{"Name"} eq "bool"
142810d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                and $Value_Old eq "false" and $Value_New eq "0")
142820d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                { # int class::method ( bool p = 0 );
142830d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                  # old ABI dumps: "false"
142840d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                  # new ABI dumps: "0"
142850d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    $Value_Old = "0";
142860d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
14287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1428901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(not checkDump(1, "2.18")
1429001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        and checkDump(2, "2.18"))
1429101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        { # support for old ABI dumps
1429201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if(not defined $Value_Old
1429301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            and substr($Value_New, 0, 2) eq "_Z") {
1429401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $Value_Old = $Value_New;
1429501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
1429601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
142970d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(defined $Value_Old)
14298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
142990d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $Value_Old = showVal($Value_Old, $PType1_Id, 1);
143000d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(defined $Value_New)
14301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
143020d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $Value_New = showVal($Value_New, $PType2_Id, 2);
143030d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if($Value_Old ne $Value_New)
143040d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                { # FIXME: how to distinguish "0" and 0 (NULL)
143051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    %{$CompatProblems{$Level}{$Symbol}{"Parameter_Default_Value_Changed"}{$Parameter_Location}}=(
14306dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        "Target"=>$PName1,
14307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Param_Pos"=>$ParamPos1,
143080d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        "Old_Value"=>$Value_Old,
143090d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        "New_Value"=>$Value_New  );
14310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
14313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
143141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Symbol}{"Parameter_Default_Value_Removed"}{$Parameter_Location}}=(
143150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    "Target"=>$PName1,
143160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    "Param_Pos"=>$ParamPos1,
143170d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    "Old_Value"=>$Value_Old  );
14318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
143200d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        elsif(defined $Value_New)
143210d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
143220d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $Value_New = showVal($Value_New, $PType2_Id, 2);
143230d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            %{$CompatProblems{$Level}{$Symbol}{"Parameter_Default_Value_Added"}{$Parameter_Location}}=(
143240d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                "Target"=>$PName1,
143250d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                "Param_Pos"=>$ParamPos1,
143260d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                "New_Value"=>$Value_New  );
143270d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
14328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14329ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko
14330ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko    if($ChkRnmd)
14331ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko    {
14332ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        if($PName1 and $PName2 and $PName1 ne $PName2
14333ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        and $PType1_Id!=-1 and $PType2_Id!=-1
14334ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        and $PName1!~/\Ap\d+\Z/ and $PName2!~/\Ap\d+\Z/)
14335ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        { # except unnamed "..." value list (Id=-1)
14336ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko            %{$CompatProblems{$Level}{$Symbol}{"Renamed_Parameter"}{showPos($ParamPos1)." Parameter"}}=(
14337ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                "Target"=>$PName1,
14338ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                "Param_Pos"=>$ParamPos1,
14339ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                "Param_Type"=>$TypeInfo{1}{$PType1_Id}{"Name"},
14340ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                "Old_Value"=>$PName1,
14341ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                "New_Value"=>$PName2,
14342ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                "New_Signature"=>get_Signature($Symbol, 2)  );
14343ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        }
14344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14345ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko
14346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # checking type change (replace)
14347dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my %SubProblems = detectTypeChange($PType1_Id, $PType2_Id, "Parameter", $Level);
14348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $SubProblemType (keys(%SubProblems))
14349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # add new problems, remove false alarms
14350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $New_Value = $SubProblems{$SubProblemType}{"New_Value"};
14351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Old_Value = $SubProblems{$SubProblemType}{"Old_Value"};
14352fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14353fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        # quals
14354fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($SubProblemType eq "Parameter_Type"
14355fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        or $SubProblemType eq "Parameter_Type_And_Size"
14356fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        or $SubProblemType eq "Parameter_Type_Format")
14357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1435862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(checkDump(1, "2.6") and checkDump(2, "2.6"))
14359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14360fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(addedQual($Old_Value, $New_Value, "restrict")) {
143610d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    %{$SubProblems{"Parameter_Became_Restrict"}} = %{$SubProblems{$SubProblemType}};
143621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
14363fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                elsif(removedQual($Old_Value, $New_Value, "restrict")) {
14364fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Parameter_Became_Non_Restrict"}} = %{$SubProblems{$SubProblemType}};
14365fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
14366fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
14367fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(checkDump(1, "2.6") and checkDump(2, "2.6"))
14368fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
14369fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(removedQual($Old_Value, $New_Value, "volatile")) {
14370fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Parameter_Became_Non_Volatile"}} = %{$SubProblems{$SubProblemType}};
14371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type2{"Type"} eq "Const" and $BaseType2{"Name"} eq $Type1{"Name"}
14374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and $Type1{"Type"}=~/Intrinsic|Class|Struct|Union|Enum/)
14375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # int to "int const"
14376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                delete($SubProblems{$SubProblemType});
14377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14378fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            elsif($Type1{"Type"} eq "Const" and $BaseType1{"Name"} eq $Type2{"Name"}
14379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and $Type2{"Type"}=~/Intrinsic|Class|Struct|Union|Enum/)
14380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # "int const" to int
14381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                delete($SubProblems{$SubProblemType});
14382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14383fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            elsif(my $RR = removedQual($Old_Value, $New_Value, "const"))
14384fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            { # "const" to non-"const"
14385fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($RR==2) {
14386fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Parameter_Removed_Const"}} = %{$SubProblems{$SubProblemType}};
14387fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
14388fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else {
14389fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Parameter_Became_Non_Const"}} = %{$SubProblems{$SubProblemType}};
14390fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
14391fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
14392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14394fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14395fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($Level eq "Source")
14396fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
14397fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        foreach my $SubProblemType (keys(%SubProblems))
14398fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
14399fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my $New_Value = $SubProblems{$SubProblemType}{"New_Value"};
14400fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my $Old_Value = $SubProblems{$SubProblemType}{"Old_Value"};
14401fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14402fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($SubProblemType eq "Parameter_Type")
14403fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
14404fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(cmpBTypes($Old_Value, $New_Value, 1, 2)) {
14405fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    delete($SubProblems{$SubProblemType});
14406fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
14407fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
14408fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
14409fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
14410fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $SubProblemType (keys(%SubProblems))
14412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # modify/register problems
14413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $New_Value = $SubProblems{$SubProblemType}{"New_Value"};
14414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Old_Value = $SubProblems{$SubProblemType}{"Old_Value"};
14415f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my $New_Size = $SubProblems{$SubProblemType}{"New_Size"};
14416f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my $Old_Size = $SubProblems{$SubProblemType}{"Old_Size"};
14417fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $NewProblemType = $SubProblemType;
14419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Old_Value eq "..." and $New_Value ne "...")
14420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # change from "..." to "int"
14421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ParamPos1==0)
14422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # ISO C requires a named argument before "..."
14423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
14424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14425fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $NewProblemType = "Parameter_Became_Non_VaList";
14426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($New_Value eq "..." and $Old_Value ne "...")
14428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # change from "int" to "..."
14429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ParamPos2==0)
14430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # ISO C requires a named argument before "..."
14431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
14432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $NewProblemType = "Parameter_Became_VaList";
14434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
144351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif($Level eq "Binary" and ($SubProblemType eq "Parameter_Type_And_Size"
14436f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        or $SubProblemType eq "Parameter_Type" or $SubProblemType eq "Parameter_Type_Format"))
14437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
14438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my ($Arch1, $Arch2) = (getArch(1), getArch(2));
14439f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($Arch1 eq "unknown"
14440f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            or $Arch2 eq "unknown")
14441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # if one of the architectures is unknown
14442f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko              # then set other arhitecture to unknown too
14443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                ($Arch1, $Arch2) = ("unknown", "unknown");
14444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14445f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            my (%Conv1, %Conv2) = ();
14446fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($UseConv_Real{1}{"P"} and $UseConv_Real{2}{"P"})
14447f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            { # real
14448f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                %Conv1 = callingConvention_P_Real($CompleteSignature{1}{$Symbol}, $ParamPos1);
14449f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                %Conv2 = callingConvention_P_Real($CompleteSignature{2}{$Symbol}, $ParamPos2);
14450f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
14451f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            else
14452f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            { # model
14453f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                %Conv1 = callingConvention_P_Model($CompleteSignature{1}{$Symbol}, $ParamPos1, $TypeInfo{1}, $Arch1, $OStarget, $WORD_SIZE{1});
14454f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                %Conv2 = callingConvention_P_Model($CompleteSignature{2}{$Symbol}, $ParamPos2, $TypeInfo{2}, $Arch2, $OStarget, $WORD_SIZE{2});
14455f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
14456f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($Conv1{"Method"} eq $Conv2{"Method"})
14457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14458f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                if($Conv1{"Method"} eq "stack")
14459f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
14460f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    if($Old_Size ne $New_Size) { # FIXME: isMemPadded, getOffset
14461f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        $NewProblemType = "Parameter_Type_And_Stack";
14462f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    }
14463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14464f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                elsif($Conv1{"Method"} eq "reg")
14465f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
14466f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    if($Conv1{"Registers"} ne $Conv2{"Registers"}) {
14467f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        $NewProblemType = "Parameter_Type_And_Register";
14468f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    }
14469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
14472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14473f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                if($Conv1{"Method"} eq "stack") {
14474f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    $NewProblemType = "Parameter_Type_From_Stack_To_Register";
14475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14476f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                elsif($Conv1{"Method"} eq "register") {
14477f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    $NewProblemType = "Parameter_Type_From_Register_To_Stack";
14478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14480f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $SubProblems{$SubProblemType}{"Old_Reg"} = $Conv1{"Registers"};
14481f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $SubProblems{$SubProblemType}{"New_Reg"} = $Conv2{"Registers"};
14482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
144831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        %{$CompatProblems{$Level}{$Symbol}{$NewProblemType}{$Parameter_Location}}=(
14484dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            "Target"=>$PName1,
14485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "Param_Pos"=>$ParamPos1,
144861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            "New_Signature"=>get_Signature($Symbol, 2) );
144871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        @{$CompatProblems{$Level}{$Symbol}{$NewProblemType}{$Parameter_Location}}{keys(%{$SubProblems{$SubProblemType}})} = values %{$SubProblems{$SubProblemType}};
14488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14489ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    @RecurTypes = ();
14490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # checking type definition changes
1449162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %SubProblems_Merge = mergeTypes($PType1_Id, $PType2_Id, $Level);
14492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $SubProblemType (keys(%SubProblems_Merge))
14493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
14494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $SubLocation (keys(%{$SubProblems_Merge{$SubProblemType}}))
14495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
14496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $NewProblemType = $SubProblemType;
14497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($SubProblemType eq "DataType_Size")
14498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14499ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $InitialType_Type = $SubProblems_Merge{$SubProblemType}{$SubLocation}{"InitialType_Type"};
14500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($InitialType_Type!~/\A(Pointer|Ref)\Z/ and $SubLocation!~/\-\>/)
14501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # stack has been affected
14502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $NewProblemType = "DataType_Size_And_Stack";
14503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $NewLocation = ($SubLocation)?$Parameter_Location."->".$SubLocation:$Parameter_Location;
145061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            %{$CompatProblems{$Level}{$Symbol}{$NewProblemType}{$NewLocation}}=(
1450762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                "Param_Type"=>$TypeInfo{1}{$PType1_Id}{"Name"},
14508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                "Param_Pos"=>$ParamPos1,
14509dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                "Param_Name"=>$PName1  );
145101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            @{$CompatProblems{$Level}{$Symbol}{$NewProblemType}{$NewLocation}}{keys(%{$SubProblems_Merge{$SubProblemType}{$SubLocation}})} = values %{$SubProblems_Merge{$SubProblemType}{$SubLocation}};
14511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($SubLocation!~/\-\>/) {
1451262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $CompatProblems{$Level}{$Symbol}{$NewProblemType}{$NewLocation}{"Start_Type_Name"} = $TypeInfo{1}{$PType1_Id}{"Name"};
14513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14517ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
14518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub find_ParamPair_Pos_byName($$$)
14519ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
145201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Name, $Symbol, $LibVersion) = @_;
145211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $ParamPos (sort {int($a)<=>int($b)} keys(%{$CompleteSignature{$LibVersion}{$Symbol}{"Param"}}))
14522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
145231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        next if(not defined $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$ParamPos});
145241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$ParamPos}{"name"} eq $Name)
14525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
14526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $ParamPos;
14527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "lost";
14530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
14532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub find_ParamPair_Pos_byTypeAndPos($$$$$)
14533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
145341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($TypeName, $MediumPos, $Order, $Symbol, $LibVersion) = @_;
14535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Positions = ();
145361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $ParamPos (sort {int($a)<=>int($b)} keys(%{$CompleteSignature{$LibVersion}{$Symbol}{"Param"}}))
14537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
14538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($Order eq "backward" and $ParamPos>$MediumPos);
14539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($Order eq "forward" and $ParamPos<$MediumPos);
145401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        next if(not defined $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$ParamPos});
145411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $PTypeId = $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$ParamPos}{"type"};
1454262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($TypeInfo{$LibVersion}{$PTypeId}{"Name"} eq $TypeName) {
14543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            push(@Positions, $ParamPos);
14544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @Positions;
14547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
14549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTypeIdByName($$)
14550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
14551e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    my ($TypeName, $LibVersion) = @_;
14552e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    return $TName_Tid{$LibVersion}{formatName($TypeName, "T")};
14553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
145558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub diffTypes($$$)
145568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko{
145578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(defined $Cache{"diffTypes"}{$_[2]}{$_[0]}{$_[1]}) {
145588f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return $Cache{"diffTypes"}{$_[2]}{$_[0]}{$_[1]};
145598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
145608f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(isRecurType($_[0], $_[1], \@RecurTypes_Diff))
145618f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # skip recursive declarations
145628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 0;
145638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
145648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
145658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    pushType($_[0], $_[1], \@RecurTypes_Diff);
145668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Diff = diffTypes_I(@_);
145678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    pop(@RecurTypes_Diff);
145688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
145698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return ($Cache{"diffTypes"}{$_[2]}{$_[0]}{$_[1]} = $Diff);
145708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko}
145718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
145728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub diffTypes_I($$$)
14573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
145741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Type1_Id, $Type2_Id, $Level) = @_;
145758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
14576f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type1_Pure = get_PureType($Type1_Id, $TypeInfo{1});
14577f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type2_Pure = get_PureType($Type2_Id, $TypeInfo{2});
145788f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
14579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type1_Pure{"Name"} eq $Type2_Pure{"Name"})
14580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # equal types
14581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
14582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
145839927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($Type1_Pure{"Name"} eq "void")
145849927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # from void* to something
145859927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return 0;
145869927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
14587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type1_Pure{"Name"}=~/\*/
14588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $Type2_Pure{"Name"}=~/\*/)
14589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # compared in detectTypeChange()
14590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
14591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
145928f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
14593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %FloatType = map {$_=>1} (
14594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "float",
14595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "double",
14596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "long double"
14597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
14598fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14599fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $T1 = $Type1_Pure{"Type"};
14600fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $T2 = $Type2_Pure{"Type"};
14601fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14602fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($T1 eq "Struct"
14603fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    and $T2 eq "Class")
14604fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # compare as data structures
14605fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $T2 = "Struct";
14606fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
14607fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14608fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($T1 eq "Class"
14609fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    and $T2 eq "Struct")
14610fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # compare as data structures
14611fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $T1 = "Struct";
14612fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
14613fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14614fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($T1 ne $T2)
14615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # different types
14616fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($T1 eq "Intrinsic"
14617fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        and $T2 eq "Enum")
14618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # "int" to "enum"
14619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
14620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14621fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        elsif($T2 eq "Intrinsic"
14622fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        and $T1 eq "Enum")
14623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # "enum" to "int"
14624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
14625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
14627fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # union to struct
14628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          #  ...
14629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
14630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
14633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
14634fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($T1 eq "Intrinsic")
14635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
14636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($FloatType{$Type1_Pure{"Name"}}
14637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            or $FloatType{$Type2_Pure{"Name"}})
14638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # "float" to "double"
14639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # "float" to "int"
146401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Source")
146411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # Safe
146421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    return 0;
146431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
146441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                else {
146451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    return 1;
146461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
14647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14649fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        elsif($T1=~/Class|Struct|Union|Enum/)
14650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
14651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my @Membs1 = keys(%{$Type1_Pure{"Memb"}});
14652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my @Membs2 = keys(%{$Type2_Pure{"Memb"}});
14653fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(not @Membs1
14654fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            or not @Membs2)
14655570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            { # private
14656570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                return 0;
14657570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
14658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($#Membs1!=$#Membs2)
14659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # different number of elements
14660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return 1;
14661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14662fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($T1 eq "Enum")
14663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Pos (@Membs1)
14665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # compare elements by name and value
14666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($Type1_Pure{"Memb"}{$Pos}{"name"} ne $Type2_Pure{"Memb"}{$Pos}{"name"}
14667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    or $Type1_Pure{"Memb"}{$Pos}{"value"} ne $Type2_Pure{"Memb"}{$Pos}{"value"})
14668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # different names
14669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        return 1;
14670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
14671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
14674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Pos (@Membs1)
146768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                {
146771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Level eq "Source")
146781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
146791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($Type1_Pure{"Memb"}{$Pos}{"name"} ne $Type2_Pure{"Memb"}{$Pos}{"name"})
146801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        { # different names
146811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            return 1;
146821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
146831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
146848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
146858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my %MT1 = %{$TypeInfo{1}{$Type1_Pure{"Memb"}{$Pos}{"type"}}};
146868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my %MT2 = %{$TypeInfo{2}{$Type2_Pure{"Memb"}{$Pos}{"type"}}};
146878f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
146888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    if($MT1{"Name"} ne $MT2{"Name"}
146898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    or isAnon($MT1{"Name"}) or isAnon($MT2{"Name"}))
146908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    {
146918f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        my $PL1 = get_PLevel($MT1{"Tid"}, 1);
146928f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        my $PL2 = get_PLevel($MT2{"Tid"}, 2);
146938f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
146948f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        if($PL1 ne $PL2)
146958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        { # different pointer level
146968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                            return 1;
146978f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        }
146988f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
146998f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        # compare base types
147008f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        my %BT1 = get_BaseType($MT1{"Tid"}, 1);
147018f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        my %BT2 = get_BaseType($MT2{"Tid"}, 2);
147028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
147038f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        if(diffTypes($BT1{"Tid"}, $BT2{"Tid"}, $Level))
147048f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        { # different types
147058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                            return 1;
147068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        }
147078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    }
14708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
147118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        else
147128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
147138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            # TODO: arrays, etc.
147148f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
14715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
14717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
147191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub detectTypeChange($$$$)
14720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
147211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Type1_Id, $Type2_Id, $Prefix, $Level) = @_;
14722dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if(not $Type1_Id or not $Type2_Id) {
14723dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        return ();
14724dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
14725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %LocalProblems = ();
1472662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type1 = get_Type($Type1_Id, 1);
1472762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type2 = get_Type($Type2_Id, 2);
14728f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type1_Pure = get_PureType($Type1_Id, $TypeInfo{1});
14729f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type2_Pure = get_PureType($Type2_Id, $TypeInfo{2});
14730f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type1_Base = ($Type1_Pure{"Type"} eq "Array")?get_OneStep_BaseType($Type1_Pure{"Tid"}, $TypeInfo{1}):get_BaseType($Type1_Id, 1);
14731f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type2_Base = ($Type2_Pure{"Type"} eq "Array")?get_OneStep_BaseType($Type2_Pure{"Tid"}, $TypeInfo{2}):get_BaseType($Type2_Id, 2);
1473274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1473362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $Type1_PLevel = get_PLevel($Type1_Id, 1);
1473462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $Type2_PLevel = get_PLevel($Type2_Id, 2);
14735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $Type1{"Name"} or not $Type2{"Name"});
14736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $Type1_Base{"Name"} or not $Type2_Base{"Name"});
14737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if($Type1_PLevel eq "" or $Type2_PLevel eq "");
14738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type1_Base{"Name"} ne $Type2_Base{"Name"}
14739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and ($Type1{"Name"} eq $Type2{"Name"} or ($Type1_PLevel>=1 and $Type1_PLevel==$Type2_PLevel
14740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Type1_Base{"Name"} ne "void" and $Type2_Base{"Name"} ne "void")))
14741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # base type change
147429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($Type1{"Name"} eq $Type2{"Name"})
147439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
147449927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($Type1{"Type"} eq "Typedef" and $Type2{"Type"} eq "Typedef")
147459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # will be reported in mergeTypes() as typedef problem
147469927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                return ();
147479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
147489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            my %Typedef_1 = goToFirst($Type1{"Tid"}, 1, "Typedef");
147499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            my %Typedef_2 = goToFirst($Type2{"Tid"}, 2, "Typedef");
147509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(%Typedef_1 and %Typedef_2)
147519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
147529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if($Typedef_1{"Name"} eq $Typedef_2{"Name"}
147539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                and $Typedef_1{"Type"} eq "Typedef" and $Typedef_2{"Type"} eq "Typedef")
147549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                { # const Typedef
147559927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    return ();
147569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
147579927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
14758ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type1_Base{"Name"}!~/anon\-/ and $Type2_Base{"Name"}!~/anon\-/)
14760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
147611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Binary"
147628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            and $Type1_Base{"Size"} and $Type2_Base{"Size"}
147638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            and $Type1_Base{"Size"} ne $Type2_Base{"Size"})
14764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$LocalProblems{$Prefix."_BaseType_And_Size"}}=(
14766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Old_Value"=>$Type1_Base{"Name"},
14767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "New_Value"=>$Type2_Base{"Name"},
14768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Old_Size"=>$Type1_Base{"Size"}*$BYTE_SIZE,
14769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "New_Size"=>$Type2_Base{"Size"}*$BYTE_SIZE,
14770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "InitialType_Type"=>$Type1_Pure{"Type"});
14771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
14773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
147748f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if(diffTypes($Type1_Base{"Tid"}, $Type2_Base{"Tid"}, $Level))
14775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # format change
14776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$LocalProblems{$Prefix."_BaseType_Format"}}=(
14777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Value"=>$Type1_Base{"Name"},
14778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Value"=>$Type2_Base{"Name"},
14779f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        "Old_Size"=>$Type1_Base{"Size"}*$BYTE_SIZE,
14780f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        "New_Size"=>$Type2_Base{"Size"}*$BYTE_SIZE,
14781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "InitialType_Type"=>$Type1_Pure{"Type"});
14782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                elsif(tNameLock($Type1_Base{"Tid"}, $Type2_Base{"Tid"}))
14784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
14785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$LocalProblems{$Prefix."_BaseType"}}=(
14786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Value"=>$Type1_Base{"Name"},
14787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Value"=>$Type2_Base{"Name"},
14788f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        "Old_Size"=>$Type1_Base{"Size"}*$BYTE_SIZE,
14789f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        "New_Size"=>$Type2_Base{"Size"}*$BYTE_SIZE,
14790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "InitialType_Type"=>$Type1_Pure{"Type"});
14791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Type1{"Name"} ne $Type2{"Name"})
14796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # type change
14797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type1{"Name"}!~/anon\-/ and $Type2{"Name"}!~/anon\-/)
14798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
14799f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($Prefix eq "Return"
14800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and $Type1_Pure{"Name"} eq "void")
14801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$LocalProblems{"Return_Type_From_Void"}}=(
14803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "New_Value"=>$Type2{"Name"},
14804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "New_Size"=>$Type2{"Size"}*$BYTE_SIZE,
14805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "InitialType_Type"=>$Type1_Pure{"Type"});
14806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Prefix eq "Return"
14808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and $Type2_Pure{"Name"} eq "void")
14809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$LocalProblems{"Return_Type_Became_Void"}}=(
14811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Old_Value"=>$Type1{"Name"},
14812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Old_Size"=>$Type1{"Size"}*$BYTE_SIZE,
14813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "InitialType_Type"=>$Type1_Pure{"Type"});
14814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
14816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
148171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary"
14818dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                and $Type1{"Size"} and $Type2{"Size"}
14819dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                and $Type1{"Size"} ne $Type2{"Size"})
14820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
14821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$LocalProblems{$Prefix."_Type_And_Size"}}=(
14822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Value"=>$Type1{"Name"},
14823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Value"=>$Type2{"Name"},
14824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Size"=>$Type1{"Size"}*$BYTE_SIZE,
14825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Size"=>$Type2{"Size"}*$BYTE_SIZE,
14826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "InitialType_Type"=>$Type1_Pure{"Type"});
14827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else
14829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
148308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    if(diffTypes($Type1_Id, $Type2_Id, $Level))
14831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # format change
14832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        %{$LocalProblems{$Prefix."_Type_Format"}}=(
14833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            "Old_Value"=>$Type1{"Name"},
14834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            "New_Value"=>$Type2{"Name"},
14835f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            "Old_Size"=>$Type1{"Size"}*$BYTE_SIZE,
14836f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            "New_Size"=>$Type2{"Size"}*$BYTE_SIZE,
14837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            "InitialType_Type"=>$Type1_Pure{"Type"});
14838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
14839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    elsif(tNameLock($Type1_Id, $Type2_Id))
14840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # FIXME: correct this condition
14841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        %{$LocalProblems{$Prefix."_Type"}}=(
14842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            "Old_Value"=>$Type1{"Name"},
14843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            "New_Value"=>$Type2{"Name"},
14844f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            "Old_Size"=>$Type1{"Size"}*$BYTE_SIZE,
14845f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            "New_Size"=>$Type2{"Size"}*$BYTE_SIZE,
14846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            "InitialType_Type"=>$Type1_Pure{"Type"});
14847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
14848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type1_PLevel!=$Type2_PLevel)
14853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
14854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type1{"Name"} ne "void" and $Type1{"Name"} ne "..."
14855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Type2{"Name"} ne "void" and $Type2{"Name"} ne "...")
14856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
148571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Source")
148581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
148591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$LocalProblems{$Prefix."_PointerLevel"}}=(
14860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Old_Value"=>$Type1_PLevel,
14861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "New_Value"=>$Type2_PLevel);
14862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
148631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            else
148641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
14865fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Type2_PLevel>$Type1_PLevel)
14866fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
148671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    %{$LocalProblems{$Prefix."_PointerLevel_Increased"}}=(
148681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        "Old_Value"=>$Type1_PLevel,
148691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        "New_Value"=>$Type2_PLevel);
148701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
14871fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else
14872fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
148731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    %{$LocalProblems{$Prefix."_PointerLevel_Decreased"}}=(
148741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        "Old_Value"=>$Type1_PLevel,
148751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        "New_Value"=>$Type2_PLevel);
148761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
14877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type1_Pure{"Type"} eq "Array")
14881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # base_type[N] -> base_type[N]
14882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # base_type: older_structure -> typedef to newer_structure
148831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my %SubProblems = detectTypeChange($Type1_Base{"Tid"}, $Type2_Base{"Tid"}, $Prefix, $Level);
14884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $SubProblemType (keys(%SubProblems))
14885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
14886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SubProblemType=~s/_Type/_BaseType/g;
14887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(defined $LocalProblems{$SubProblemType});
14888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Attr (keys(%{$SubProblems{$SubProblemType}})) {
14889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $LocalProblems{$SubProblemType}{$Attr} = $SubProblems{$SubProblemType}{$Attr};
14890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return %LocalProblems;
14894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
14896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub tNameLock($$)
14897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
14898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Tid1, $Tid2) = @_;
148990d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $Changed = 0;
149000d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(differentDumps("G"))
149010d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # different GCC versions
149020d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        $Changed = 1;
149030d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
149040d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    elsif(differentDumps("V"))
149050d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # different versions of ABI dumps
1490674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(not checkDump(1, "2.20")
1490774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        or not checkDump(2, "2.20"))
149080d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # latest names update
149090d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko          # 2.6: added restrict qualifier
149100d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko          # 2.13: added missed typedefs to qualified types
1491174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko          # 2.20: prefix for struct, union and enum types
149120d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $Changed = 1;
149130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
149140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
149158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
149168f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $TN1 = $TypeInfo{1}{$Tid1}{"Name"};
149178f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $TN2 = $TypeInfo{2}{$Tid2}{"Name"};
149188f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
149190d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($Changed)
14920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # different formats
14921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($UseOldDumps)
14922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # old dumps
14923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
14924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
149250d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
1492662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $TT1 = $TypeInfo{1}{$Tid1}{"Type"};
1492762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $TT2 = $TypeInfo{2}{$Tid2}{"Type"};
149280d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
1492962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Base1 = get_Type($Tid1, 1);
149300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        while(defined $Base1{"Type"} and $Base1{"Type"} eq "Typedef") {
14931f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            %Base1 = get_OneStep_BaseType($Base1{"Tid"}, $TypeInfo{1});
14932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1493362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Base2 = get_Type($Tid2, 2);
149340d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        while(defined $Base2{"Type"} and $Base2{"Type"} eq "Typedef") {
14935f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            %Base2 = get_OneStep_BaseType($Base2{"Tid"}, $TypeInfo{2});
14936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14937850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $BName1 = uncover_typedefs($Base1{"Name"}, 1);
14938850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $BName2 = uncover_typedefs($Base2{"Name"}, 2);
14939850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($BName1 eq $BName2)
14940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # equal base types
14941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
14942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
149430d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
1494462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not checkDump(1, "2.13")
1494562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        or not checkDump(2, "2.13"))
149460d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # broken array names in ABI dumps < 2.13
149470d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if($TT1 eq "Array"
1494874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            and $TT2 eq "Array") {
149490d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                return 0;
149500d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
149510d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
149520d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
1495362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not checkDump(1, "2.6")
1495462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        or not checkDump(2, "2.6"))
149550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # added restrict attribute in 2.6
1495662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($TN1!~/\brestrict\b/
1495774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            and $TN2=~/\brestrict\b/) {
1495874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                return 0;
1495974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
1496074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
1496174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1496274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(not checkDump(1, "2.20")
1496374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        or not checkDump(2, "2.20"))
1496474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        { # added restrict attribute in 2.6
1496574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if($TN1=~/\A(struct|union|enum) \Q$TN2\E\Z/
1496674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            or $TN2=~/\A(struct|union|enum) \Q$TN1\E\Z/) {
14967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return 0;
14968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
149718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    else
149728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
149738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        # typedef struct {...} type_t
149748f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        # typedef struct type_t {...} type_t
149758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(index($TN1, " ".$TN2)!=-1)
149768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
149778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($TN1=~/\A(struct|union|enum) \Q$TN2\E\Z/) {
149788f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                return 0;
149798f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
149808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
149818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(index($TN2, " ".$TN1)!=-1)
149828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
149838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($TN2=~/\A(struct|union|enum) \Q$TN1\E\Z/) {
149848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                return 0;
149858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
149868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
149878f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
14988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1;
14989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
149911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub differentDumps($)
14992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
149931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Check = $_[0];
14994989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(defined $Cache{"differentDumps"}{$Check}) {
14995989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        return $Cache{"differentDumps"}{$Check};
14996989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
14997dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($UsedDump{1}{"V"} and $UsedDump{2}{"V"})
149981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
14999dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Check eq "G")
15000dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
15001dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(getGccVersion(1) ne getGccVersion(2))
15002dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            { # different GCC versions
15003989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                return ($Cache{"differentDumps"}{$Check}=1);
15004dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
150051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
15006dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Check eq "V")
15007dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
15008dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(cmpVersions(formatVersion($UsedDump{1}{"V"}, 2),
15009dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            formatVersion($UsedDump{2}{"V"}, 2))!=0)
15010dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            { # different dump versions (skip micro version)
15011989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                return ($Cache{"differentDumps"}{$Check}=1);
15012dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
150131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
15014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15015989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return ($Cache{"differentDumps"}{$Check}=0);
15016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub formatVersion($$)
15019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # cut off version digits
15020dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my ($V, $Digits) = @_;
15021dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my @Elems = split(/\./, $V);
15022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return join(".", splice(@Elems, 0, $Digits));
15023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub htmlSpecChars($)
15026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Str = $_[0];
150285c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if(not $Str) {
150295c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        return $Str;
15030dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
15031ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/\&([^#]|\Z)/&amp;$1/g;
15032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/</&lt;/g;
15033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/\-\>/&#45;&gt;/g; # &minus;
15034ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/>/&gt;/g;
150358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $Str=~s/([^ ]) ([^ ])/$1\@SP\@$2/g;
150368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $Str=~s/([^ ]) ([^ ])/$1\@SP\@$2/g;
15037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/ /&#160;/g; # &nbsp;
150388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $Str=~s/\@SP\@/ /g;
15039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/\n/<br\/>/g;
15040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/\"/&quot;/g;
15041ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/\'/&#39;/g;
15042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Str;
15043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15044ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
150455c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenkosub xmlSpecChars($)
150465c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko{
150475c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    my $Str = $_[0];
150485c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if(not $Str) {
150495c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        return $Str;
150505c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
150515c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko
150525c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    $Str=~s/\&([^#]|\Z)/&amp;$1/g;
150535c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    $Str=~s/</&lt;/g;
150545c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    $Str=~s/>/&gt;/g;
150555c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko
150565c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    $Str=~s/\"/&quot;/g;
150575c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    $Str=~s/\'/&#39;/g;
150585c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko
150595c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    return $Str;
150605c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko}
150615c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko
1506201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenkosub xmlSpecChars_R($)
1506301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko{
1506401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $Str = $_[0];
1506501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(not $Str) {
1506601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        return $Str;
1506701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    }
1506801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
1506901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $Str=~s/&amp;/&/g;
1507001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $Str=~s/&lt;/</g;
1507101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $Str=~s/&gt;/>/g;
1507201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
1507301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $Str=~s/&quot;/"/g;
1507401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $Str=~s/&#39;/'/g;
1507501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
1507601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    return $Str;
1507701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko}
1507801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
15079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub black_name($)
15080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
15082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "<span class='iname_b'>".highLight_Signature($Name)."</span>";
15083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub highLight_Signature($)
15086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Signature = $_[0];
15088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return highLight_Signature_PPos_Italic($Signature, "", 0, 0, 0);
15089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub highLight_Signature_Italic_Color($)
15092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Signature = $_[0];
15094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return highLight_Signature_PPos_Italic($Signature, "", 1, 1, 1);
15095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub separate_symbol($)
15098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Symbol = $_[0];
15100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Name, $Spec, $Ver) = ($Symbol, "", "");
15101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Symbol=~/\A([^\@\$\?]+)([\@\$]+)([^\@\$]+)\Z/) {
15102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        ($Name, $Spec, $Ver) = ($1, $2, $3);
15103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Name, $Spec, $Ver);
15105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub cut_f_attrs($)
15108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($_[0]=~s/(\))((| (const volatile|const|volatile))(| \[static\]))\Z/$1/) {
15110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $2;
15111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
15113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub highLight_Signature_PPos_Italic($$$$$)
15116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15117dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my ($FullSignature, $Param_Pos, $ItalicParams, $ColorParams, $ShowReturn) = @_;
15118dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    $Param_Pos = "" if(not defined $Param_Pos);
15119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($CheckObjectsOnly) {
15120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ItalicParams=$ColorParams=0;
15121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Signature, $VersionSpec, $SymbolVersion) = separate_symbol($FullSignature);
15123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Return = "";
15124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ShowRetVal and $Signature=~s/([^:]):([^:].+?)\Z/$1/g) {
15125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Return = $2;
15126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
151271693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $SCenter = find_center($Signature, "(");
15128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SCenter)
151291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # global data
15130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Signature = htmlSpecChars($Signature);
151318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Signature=~s!(\[data\])!<span class='attr'>$1</span>!g;
151321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Signature .= (($SymbolVersion)?"<span class='sym_ver'>&#160;$VersionSpec&#160;$SymbolVersion</span>":"");
15133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Return and $ShowReturn) {
151341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Signature .= "<span class='sym_p nowrap'> &#160;<b>:</b>&#160;&#160;".htmlSpecChars($Return)."</span>";
15135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Signature;
15137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Begin, $End) = (substr($Signature, 0, $SCenter), "");
15139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Begin.=" " if($Begin!~/ \Z/);
15140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $End = cut_f_attrs($Signature);
15141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Parts = ();
1514207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    my ($Short, $Params) = split_Signature($Signature);
1514307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    my @SParts = separate_Params($Params, 1, 1);
15144dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    foreach my $Pos (0 .. $#SParts)
15145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
15146dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        my $Part = $SParts[$Pos];
15147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Part=~s/\A\s+|\s+\Z//g;
15148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($Part_Styled, $ParamName) = (htmlSpecChars($Part), "");
15149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Part=~/\([\*]+(\w+)\)/i) {
15150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ParamName = $1;#func-ptr
15151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Part=~/(\w+)[\,\)]*\Z/i) {
15153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ParamName = $1;
15154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
151558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not $ParamName)
151568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
15157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            push(@Parts, $Part_Styled);
15158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
15159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($ItalicParams and not $TName_Tid{1}{$Part}
15161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and not $TName_Tid{2}{$Part})
15162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
151630d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            my $Style = "param";
15164dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if($Param_Pos ne ""
15165dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            and $Pos==$Param_Pos) {
151660d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $Style = "focus_p";
15167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($ColorParams) {
151690d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $Style = "color_p";
15170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
151710d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $Part_Styled =~ s!(\W)$ParamName([\,\)]|\Z)!$1<span class=\'$Style\'>$ParamName</span>$2!ig;
15172ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15173ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Part_Styled=~s/,(\w)/, $1/g;
15174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        push(@Parts, $Part_Styled);
15175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(@Parts)
15177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
15178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Num (0 .. $#Parts)
15179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Num==$#Parts)
15181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # add ")" to the last parameter
15182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Parts[$Num] = "<span class='nowrap'>".$Parts[$Num]." )</span>";
15183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif(length($Parts[$Num])<=45) {
15185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Parts[$Num] = "<span class='nowrap'>".$Parts[$Num]."</span>";
15186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
151881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Signature = htmlSpecChars($Begin)."<span class='sym_p'>(&#160;".join(" ", @Parts)."</span>".$End;
15189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
151911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Signature = htmlSpecChars($Begin)."<span class='sym_p'>(&#160;)</span>".$End;
15192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Return and $ShowReturn) {
151941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Signature .= "<span class='sym_p nowrap'> &#160;<b>:</b>&#160;&#160;".htmlSpecChars($Return)."</span>";
15195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
151961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $Signature=~s!\[\]![&#160;]!g;
151971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $Signature=~s!operator=!operator&#160;=!g;
151988f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $Signature=~s!(\[in-charge\]|\[not-in-charge\]|\[in-charge-deleting\]|\[static\])!<span class='attr'>$1</span>!g;
151998f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($SymbolVersion) {
152008f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Signature .= "<span class='sym_ver'>&#160;$VersionSpec&#160;$SymbolVersion</span>";
152018f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
152028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return $Signature;
15203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1520507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenkosub split_Signature($)
15206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1520707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    my $Signature = $_[0];
1520807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if(my $ShortName = substr($Signature, 0, find_center($Signature, "(")))
1520907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    {
1521007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        $Signature=~s/\A\Q$ShortName\E\(//g;
1521107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        cut_f_attrs($Signature);
1521207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        $Signature=~s/\)\Z//;
1521307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        return ($ShortName, $Signature);
1521407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    }
1521507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
1521607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    # error
1521707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    return ($Signature, "");
15218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1522007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenkosub separate_Params($$$)
15221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1522207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    my ($Params, $Comma, $Sp) = @_;
15223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Parts = ();
152241693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %B = ( "("=>0, "<"=>0, ")"=>0, ">"=>0 );
152251693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $Part = 0;
15226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Pos (0 .. length($Params) - 1)
15227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
152281693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $S = substr($Params, $Pos, 1);
152291693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(defined $B{$S}) {
1523007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $B{$S} += 1;
152311693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
152321693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($S eq "," and
152331693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $B{"("}==$B{")"} and $B{"<"}==$B{">"})
15234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
152351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Comma)
152361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # include comma
152371693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $Parts[$Part] .= $S;
15238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
152391693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $Part += 1;
15240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
152421693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $Parts[$Part] .= $S;
15243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1524507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if(not $Sp)
1524607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    { # remove spaces
1524707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        foreach (@Parts)
1524807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        {
1524907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            s/\A //g;
1525007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            s/ \Z//g;
1525107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        }
1525207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    }
15253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @Parts;
15254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
152561693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub find_center($$)
15257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Sign, $Target) = @_;
152591693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %B = ( "("=>0, "<"=>0, ")"=>0, ">"=>0 );
15260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Center = 0;
152611693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($Sign=~s/(operator([^\w\s\(\)]+|\(\)))//g)
152621693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # operators
15263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Center+=length($1);
15264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Pos (0 .. length($Sign)-1)
15266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
15267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $S = substr($Sign, $Pos, 1);
15268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($S eq $Target)
15269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($B{"("}==$B{")"}
15271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and $B{"<"}==$B{">"}) {
15272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return $Center;
15273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(defined $B{$S}) {
15276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $B{$S}+=1;
15277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Center+=1;
15279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
15281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub appendFile($$)
15284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Content) = @_;
15286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(not $Path);
15287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Dir = get_dirname($Path)) {
15288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        mkpath($Dir);
15289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
152901693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    open(FILE, ">>", $Path) || die ("can't open file \'$Path\': $!\n");
15291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    print FILE $Content;
15292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    close(FILE);
15293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub writeFile($$)
15296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Content) = @_;
15298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(not $Path);
15299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Dir = get_dirname($Path)) {
15300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        mkpath($Dir);
15301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
153021693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    open(FILE, ">", $Path) || die ("can't open file \'$Path\': $!\n");
15303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    print FILE $Content;
15304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    close(FILE);
15305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub readFile($)
15308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
15310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Path or not -f $Path);
153111693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    open(FILE, $Path);
15312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    local $/ = undef;
15313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Content = <FILE>;
15314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    close(FILE);
15315850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($Path!~/\.(tu|class|abi)\Z/) {
15316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Content=~s/\r/\n/g;
15317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Content;
15319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_filename($)
15322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # much faster than basename() from File::Basename module
15323850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(defined $Cache{"get_filename"}{$_[0]}) {
15324850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return $Cache{"get_filename"}{$_[0]};
15325850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
153261693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($_[0] and $_[0]=~/([^\/\\]+)[\/\\]*\Z/) {
15327850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return ($Cache{"get_filename"}{$_[0]}=$1);
15328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15329850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return ($Cache{"get_filename"}{$_[0]}="");
15330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_dirname($)
15333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # much faster than dirname() from File::Basename module
15334850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(defined $Cache{"get_dirname"}{$_[0]}) {
15335850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return $Cache{"get_dirname"}{$_[0]};
15336850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
153371693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($_[0] and $_[0]=~/\A(.*?)[\/\\]+[^\/\\]*[\/\\]*\Z/) {
15338850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return ($Cache{"get_dirname"}{$_[0]}=$1);
15339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15340850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return ($Cache{"get_dirname"}{$_[0]}="");
15341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub separate_path($) {
15344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return (get_dirname($_[0]), get_filename($_[0]));
15345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub esc($)
15348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Str = $_[0];
15350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/([()\[\]{}$ &'"`;,<>\+])/\\$1/g;
15351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Str;
15352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub readLineNum($$)
15355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Num) = @_;
15357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Path or not -f $Path);
153581693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    open(FILE, $Path);
15359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (1 ... $Num) {
15360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        <FILE>;
15361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Line = <FILE>;
15363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    close(FILE);
15364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Line;
15365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
153670d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub readAttributes($$)
15368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
153690d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Path, $Num) = @_;
15370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $Path or not -f $Path);
15371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %Attributes = ();
15372850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(readLineNum($Path, $Num)=~/<!--\s+(.+)\s+-->/)
15373850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
15374850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        foreach my $AttrVal (split(/;/, $1))
15375850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
15376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($AttrVal=~/(.+):(.+)/)
15377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
15378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my ($Name, $Value) = ($1, $2);
15379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Attributes{$Name} = $Value;
15380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return \%Attributes;
15384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub is_abs($) {
15387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($_[0]=~/\A(\/|\w+:[\/\\])/);
15388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15389ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_abs_path($)
15391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # abs_path() should NOT be called for absolute inputs
15392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # because it can change them
15393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
15394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not is_abs($Path)) {
15395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = abs_path($Path);
15396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Path;
15398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_OSgroup()
15401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15402f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my $N = $Config{"osname"};
15403f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if($N=~/macos|darwin|rhapsody/i) {
15404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "macos";
15405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15406f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    elsif($N=~/freebsd|openbsd|netbsd/i) {
15407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "bsd";
15408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15409f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    elsif($N=~/haiku|beos/i) {
15410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "beos";
15411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15412f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    elsif($N=~/symbian|epoc/i) {
15413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "symbian";
15414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15415f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    elsif($N=~/win/i) {
15416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "windows";
15417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
15419f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        return $N;
15420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getGccVersion($)
15424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
15426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($GCC_VERSION{$LibVersion})
15427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # dump version
15428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $GCC_VERSION{$LibVersion};
15429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($UsedDump{$LibVersion}{"V"})
15431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # old-version dumps
15432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "unknown";
15433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $GccVersion = get_dumpversion($GCC_PATH); # host version
15435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $GccVersion) {
15436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "unknown";
15437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $GccVersion;
15439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub showArch($)
15442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Arch = $_[0];
15444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Arch eq "arm"
15445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $Arch eq "mips") {
15446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return uc($Arch);
15447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Arch;
15449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getArch($)
15452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
15454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($CPU_ARCH{$LibVersion})
15455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # dump version
15456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $CPU_ARCH{$LibVersion};
15457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($UsedDump{$LibVersion}{"V"})
15459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # old-version dumps
15460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "unknown";
15461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Cache{"getArch"}{$LibVersion}) {
15463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"getArch"}{$LibVersion};
15464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Arch = get_dumpmachine($GCC_PATH); # host version
15466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Arch) {
15467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "unknown";
15468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Arch=~/\A([\w]{3,})(-|\Z)/) {
15470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Arch = $1;
15471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15472177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    $Arch = "x86" if($Arch=~/\Ai[3-7]86\Z/i);
15473177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    $Arch = "x86_64" if($Arch=~/\Aamd64\Z/i);
15474c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko    if($OSgroup eq "windows")
15475c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko    {
15476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Arch = "x86" if($Arch=~/win32|mingw32/i);
15477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Arch = "x86_64" if($Arch=~/win64|mingw64/i);
15478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Cache{"getArch"}{$LibVersion} = $Arch;
15480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Arch;
15481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
154831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub get_Report_Header($)
15484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
154851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
15486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $ArchInfo = " on <span style='color:Blue;'>".showArch(getArch(1))."</span>";
154871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(getArch(1) ne getArch(2)
154881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or getArch(1) eq "unknown"
154891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $Level eq "Source")
15490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # don't show architecture in the header
15491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ArchInfo="";
15492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
154931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Report_Header = "<h1><span class='nowrap'>";
154941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Level eq "Source") {
154951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Report_Header .= "Source compatibility";
154961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
154971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($Level eq "Binary") {
154981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Report_Header .= "Binary compatibility";
154991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
155001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else {
155011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Report_Header .= "API compatibility";
155021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
155031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $Report_Header .= " report for the <span style='color:Blue;'>$TargetLibraryFName</span> $TargetComponent</span>";
15504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey 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>";
15505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($AppPath) {
15506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Report_Header .= " <span class='nowrap'>&#160;(relating to the portability of application <span style='color:Blue;'>".get_filename($AppPath)."</span>)</span>";
15507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Report_Header .= "</h1>\n";
15509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Report_Header;
15510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_SourceInfo()
15513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15514fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my ($CheckedHeaders, $CheckedSources, $CheckedLibs) = ("", "");
1551562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not $CheckObjectsOnly)
15516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
15517fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my @Headers = keys(%{$Registered_Headers{1}}))
1551862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
15519fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $CheckedHeaders = "<a name='Headers'></a><h2>Header Files (".($#Headers+1).")</h2><hr/>\n";
15520fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $CheckedHeaders .= "<div class='h_list'>\n";
15521fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            foreach my $Header_Path (sort {lc($Registered_Headers{1}{$a}{"Identity"}) cmp lc($Registered_Headers{1}{$b}{"Identity"})} @Headers)
15522fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
15523fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Identity = $Registered_Headers{1}{$Header_Path}{"Identity"};
15524fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Name = get_filename($Identity);
15525fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Comment = ($Identity=~/[\/\\]/)?" ($Identity)":"";
15526fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $CheckedHeaders .= $Name.$Comment."<br/>\n";
15527fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
15528fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $CheckedHeaders .= "</div>\n";
15529fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $CheckedHeaders .= "<br/>$TOP_REF<br/>\n";
15530fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
15531fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
15532fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my @Sources = keys(%{$Registered_Sources{1}}))
15533fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
15534fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $CheckedSources = "<a name='Sources'></a><h2>Source Files (".($#Sources+1).")</h2><hr/>\n";
15535fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $CheckedSources .= "<div class='h_list'>\n";
15536fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            foreach my $Header_Path (sort {lc($Registered_Sources{1}{$a}{"Identity"}) cmp lc($Registered_Sources{1}{$b}{"Identity"})} @Sources)
15537fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
15538fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Identity = $Registered_Sources{1}{$Header_Path}{"Identity"};
15539fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Name = get_filename($Identity);
15540fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Comment = ($Identity=~/[\/\\]/)?" ($Identity)":"";
15541fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $CheckedSources .= $Name.$Comment."<br/>\n";
15542fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
15543fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $CheckedSources .= "</div>\n";
15544fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $CheckedSources .= "<br/>$TOP_REF<br/>\n";
1554562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
15546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1554762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not $CheckHeadersOnly)
15548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
15549fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $CheckedLibs = "<a name='Libs'></a><h2>".get_ObjTitle()." (".keys(%{$Library_Symbol{1}}).")</h2><hr/>\n";
1555062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $CheckedLibs .= "<div class='lib_list'>\n";
1555162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $Library (sort {lc($a) cmp lc($b)}  keys(%{$Library_Symbol{1}}))
1555262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
1555362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $Library.=" (.$LIB_EXT)" if($Library!~/\.\w+\Z/);
1555462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $CheckedLibs .= $Library."<br/>\n";
1555562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1555662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $CheckedLibs .= "</div>\n";
1555762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $CheckedLibs .= "<br/>$TOP_REF<br/>\n";
15558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15559fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return $CheckedHeaders.$CheckedSources.$CheckedLibs;
15560fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko}
15561fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
15562fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub get_ObjTitle()
15563fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko{
15564fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(defined $UsedDump{1}{"DWARF"}) {
15565fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return "Objects";
15566fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
15567fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    else {
15568fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return ucfirst($SLIB_TYPE)." Libraries";
15569fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
15570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_TypeProblems_Count($$$)
15573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeChanges, $TargetPriority, $Level) = @_;
15575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Type_Problems_Count = 0;
15576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Type_Name (sort keys(%{$TypeChanges}))
15577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
15578ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my %Kinds_Target = ();
15579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Kind (keys(%{$TypeChanges->{$Type_Name}}))
15580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Location (keys(%{$TypeChanges->{$Type_Name}{$Kind}}))
15582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
15583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Target = $TypeChanges->{$Type_Name}{$Kind}{$Location}{"Target"};
15584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Priority = getProblemSeverity($Level, $Kind);
15585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next if($Priority ne $TargetPriority);
15586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Kinds_Target{$Kind}{$Target}) {
15587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
15588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
15589dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if(cmpSeverities($Type_MaxSeverity{$Level}{$Type_Name}{$Kind}{$Target}, $Priority))
15590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # select a problem with the highest priority
15591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
15592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
15593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Kinds_Target{$Kind}{$Target} = 1;
15594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Type_Problems_Count += 1;
15595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Type_Problems_Count;
15599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_Summary($)
15602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
156031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
156041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Added, $Removed, $I_Problems_High, $I_Problems_Medium, $I_Problems_Low, $T_Problems_High,
156058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey 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);
156061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    %{$RESULT{$Level}} = (
156071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        "Problems"=>0,
156081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        "Warnings"=>0,
156091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        "Affected"=>0 );
15610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # check rules
156111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Interface (sort keys(%{$CompatProblems{$Level}}))
15612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
156131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $Kind (keys(%{$CompatProblems{$Level}{$Interface}}))
15614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not defined $CompatRules{$Level}{$Kind})
15616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # unknown rule
15617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not $UnknownRules{$Level}{$Kind})
15618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # only one warning
15619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    printMsg("WARNING", "unknown rule \"$Kind\" (\"$Level\")");
15620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $UnknownRules{$Level}{$Kind}=1;
15621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
156221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                delete($CompatProblems{$Level}{$Interface}{$Kind});
15623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
156268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $Constant (sort keys(%{$CompatProblems_Constants{$Level}}))
156278f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
156288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        foreach my $Kind (keys(%{$CompatProblems_Constants{$Level}{$Constant}}))
156298f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
156308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(not defined $CompatRules{$Level}{$Kind})
156318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # unknown rule
156328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if(not $UnknownRules{$Level}{$Kind})
156338f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                { # only one warning
156348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    printMsg("WARNING", "unknown rule \"$Kind\" (\"$Level\")");
156358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $UnknownRules{$Level}{$Kind}=1;
156368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
156378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                delete($CompatProblems_Constants{$Level}{$Constant}{$Kind});
156388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
156398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
156408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
156411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Interface (sort keys(%{$CompatProblems{$Level}}))
15642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
156431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $Kind (sort keys(%{$CompatProblems{$Level}{$Interface}}))
15644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CompatRules{$Level}{$Kind}{"Kind"} eq "Symbols")
15646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
156471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Location (sort keys(%{$CompatProblems{$Level}{$Interface}{$Kind}}))
15648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
15649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $Priority = getProblemSeverity($Level, $Kind);
156501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Kind eq "Added_Symbol") {
15651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $Added += 1;
15652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
156531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    elsif($Kind eq "Removed_Symbol")
15654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
15655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $Removed += 1;
15656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $TotalAffected{$Level}{$Interface} = $Priority;
15657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
15658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    else
15659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
15660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($Priority eq "Safe") {
15661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $I_Other += 1;
15662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
15663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        elsif($Priority eq "High") {
15664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $I_Problems_High += 1;
15665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
15666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        elsif($Priority eq "Medium") {
15667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $I_Problems_Medium += 1;
15668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
15669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        elsif($Priority eq "Low") {
15670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $I_Problems_Low += 1;
15671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
15672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if(($Priority ne "Low" or $StrictCompat)
15673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        and $Priority ne "Safe") {
15674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $TotalAffected{$Level}{$Interface} = $Priority;
15675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
15676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
15677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
15678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %TypeChanges = ();
156821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Interface (sort keys(%{$CompatProblems{$Level}}))
15683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
156841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $Kind (keys(%{$CompatProblems{$Level}{$Interface}}))
15685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CompatRules{$Level}{$Kind}{"Kind"} eq "Types")
15687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
156881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Location (sort {cmp_locations($b, $a)} sort keys(%{$CompatProblems{$Level}{$Interface}{$Kind}}))
15689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
156901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my $Type_Name = $CompatProblems{$Level}{$Interface}{$Kind}{$Location}{"Type_Name"};
156911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my $Target = $CompatProblems{$Level}{$Interface}{$Kind}{$Location}{"Target"};
15692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $Priority = getProblemSeverity($Level, $Kind);
15693dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    if(cmpSeverities($Type_MaxSeverity{$Level}{$Type_Name}{$Kind}{$Target}, $Priority))
15694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # select a problem with the highest priority
15695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        next;
15696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
15697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(($Priority ne "Low" or $StrictCompat)
15698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    and $Priority ne "Safe") {
15699dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        $TotalAffected{$Level}{$Interface} = maxSeverity($TotalAffected{$Level}{$Interface}, $Priority);
15700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
157011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    %{$TypeChanges{$Type_Name}{$Kind}{$Location}} = %{$CompatProblems{$Level}{$Interface}{$Kind}{$Location}};
15702dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    $Type_MaxSeverity{$Level}{$Type_Name}{$Kind}{$Target} = maxSeverity($Type_MaxSeverity{$Level}{$Type_Name}{$Kind}{$Target}, $Priority);
15703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
15704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
157071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
15708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $T_Problems_High = get_TypeProblems_Count(\%TypeChanges, "High", $Level);
15709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $T_Problems_Medium = get_TypeProblems_Count(\%TypeChanges, "Medium", $Level);
15710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $T_Problems_Low = get_TypeProblems_Count(\%TypeChanges, "Low", $Level);
15711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $T_Other = get_TypeProblems_Count(\%TypeChanges, "Safe", $Level);
157121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
15713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($CheckObjectsOnly)
15714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # only removed exported symbols
157151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $RESULT{$Level}{"Affected"} = $Removed*100/keys(%{$Symbol_Library{1}});
15716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
15718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # changed and removed public symbols
157191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $SCount = keys(%{$CheckedSymbols{$Level}});
15720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($ExtendedCheck)
15721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # don't count external_func_0 for constants
15722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SCount-=1;
15723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SCount)
15725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my %Weight = (
15727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                "High" => 100,
15728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                "Medium" => 50,
15729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                "Low" => 25
15730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            );
15731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach (keys(%{$TotalAffected{$Level}})) {
157321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $RESULT{$Level}{"Affected"}+=$Weight{$TotalAffected{$Level}{$_}};
15733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
157341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $RESULT{$Level}{"Affected"} = $RESULT{$Level}{"Affected"}/$SCount;
15735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
157371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $RESULT{$Level}{"Affected"} = 0;
15738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
157401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $RESULT{$Level}{"Affected"} = show_number($RESULT{$Level}{"Affected"});
157411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($RESULT{$Level}{"Affected"}>=100) {
157421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $RESULT{$Level}{"Affected"} = 100;
15743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15745850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    $RESULT{$Level}{"Problems"} += $Removed;
15746850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    $RESULT{$Level}{"Problems"} += $T_Problems_High + $I_Problems_High;
157471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $RESULT{$Level}{"Problems"} += $T_Problems_Medium + $I_Problems_Medium;
15748850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($StrictCompat) {
15749850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $RESULT{$Level}{"Problems"} += $T_Problems_Low + $I_Problems_Low;
15750850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
15751850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    else {
15752850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $RESULT{$Level}{"Warnings"} += $T_Problems_Low + $I_Problems_Low;
15753850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
15754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
157558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $Constant (keys(%{$CompatProblems_Constants{$Level}}))
157561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
157578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        foreach my $Kind (keys(%{$CompatProblems_Constants{$Level}{$Constant}}))
15758850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
157598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $Severity = getProblemSeverity($Level, $Kind);
157608f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($Severity eq "Safe")
157618f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
157628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $C_Other+=1;
15763850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
157648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            elsif($Severity eq "Low")
157658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
157668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $C_Problems_Low+=1;
15767850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
157681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
157698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
157708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
157718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($C_Problems_Low)
157728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
157738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($StrictCompat) {
157748f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $RESULT{$Level}{"Problems"} += $C_Problems_Low;
157758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
157768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        else {
157778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $RESULT{$Level}{"Warnings"} += $C_Problems_Low;
157781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
157791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
15780850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($CheckImpl and $Level eq "Binary")
15781850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
15782850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($StrictCompat) {
157838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $RESULT{$Level}{"Problems"} += keys(%CompatProblems_Impl);
15784850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
15785850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        else {
157868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $RESULT{$Level}{"Warnings"} += keys(%CompatProblems_Impl);
15787850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
15788850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
15789850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($RESULT{$Level}{"Problems"}
15790850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    and $RESULT{$Level}{"Affected"}) {
15791850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $RESULT{$Level}{"Verdict"} = "incompatible";
15792850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
15793850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    else {
15794850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $RESULT{$Level}{"Verdict"} = "compatible";
157951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
157961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
157971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $TotalTypes = keys(%{$CheckedTypes{$Level}});
157981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(not $TotalTypes)
157991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # list all the types
15800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TotalTypes = keys(%{$TName_Tid{1}});
15801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Arch1, $Arch2) = (getArch(1), getArch(2));
15804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($GccV1, $GccV2) = (getGccVersion(1), getGccVersion(2));
15805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TestInfo, $TestResults, $Problem_Summary) = ();
15807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
15809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
15810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # test info
15811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "  <library>$TargetLibraryName</library>\n";
15812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "  <version1>\n";
15813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "    <number>".$Descriptor{1}{"Version"}."</number>\n";
15814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "    <architecture>$Arch1</architecture>\n";
15815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "    <gcc>$GccV1</gcc>\n";
15816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "  </version1>\n";
15817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "  <version2>\n";
15819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "    <number>".$Descriptor{2}{"Version"}."</number>\n";
15820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "    <architecture>$Arch2</architecture>\n";
15821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "    <gcc>$GccV2</gcc>\n";
15822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "  </version2>\n";
15823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo = "<test_info>\n".$TestInfo."</test_info>\n\n";
15824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # test results
15826fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my @Headers = keys(%{$Registered_Headers{1}}))
15827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15828fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TestResults .= "  <headers>\n";
15829fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            foreach my $Name (sort {lc($Registered_Headers{1}{$a}{"Identity"}) cmp lc($Registered_Headers{1}{$b}{"Identity"})} @Headers)
15830fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
15831fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Identity = $Registered_Headers{1}{$Name}{"Identity"};
15832fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Comment = ($Identity=~/[\/\\]/)?" ($Identity)":"";
15833fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $TestResults .= "    <name>".get_filename($Name).$Comment."</name>\n";
15834fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
15835fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TestResults .= "  </headers>\n";
15836fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
15837fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
15838fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my @Sources = keys(%{$Registered_Sources{1}}))
15839fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
15840fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TestResults .= "  <sources>\n";
15841fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            foreach my $Name (sort {lc($Registered_Sources{1}{$a}{"Identity"}) cmp lc($Registered_Sources{1}{$b}{"Identity"})} @Sources)
15842fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
15843fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Identity = $Registered_Sources{1}{$Name}{"Identity"};
15844fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Comment = ($Identity=~/[\/\\]/)?" ($Identity)":"";
15845fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $TestResults .= "    <name>".get_filename($Name).$Comment."</name>\n";
15846fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
15847fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TestResults .= "  </sources>\n";
15848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestResults .= "  <libs>\n";
15851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Library (sort {lc($a) cmp lc($b)}  keys(%{$Library_Symbol{1}}))
15852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Library.=" (.$LIB_EXT)" if($Library!~/\.\w+\Z/);
15854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TestResults .= "    <name>$Library</name>\n";
15855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestResults .= "  </libs>\n";
15857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1585862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $TestResults .= "  <symbols>".(keys(%{$CheckedSymbols{$Level}}) - keys(%ExtendedSymbols))."</symbols>\n";
15859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestResults .= "  <types>".$TotalTypes."</types>\n";
15860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
158611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TestResults .= "  <verdict>".$RESULT{$Level}{"Verdict"}."</verdict>\n";
158621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TestResults .= "  <affected>".$RESULT{$Level}{"Affected"}."</affected>\n";
15863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestResults = "<test_results>\n".$TestResults."</test_results>\n\n";
15864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # problem summary
15866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  <added_symbols>".$Added."</added_symbols>\n";
15867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  <removed_symbols>".$Removed."</removed_symbols>\n";
15868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  <problems_with_types>\n";
15870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "    <high>$T_Problems_High</high>\n";
15871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "    <medium>$T_Problems_Medium</medium>\n";
15872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "    <low>$T_Problems_Low</low>\n";
15873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "    <safe>$T_Other</safe>\n";
15874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  </problems_with_types>\n";
15875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  <problems_with_symbols>\n";
15877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "    <high>$I_Problems_High</high>\n";
15878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "    <medium>$I_Problems_Medium</medium>\n";
15879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "    <low>$I_Problems_Low</low>\n";
158801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Problem_Summary .= "    <safe>$I_Other</safe>\n";
15881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  </problems_with_symbols>\n";
15882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  <problems_with_constants>\n";
158841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Problem_Summary .= "    <low>$C_Problems_Low</low>\n";
15885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  </problems_with_constants>\n";
158861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CheckImpl and $Level eq "Binary")
15887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Problem_Summary .= "  <impl>\n";
158898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Problem_Summary .= "    <low>".keys(%CompatProblems_Impl)."</low>\n";
15890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Problem_Summary .= "  </impl>\n";
15891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary = "<problem_summary>\n".$Problem_Summary."</problem_summary>\n\n";
15893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ($TestInfo.$TestResults.$Problem_Summary, "");
15895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
15897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
15898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # test info
15899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo = "<h2>Test Info</h2><hr/>\n";
159001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TestInfo .= "<table class='summary'>\n";
15901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "<tr><th>".ucfirst($TargetComponent)." Name</th><td>$TargetLibraryFName</td></tr>\n";
15902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my (@VInf1, @VInf2, $AddTestInfo) = ();
15904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Arch1 ne "unknown"
15905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Arch2 ne "unknown")
15906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # CPU arch
15907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Arch1 eq $Arch2)
15908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # go to the separate section
159091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $AddTestInfo .= "<tr><th>CPU Type</th><td>".showArch($Arch1)."</td></tr>\n";
15910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
15912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # go to the version number
15913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@VInf1, showArch($Arch1));
15914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@VInf2, showArch($Arch2));
15915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($GccV1 ne "unknown"
15918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $GccV2 ne "unknown"
15919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $OStarget ne "windows")
15920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # GCC version
15921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($GccV1 eq $GccV2)
15922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # go to the separate section
15923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $AddTestInfo .= "<tr><th>GCC Version</th><td>$GccV1</td></tr>\n";
15924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
15926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # go to the version number
15927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@VInf1, "gcc ".$GccV1);
15928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@VInf2, "gcc ".$GccV2);
15929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # show long version names with GCC version and CPU architecture name (if different)
15932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "<tr><th>Version #1</th><td>".$Descriptor{1}{"Version"}.(@VInf1?" (".join(", ", reverse(@VInf1)).")":"")."</td></tr>\n";
15933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "<tr><th>Version #2</th><td>".$Descriptor{2}{"Version"}.(@VInf2?" (".join(", ", reverse(@VInf2)).")":"")."</td></tr>\n";
15934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= $AddTestInfo;
15935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        #if($COMMON_LANGUAGE{1}) {
15936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        #    $TestInfo .= "<tr><th>Language</th><td>".$COMMON_LANGUAGE{1}."</td></tr>\n";
15937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        #}
15938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($ExtendedCheck) {
15939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TestInfo .= "<tr><th>Mode</th><td>Extended</td></tr>\n";
15940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
159411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($JoinReport)
159421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
159431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Binary") {
159441693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $TestInfo .= "<tr><th>Subject</th><td width='150px'>Binary Compatibility</td></tr>\n"; # Run-time
159451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
159461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Source") {
159471693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $TestInfo .= "<tr><th>Subject</th><td width='150px'>Source Compatibility</td></tr>\n"; # Build-time
159481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
159491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
15950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "</table>\n";
15951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # test results
15953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestResults = "<h2>Test Results</h2><hr/>\n";
159541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TestResults .= "<table class='summary'>";
15955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15956fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my @Headers = keys(%{$Registered_Headers{1}}))
15957fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
15958fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my $Headers_Link = "<a href='#Headers' style='color:Blue;'>".($#Headers + 1)."</a>";
15959fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TestResults .= "<tr><th>Total Header Files</th><td>".$Headers_Link."</td></tr>\n";
15960fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
15961fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        elsif($CheckObjectsOnly) {
15962fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TestResults .= "<tr><th>Total Header Files</th><td>0&#160;(not&#160;analyzed)</td></tr>\n";
15963fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
15964fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
15965fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my @Sources = keys(%{$Registered_Sources{1}}))
15966fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
15967fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my $Src_Link = "<a href='#Sources' style='color:Blue;'>".($#Sources + 1)."</a>";
15968fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TestResults .= "<tr><th>Total Source Files</th><td>".$Src_Link."</td></tr>\n";
15969fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
15970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $ExtendedCheck)
15972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Libs_Link = "0";
15974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Libs_Link = "<a href='#Libs' style='color:Blue;'>".keys(%{$Library_Symbol{1}})."</a>" if(keys(%{$Library_Symbol{1}})>0);
15975fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TestResults .= "<tr><th>Total ".get_ObjTitle()."</th><td>".($CheckHeadersOnly?"0&#160;(not&#160;analyzed)":$Libs_Link)."</td></tr>\n";
15976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1597862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $TestResults .= "<tr><th>Total Symbols / Types</th><td>".(keys(%{$CheckedSymbols{$Level}}) - keys(%ExtendedSymbols))." / ".$TotalTypes."</td></tr>\n";
15979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15980850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $META_DATA = "verdict:".$RESULT{$Level}{"Verdict"}.";";
159811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($JoinReport) {
159821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $META_DATA = "kind:".lc($Level).";".$META_DATA;
159831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
159841693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $TestResults .= "<tr><th>Verdict</th>";
15985850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($RESULT{$Level}{"Verdict"} eq "incompatible") {
159861693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $TestResults .= "<td><span style='color:Red;'><b>Incompatible<br/>(".$RESULT{$Level}{"Affected"}."%)</b></span></td>";
159871693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
159881693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        else {
159891693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $TestResults .= "<td><span style='color:Green;'><b>Compatible</b></span></td>";
159901693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
159911693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $TestResults .= "</tr>\n";
15992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestResults .= "</table>\n";
15993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
159941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $META_DATA .= "affected:".$RESULT{$Level}{"Affected"}.";";# in percents
15995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # problem summary
15996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary = "<h2>Problem Summary</h2><hr/>\n";
159971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Problem_Summary .= "<table class='summary'>";
15998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "<tr><th></th><th style='text-align:center;'>Severity</th><th style='text-align:center;'>Count</th></tr>";
15999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Added_Link = "0";
160011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Added>0)
160021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
160031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($JoinReport) {
160041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Added_Link = "<a href='#".$Level."_Added' style='color:Blue;'>$Added</a>";
160051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
160061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            else {
160071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Added_Link = "<a href='#Added' style='color:Blue;'>$Added</a>";
160081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
160091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
16010ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "added:$Added;";
160111693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<tr><th>Added Symbols</th><td>-</td><td".getStyle("I", "A", $Added).">$Added_Link</td></tr>\n";
16012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Removed_Link = "0";
160141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Removed>0)
160151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
160161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($JoinReport) {
160171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Removed_Link = "<a href='#".$Level."_Removed' style='color:Blue;'>$Removed</a>"
160181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
160191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            else {
160201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Removed_Link = "<a href='#Removed' style='color:Blue;'>$Removed</a>"
160211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
160221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
16023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "removed:$Removed;";
160241693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<tr><th>Removed Symbols</th>";
160251693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<td>High</td><td".getStyle("I", "R", $Removed).">$Removed_Link</td></tr>\n";
16026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $TH_Link = "0";
160281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TH_Link = "<a href='#".get_Anchor("Type", $Level, "High")."' style='color:Blue;'>$T_Problems_High</a>" if($T_Problems_High>0);
16029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TH_Link = "n/a" if($CheckObjectsOnly);
16030ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "type_problems_high:$T_Problems_High;";
160311693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<tr><th rowspan='3'>Problems with<br/>Data Types</th>";
160321693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<td>High</td><td".getStyle("T", "H", $T_Problems_High).">$TH_Link</td></tr>\n";
16033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16034ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $TM_Link = "0";
160351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TM_Link = "<a href='#".get_Anchor("Type", $Level, "Medium")."' style='color:Blue;'>$T_Problems_Medium</a>" if($T_Problems_Medium>0);
16036ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TM_Link = "n/a" if($CheckObjectsOnly);
16037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "type_problems_medium:$T_Problems_Medium;";
160381693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<tr><td>Medium</td><td".getStyle("T", "M", $T_Problems_Medium).">$TM_Link</td></tr>\n";
16039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $TL_Link = "0";
160411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TL_Link = "<a href='#".get_Anchor("Type", $Level, "Low")."' style='color:Blue;'>$T_Problems_Low</a>" if($T_Problems_Low>0);
16042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TL_Link = "n/a" if($CheckObjectsOnly);
16043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "type_problems_low:$T_Problems_Low;";
160441693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<tr><td>Low</td><td".getStyle("T", "L", $T_Problems_Low).">$TL_Link</td></tr>\n";
16045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16046ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $IH_Link = "0";
160471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $IH_Link = "<a href='#".get_Anchor("Symbol", $Level, "High")."' style='color:Blue;'>$I_Problems_High</a>" if($I_Problems_High>0);
16048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $IH_Link = "n/a" if($CheckObjectsOnly);
16049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "interface_problems_high:$I_Problems_High;";
160501693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<tr><th rowspan='3'>Problems with<br/>Symbols</th>";
160511693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<td>High</td><td".getStyle("I", "H", $I_Problems_High).">$IH_Link</td></tr>\n";
16052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16053ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $IM_Link = "0";
160541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $IM_Link = "<a href='#".get_Anchor("Symbol", $Level, "Medium")."' style='color:Blue;'>$I_Problems_Medium</a>" if($I_Problems_Medium>0);
16055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $IM_Link = "n/a" if($CheckObjectsOnly);
16056ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "interface_problems_medium:$I_Problems_Medium;";
160571693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<tr><td>Medium</td><td".getStyle("I", "M", $I_Problems_Medium).">$IM_Link</td></tr>\n";
16058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $IL_Link = "0";
160601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $IL_Link = "<a href='#".get_Anchor("Symbol", $Level, "Low")."' style='color:Blue;'>$I_Problems_Low</a>" if($I_Problems_Low>0);
16061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $IL_Link = "n/a" if($CheckObjectsOnly);
16062ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "interface_problems_low:$I_Problems_Low;";
160631693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<tr><td>Low</td><td".getStyle("I", "L", $I_Problems_Low).">$IL_Link</td></tr>\n";
16064ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $ChangedConstants_Link = "0";
160668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(keys(%{$CheckedSymbols{$Level}}) and $C_Problems_Low) {
160678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $ChangedConstants_Link = "<a href='#".get_Anchor("Constant", $Level, "Low")."' style='color:Blue;'>$C_Problems_Low</a>";
16068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ChangedConstants_Link = "n/a" if($CheckObjectsOnly);
160701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $META_DATA .= "changed_constants:$C_Problems_Low;";
160711693447e958e56734a9d3291c320b0ff3c4c6d47Andrey 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";
16072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
160731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CheckImpl and $Level eq "Binary")
16074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $ChangedImpl_Link = "0";
160768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $ChangedImpl_Link = "<a href='#Changed_Implementation' style='color:Blue;'>".keys(%CompatProblems_Impl)."</a>" if(keys(%CompatProblems_Impl)>0);
16077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ChangedImpl_Link = "n/a" if($CheckHeadersOnly);
160788f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $META_DATA .= "changed_implementation:".keys(%CompatProblems_Impl).";";
160798f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey 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";
16080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # Safe Changes
160821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($T_Other and not $CheckObjectsOnly)
160831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
160841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $TS_Link = "<a href='#".get_Anchor("Type", $Level, "Safe")."' style='color:Blue;'>$T_Other</a>";
160851693447e958e56734a9d3291c320b0ff3c4c6d47Andrey 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";
160861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
160871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
160881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($I_Other and not $CheckObjectsOnly)
160891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
160901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $IS_Link = "<a href='#".get_Anchor("Symbol", $Level, "Safe")."' style='color:Blue;'>$I_Other</a>";
160911693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $Problem_Summary .= "<tr><th>Other Changes<br/>in Symbols</th><td>-</td><td".getStyle("I", "S", $I_Other).">$IS_Link</td></tr>\n";
16092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
160948f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($C_Other and not $CheckObjectsOnly)
160958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
160968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $CS_Link = "<a href='#".get_Anchor("Constant", $Level, "Safe")."' style='color:Blue;'>$C_Other</a>";
160978f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Problem_Summary .= "<tr><th>Other Changes<br/>in Constants</th><td>-</td><td".getStyle("C", "S", $C_Other).">$CS_Link</td></tr>\n";
160988f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
160998f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
16100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "tool_version:$TOOL_VERSION";
16101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "</table>\n";
161021693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        # $TestInfo = getLegend().$TestInfo;
16103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ($TestInfo.$TestResults.$Problem_Summary, $META_DATA);
16104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
161071693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub getStyle($$$)
161081693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{
161091693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my ($Subj, $Act, $Num) = @_;
161101693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %Style = (
161111693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        "A"=>"new",
161121693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        "R"=>"failed",
161131693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        "S"=>"passed",
161141693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        "L"=>"warning",
161151693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        "M"=>"failed",
161161693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        "H"=>"failed"
161171693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    );
161181693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($Num>0) {
161191693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        return " class='".$Style{$Act}."'";
161201693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
161211693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return "";
161221693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko}
161231693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
16124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub show_number($)
16125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
161261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($_[0])
16127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
161281693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $Num = cut_off_number($_[0], 2, 0);
161291693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($Num eq "0")
161301693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
161311693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            foreach my $P (3 .. 7)
161321693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            {
161331693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $Num = cut_off_number($_[0], $P, 1);
161341693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                if($Num ne "0") {
161351693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    last;
161361693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                }
161371693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
16138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Num eq "0") {
16140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Num = $_[0];
16141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Num;
16143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $_[0];
16145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
161471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub cut_off_number($$$)
16148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
161491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($num, $digs_to_cut, $z) = @_;
16150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($num!~/\./)
16151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
16152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $num .= ".";
16153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach (1 .. $digs_to_cut-1) {
16154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $num .= "0";
16155ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($num=~/\.(.+)\Z/ and length($1)<$digs_to_cut-1)
16158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
16159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach (1 .. $digs_to_cut - 1 - length($1)) {
16160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $num .= "0";
16161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($num=~/\d+\.(\d){$digs_to_cut,}/) {
16164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      $num=sprintf("%.".($digs_to_cut-1)."f", $num);
16165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $num=~s/\.[0]+\Z//g;
161671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($z) {
161681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $num=~s/(\.[1-9]+)[0]+\Z/$1/g;
161691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
16170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $num;
16171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16172ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
161738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub get_Report_ChangedConstants($$)
16174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
161758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my ($TargetSeverity, $Level) = @_;
161761693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $CHANGED_CONSTANTS = "";
161778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
161781693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %ReportMap = ();
161798f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $Constant (keys(%{$CompatProblems_Constants{$Level}}))
161808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
161818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $Header = $Constants{1}{$Constant}{"Header"};
161828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not $Header)
161838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # added
161848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Header = $Constants{2}{$Constant}{"Header"}
161858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
161868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
161878f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        foreach my $Kind (sort {lc($a) cmp lc($b)} keys(%{$CompatProblems_Constants{$Level}{$Constant}}))
161888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
161898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(not defined $CompatRules{$Level}{$Kind}) {
161908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                next;
161918f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
161928f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($TargetSeverity ne getProblemSeverity($Level, $Kind)) {
161938f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                next;
161948f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
161958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $ReportMap{$Header}{$Constant}{$Kind} = 1;
161968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
161971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
161988f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
16199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
16200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
162011693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CHANGED_CONSTANTS .= "  <header name=\"$HeaderName\">\n";
162041693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            foreach my $Constant (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
16205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
16206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $CHANGED_CONSTANTS .= "    <constant name=\"$Constant\">\n";
162078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                foreach my $Kind (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}{$Constant}}))
162088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                {
162098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my $Change = $CompatRules{$Level}{$Kind}{"Change"};
162108f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my $Effect = $CompatRules{$Level}{$Kind}{"Effect"};
162118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my $Overcome = $CompatRules{$Level}{$Kind}{"Overcome"};
16212fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
162138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $CHANGED_CONSTANTS .= "      <problem id=\"$Kind\">\n";
162148f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $CHANGED_CONSTANTS .= "        <change".getXmlParams($Change, $CompatProblems_Constants{$Level}{$Constant}{$Kind}).">$Change</change>\n";
162158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $CHANGED_CONSTANTS .= "        <effect".getXmlParams($Effect, $CompatProblems_Constants{$Level}{$Constant}{$Kind}).">$Effect</effect>\n";
162168f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $CHANGED_CONSTANTS .= "        <overcome".getXmlParams($Overcome, $CompatProblems_Constants{$Level}{$Constant}{$Kind}).">$Overcome</overcome>\n";
162178f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $CHANGED_CONSTANTS .= "      </problem>\n";
162188f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
16219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $CHANGED_CONSTANTS .= "    </constant>\n";
16220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CHANGED_CONSTANTS .= "    </header>\n";
16222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $CHANGED_CONSTANTS = "<problems_with_constants severity=\"Low\">\n".$CHANGED_CONSTANTS."</problems_with_constants>\n\n";
16224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
16226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
16227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Number = 0;
162281693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CHANGED_CONSTANTS .= "<span class='h_name'>$HeaderName</span><br/>\n";
162318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            foreach my $Constant (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
16232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
162338f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                my $Report = "";
162348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
162358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                foreach my $Kind (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}{$Constant}}))
162368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                {
162378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my $Change = applyMacroses($Level, $Kind, $CompatRules{$Level}{$Kind}{"Change"}, $CompatProblems_Constants{$Level}{$Constant}{$Kind});
162388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my $Effect = $CompatRules{$Level}{$Kind}{"Effect"};
162398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $Report .= "<tr><th>1</th><td align='left' valign='top'>".$Change."</td><td align='left' valign='top'>$Effect</td></tr>\n";
162408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $Number += 1;
162418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
162428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if($Report)
162438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                {
162448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey 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";
162458f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $Report = $ContentSpanStart."<span class='extendable'>[+]</span> ".$Constant.$ContentSpanEnd."<br/>\n".$Report;
162468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $Report = insertIDs($Report);
162478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
162488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $CHANGED_CONSTANTS .= $Report;
16249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CHANGED_CONSTANTS .= "<br/>\n";
16251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
162521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CHANGED_CONSTANTS)
162531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
162548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $Title = "Problems with Constants, $TargetSeverity Severity";
162558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($TargetSeverity eq "Safe")
162568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # Safe Changes
162578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $Title = "Other Changes in Constants";
162581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
162598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $CHANGED_CONSTANTS = "<a name='".get_Anchor("Constant", $Level, $TargetSeverity)."'></a><h2>$Title ($Number)</h2><hr/>\n".$CHANGED_CONSTANTS.$TOP_REF."<br/>\n";
16260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $CHANGED_CONSTANTS;
16263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_Report_Impl()
16266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
162671693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $CHANGED_IMPLEMENTATION = "";
162681693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %ReportMap = ();
162698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $Interface (sort keys(%CompatProblems_Impl))
16270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
16271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $HeaderName = $CompleteSignature{1}{$Interface}{"Header"};
16272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $DyLib = $Symbol_Library{1}{$Interface};
162731693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $ReportMap{$HeaderName}{$DyLib}{$Interface} = 1;
16274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Changed_Number = 0;
162761693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
162781693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        foreach my $DyLib (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
16279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
162801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my %NameSpaceSymbols = ();
162811693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            foreach my $Interface (keys(%{$ReportMap{$HeaderName}{$DyLib}})) {
1628274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $NameSpaceSymbols{select_Symbol_NS($Interface, 2)}{$Interface} = 1;
16283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
162841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $NameSpace (sort keys(%NameSpaceSymbols))
16285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
1628674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $CHANGED_IMPLEMENTATION .= getTitle($HeaderName, $DyLib, $NameSpace);
162871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my @SortedInterfaces = sort {lc(get_Signature($a, 1)) cmp lc(get_Signature($b, 1))} keys(%{$NameSpaceSymbols{$NameSpace}});
16288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Interface (@SortedInterfaces)
16289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
16290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Changed_Number += 1;
16291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $Signature = get_Signature($Interface, 1);
16292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($NameSpace) {
1629362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $Signature=~s/\b\Q$NameSpace\E::\b//g;
16294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
162958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey 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";
16296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1629774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $CHANGED_IMPLEMENTATION .= "<br/>\n";
16298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1630174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($CHANGED_IMPLEMENTATION)
1630274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    {
1630374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $CHANGED_IMPLEMENTATION = insertIDs($CHANGED_IMPLEMENTATION);
163041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $CHANGED_IMPLEMENTATION = "<a name='Changed_Implementation'></a><h2>Problems with Implementation ($Changed_Number)</h2><hr/>\n".$CHANGED_IMPLEMENTATION.$TOP_REF."<br/>\n";
16305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16306850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
16307850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
163088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    %CompatProblems_Impl = ();
16309850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
16310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $CHANGED_IMPLEMENTATION;
16311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
163131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub getTitle($$$)
163141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
163151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Header, $Library, $NameSpace) = @_;
163161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Title = "";
163171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Library and $Library!~/\.\w+\Z/) {
163181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Library .= " (.$LIB_EXT)";
163191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
163201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Header and $Library)
163211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
163221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Title .= "<span class='h_name'>$Header</span>";
163231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Title .= ", <span class='lib_name'>$Library</span><br/>\n";
163241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
163251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($Library) {
163261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Title .= "<span class='lib_name'>$Library</span><br/>\n";
163271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
163281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($Header) {
163291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Title .= "<span class='h_name'>$Header</span><br/>\n";
163301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
163311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($NameSpace) {
1633274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $Title .= "<span class='ns'>namespace <b>$NameSpace</b></span><br/>\n";
163331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
163341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    return $Title;
163351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
163361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
16337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_Report_Added($)
16338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
163391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
163401693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $ADDED_INTERFACES = "";
163411693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %ReportMap = ();
163421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Interface (sort keys(%{$CompatProblems{$Level}}))
16343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
163441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $Kind (sort keys(%{$CompatProblems{$Level}{$Interface}}))
16345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
163461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Kind eq "Added_Symbol")
16347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
16348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $HeaderName = $CompleteSignature{2}{$Interface}{"Header"};
16349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $DyLib = $Symbol_Library{2}{$Interface};
163501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Source" and $ReportFormat eq "html")
163511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # do not show library name in HTML report
163521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $DyLib = "";
163531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
163541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $ReportMap{$HeaderName}{$DyLib}{$Interface} = 1;
16355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
16359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
163601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ADDED_INTERFACES .= "  <header name=\"$HeaderName\">\n";
163631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $DyLib (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
16364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
16365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $ADDED_INTERFACES .= "    <library name=\"$DyLib\">\n";
163661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Interface (keys(%{$ReportMap{$HeaderName}{$DyLib}})) {
16367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ADDED_INTERFACES .= "      <name>$Interface</name>\n";
16368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $ADDED_INTERFACES .= "    </library>\n";
16370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ADDED_INTERFACES .= "  </header>\n";
16372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ADDED_INTERFACES = "<added_symbols>\n".$ADDED_INTERFACES."</added_symbols>\n\n";
16374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
16376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
16377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Added_Number = 0;
163781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
163801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $DyLib (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
16381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
163821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my %NameSpaceSymbols = ();
163831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Interface (keys(%{$ReportMap{$HeaderName}{$DyLib}})) {
1638474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $NameSpaceSymbols{select_Symbol_NS($Interface, 2)}{$Interface} = 1;
16385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
163861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $NameSpace (sort keys(%NameSpaceSymbols))
16387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
163881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $ADDED_INTERFACES .= getTitle($HeaderName, $DyLib, $NameSpace);
163891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my @SortedInterfaces = sort {lc(get_Signature($a, 2)) cmp lc(get_Signature($b, 2))} keys(%{$NameSpaceSymbols{$NameSpace}});
16390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    foreach my $Interface (@SortedInterfaces)
16391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
16392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $Added_Number += 1;
16393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $Signature = get_Signature($Interface, 2);
16394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($NameSpace) {
1639562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            $Signature=~s/\b\Q$NameSpace\E::\b//g;
16396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
163979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        if($Interface=~/\A(_Z|\?)/)
163989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        {
16399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if($Signature) {
164001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey 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");
16401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            else {
164031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $ADDED_INTERFACES .= "<span class=\"iname\">".$Interface."</span><br/>\n";
16404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
164069927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        else
164079927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        {
16408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if($Signature) {
164091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $ADDED_INTERFACES .= "<span class=\"iname\">".highLight_Signature_Italic_Color($Signature)."</span><br/>\n";
16410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            else {
164121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $ADDED_INTERFACES .= "<span class=\"iname\">".$Interface."</span><br/>\n";
16413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
16415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
164161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $ADDED_INTERFACES .= "<br/>\n";
16417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
164201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($ADDED_INTERFACES)
164211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
164221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Anchor = "<a name='Added'></a>";
164231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($JoinReport) {
164241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Anchor = "<a name='".$Level."_Added'></a>";
164251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
164261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $ADDED_INTERFACES = $Anchor."<h2>Added Symbols ($Added_Number)</h2><hr/>\n".$ADDED_INTERFACES.$TOP_REF."<br/>\n";
16427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $ADDED_INTERFACES;
16430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_Report_Removed($)
16433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
164341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
164351693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $REMOVED_INTERFACES = "";
164361693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %ReportMap = ();
16437850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$CompatProblems{$Level}}))
16438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
16439850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        foreach my $Kind (sort keys(%{$CompatProblems{$Level}{$Symbol}}))
16440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
164411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Kind eq "Removed_Symbol")
16442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
16443850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                my $HeaderName = $CompleteSignature{1}{$Symbol}{"Header"};
16444850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                my $DyLib = $Symbol_Library{1}{$Symbol};
164451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Source" and $ReportFormat eq "html")
164461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # do not show library name in HTML report
164471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $DyLib = "";
164481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
16449850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $ReportMap{$HeaderName}{$DyLib}{$Symbol} = 1;
16450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
16454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
164551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $REMOVED_INTERFACES .= "  <header name=\"$HeaderName\">\n";
164581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $DyLib (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
16459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
16460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $REMOVED_INTERFACES .= "    <library name=\"$DyLib\">\n";
16461850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                foreach my $Symbol (keys(%{$ReportMap{$HeaderName}{$DyLib}})) {
16462850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    $REMOVED_INTERFACES .= "      <name>$Symbol</name>\n";
16463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $REMOVED_INTERFACES .= "    </library>\n";
16465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $REMOVED_INTERFACES .= "  </header>\n";
16467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $REMOVED_INTERFACES = "<removed_symbols>\n".$REMOVED_INTERFACES."</removed_symbols>\n\n";
16469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
16471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
164721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $Removed_Number = 0;
164731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
164741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
164751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $DyLib (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
164761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
164771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my %NameSpaceSymbols = ();
164781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Interface (keys(%{$ReportMap{$HeaderName}{$DyLib}})) {
1647974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $NameSpaceSymbols{select_Symbol_NS($Interface, 1)}{$Interface} = 1;
16480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
164811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $NameSpace (sort keys(%NameSpaceSymbols))
16482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
164831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $REMOVED_INTERFACES .= getTitle($HeaderName, $DyLib, $NameSpace);
164841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my @SortedInterfaces = sort {lc(get_Signature($a, 1)) cmp lc(get_Signature($b, 1))} keys(%{$NameSpaceSymbols{$NameSpace}});
16485850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    foreach my $Symbol (@SortedInterfaces)
16486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
16487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $Removed_Number += 1;
16488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $SubReport = "";
16489850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        my $Signature = get_Signature($Symbol, 1);
16490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($NameSpace) {
1649162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            $Signature=~s/\b\Q$NameSpace\E::\b//g;
16492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
16493850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        if($Symbol=~/\A(_Z|\?)/)
164941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
16495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if($Signature) {
16496850437949b65b213696469223d749c1f74c29601Andrey 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");
16497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            else {
16499850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                $REMOVED_INTERFACES .= "<span class=\"iname\">".$Symbol."</span><br/>\n";
16500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
165021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        else
165031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
16504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if($Signature) {
165051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $REMOVED_INTERFACES .= "<span class=\"iname\">".highLight_Signature_Italic_Color($Signature)."</span><br/>\n";
16506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            else {
16508850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                $REMOVED_INTERFACES .= "<span class=\"iname\">".$Symbol."</span><br/>\n";
16509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
16511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
16512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $REMOVED_INTERFACES .= "<br/>\n";
16514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
165161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($REMOVED_INTERFACES)
165171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
165181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Anchor = "<a name='Removed'></a><a name='Withdrawn'></a>";
165191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($JoinReport) {
165201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Anchor = "<a name='".$Level."_Removed'></a><a name='".$Level."_Withdrawn'></a>";
165211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
165221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $REMOVED_INTERFACES = $Anchor."<h2>Removed Symbols ($Removed_Number)</h2><hr/>\n".$REMOVED_INTERFACES.$TOP_REF."<br/>\n";
16523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $REMOVED_INTERFACES;
16526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getXmlParams($$)
16529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
16530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Content, $Problem) = @_;
16531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Content or not $Problem);
16532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %XMLparams = ();
16533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Attr (sort {$b cmp $a} keys(%{$Problem}))
16534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
16535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Macro = "\@".lc($Attr);
16536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Content=~/\Q$Macro\E/) {
16537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $XMLparams{lc($Attr)} = $Problem->{$Attr};
16538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @PString = ();
16541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $P (sort {$b cmp $a} keys(%XMLparams)) {
165425c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        push(@PString, $P."=\"".xmlSpecChars($XMLparams{$P})."\"");
16543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(@PString) {
16545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return " ".join(" ", @PString);
16546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
16548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
16549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub addMarkup($)
16553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
16554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Content = $_[0];
16555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # auto-markup
16556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s/\n[ ]*//; # spaces
16557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s!(\@\w+\s*\(\@\w+\))!<nowrap>$1</nowrap>!g; # @old_type (@old_size)
16558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s!(... \(\w+\))!<nowrap><b>$1</b></nowrap>!g; # ... (va_list)
165590d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $Content=~s!<nowrap>(.+?)</nowrap>!<span class='nowrap'>$1</span>!g;
16560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s!([2-9]\))!<br/>$1!g; # 1), 2), ...
16561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Content=~/\ANOTE:/)
16562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # notes
16563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Content=~s!(NOTE):!<b>$1</b>:!g;
16564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
16566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Content=~s!(NOTE):!<br/><b>$1</b>:!g;
16567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s! (out)-! <b>$1</b>-!g; # out-parameters
16569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Keywords = (
16570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "void",
16571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "const",
16572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "static",
16573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "restrict",
16574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "volatile",
16575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "register",
165760d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        "virtual"
16577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
16578ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $MKeys = join("|", @Keywords);
16579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (@Keywords) {
16580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MKeys .= "|non-".$_;
16581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s!(added\s*|to\s*|from\s*|became\s*)($MKeys)([^\w-]|\Z)!$1<b>$2</b>$3!ig; # intrinsic types, modifiers
165830d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
165840d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    # Markdown
165850d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $Content=~s!\*\*([\w\-]+)\*\*!<b>$1</b>!ig;
165860d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $Content=~s!\*([\w\-]+)\*!<i>$1</i>!ig;
16587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Content;
16588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub applyMacroses($$$$)
16591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
16592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Level, $Kind, $Content, $Problem) = @_;
16593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Content or not $Problem);
16594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Problem->{"Word_Size"} = $WORD_SIZE{2};
16595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content = addMarkup($Content);
16596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # macros
16597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Attr (sort {$b cmp $a} keys(%{$Problem}))
16598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
16599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Macro = "\@".lc($Attr);
16600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Value = $Problem->{$Attr};
16601dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if(not defined $Value
16602dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        or $Value eq "") {
16603dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            next;
16604dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
166055c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        if($Value=~/\s\(/ and $Value!~/['"]/)
16606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # functions
166071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Value=~s/\s*\[[\w\-]+\]//g; # remove quals
166081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Value=~s/\s\w+(\)|,)/$1/g; # remove parameter names
16609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Value = black_name($Value);
16610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Value=~/\s/) {
16612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Value = "<span class='value'>".htmlSpecChars($Value)."</span>";
16613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Value=~/\A\d+\Z/
16615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and ($Attr eq "Old_Size" or $Attr eq "New_Size"))
16616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # bits to bytes
16617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Value % $BYTE_SIZE)
16618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # bits
16619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Value==1) {
16620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Value = "<b>".$Value."</b> bit";
16621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
16623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Value = "<b>".$Value."</b> bits";
16624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
16627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # bytes
16628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Value /= $BYTE_SIZE;
16629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Value==1) {
16630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Value = "<b>".$Value."</b> byte";
16631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
16633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Value = "<b>".$Value."</b> bytes";
16634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
166370d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        else
166380d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
16639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Value = "<b>".htmlSpecChars($Value)."</b>";
16640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Content=~s/\Q$Macro\E/$Value/g;
16642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Content=~/(\A|[^\@\w])\@\w/)
16645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
16646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $IncompleteRules{$Level}{$Kind})
16647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # only one warning
16648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            printMsg("WARNING", "incomplete rule \"$Kind\" (\"$Level\")");
16649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $IncompleteRules{$Level}{$Kind} = 1;
16650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Content;
16653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16655dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenkosub get_Report_SymbolProblems($$)
16656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
166571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($TargetSeverity, $Level) = @_;
166581693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $INTERFACE_PROBLEMS = "";
166591693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my (%ReportMap, %SymbolChanges) = ();
166601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$CompatProblems{$Level}}))
16661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
166621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my ($SN, $SS, $SV) = separate_symbol($Symbol);
166631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SV and defined $CompatProblems{$Level}{$SN}) {
166641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
166651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
166661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $Kind (sort keys(%{$CompatProblems{$Level}{$Symbol}}))
16667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CompatRules{$Level}{$Kind}{"Kind"} eq "Symbols"
166691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and $Kind ne "Added_Symbol" and $Kind ne "Removed_Symbol")
16670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
166711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my $HeaderName = $CompleteSignature{1}{$Symbol}{"Header"};
166721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my $DyLib = $Symbol_Library{1}{$Symbol};
166731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if(not $DyLib and my $VSym = $SymVer{1}{$Symbol})
16674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # Symbol with Version
16675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $DyLib = $Symbol_Library{1}{$VSym};
16676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1667762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(not $DyLib)
1667862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                { # const global data
1667962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $DyLib = "";
1668062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
166811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Source" and $ReportFormat eq "html")
166821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # do not show library name in HTML report
166831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $DyLib = "";
166841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
166851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$SymbolChanges{$Symbol}{$Kind}} = %{$CompatProblems{$Level}{$Symbol}{$Kind}};
166861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Location (sort keys(%{$SymbolChanges{$Symbol}{$Kind}}))
16687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
16688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $Priority = getProblemSeverity($Level, $Kind);
166891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Priority ne $TargetSeverity) {
166901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        delete($SymbolChanges{$Symbol}{$Kind}{$Location});
16691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
16692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
166931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if(not keys(%{$SymbolChanges{$Symbol}{$Kind}}))
166941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                {
166951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    delete($SymbolChanges{$Symbol}{$Kind});
166961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    next;
16697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
166981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $ReportMap{$HeaderName}{$DyLib}{$Symbol} = 1;
16699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
167011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not keys(%{$SymbolChanges{$Symbol}})) {
167021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            delete($SymbolChanges{$Symbol});
167031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
16704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
16706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
167071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $INTERFACE_PROBLEMS .= "  <header name=\"$HeaderName\">\n";
167101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $DyLib (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
16711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
16712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $INTERFACE_PROBLEMS .= "    <library name=\"$DyLib\">\n";
16713fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                foreach my $Symbol (sort {lc($tr_name{$a}?$tr_name{$a}:$a) cmp lc($tr_name{$b}?$tr_name{$b}:$b)} keys(%SymbolChanges))
16714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
16715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $INTERFACE_PROBLEMS .= "      <symbol name=\"$Symbol\">\n";
16716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    foreach my $Kind (keys(%{$SymbolChanges{$Symbol}}))
16717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
16718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        foreach my $Location (sort keys(%{$SymbolChanges{$Symbol}{$Kind}}))
16719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
16720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            my %Problem = %{$SymbolChanges{$Symbol}{$Kind}{$Location}};
167210d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            $Problem{"Param_Pos"} = showPos($Problem{"Param_Pos"});
16722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= "        <problem id=\"$Kind\">\n";
16723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            my $Change = $CompatRules{$Level}{$Kind}{"Change"};
16724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= "          <change".getXmlParams($Change, \%Problem).">$Change</change>\n";
16725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            my $Effect = $CompatRules{$Level}{$Kind}{"Effect"};
16726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= "          <effect".getXmlParams($Effect, \%Problem).">$Effect</effect>\n";
16727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            my $Overcome = $CompatRules{$Level}{$Kind}{"Overcome"};
16728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= "          <overcome".getXmlParams($Overcome, \%Problem).">$Overcome</overcome>\n";
16729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= "        </problem>\n";
16730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
16731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
16732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $INTERFACE_PROBLEMS .= "      </symbol>\n";
16733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $INTERFACE_PROBLEMS .= "    </library>\n";
16735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $INTERFACE_PROBLEMS .= "  </header>\n";
16737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
167381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $INTERFACE_PROBLEMS = "<problems_with_symbols severity=\"$TargetSeverity\">\n".$INTERFACE_PROBLEMS."</problems_with_symbols>\n\n";
16739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
16741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
16742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $ProblemsNum = 0;
167431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
167451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $DyLib (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
16746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
167471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my (%NameSpaceSymbols, %NewSignature) = ();
167481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Symbol (keys(%{$ReportMap{$HeaderName}{$DyLib}})) {
1674974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $NameSpaceSymbols{select_Symbol_NS($Symbol, 1)}{$Symbol} = 1;
16750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
167511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $NameSpace (sort keys(%NameSpaceSymbols))
16752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
167531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $INTERFACE_PROBLEMS .= getTitle($HeaderName, $DyLib, $NameSpace);
16754fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    my @SortedInterfaces = sort {lc($tr_name{$a}?$tr_name{$a}:$a) cmp lc($tr_name{$b}?$tr_name{$b}:$b)} keys(%{$NameSpaceSymbols{$NameSpace}});
167551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    foreach my $Symbol (@SortedInterfaces)
16756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
167571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        my $Signature = get_Signature($Symbol, 1);
167581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        my $SYMBOL_REPORT = "";
16759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $ProblemNum = 1;
167601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        foreach my $Kind (keys(%{$SymbolChanges{$Symbol}}))
16761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
167621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            foreach my $Location (sort keys(%{$SymbolChanges{$Symbol}{$Kind}}))
16763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            {
167641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                my %Problem = %{$SymbolChanges{$Symbol}{$Kind}{$Location}};
167650d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                $Problem{"Param_Pos"} = showPos($Problem{"Param_Pos"});
16766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                if($Problem{"New_Signature"}) {
167671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    $NewSignature{$Symbol} = $Problem{"New_Signature"};
16768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                }
16769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                if(my $Change = applyMacroses($Level, $Kind, $CompatRules{$Level}{$Kind}{"Change"}, \%Problem))
16770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                {
16771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                    my $Effect = applyMacroses($Level, $Kind, $CompatRules{$Level}{$Kind}{"Effect"}, \%Problem);
167721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    $SYMBOL_REPORT .= "<tr><th>$ProblemNum</th><td align='left' valign='top'>".$Change."</td><td align='left' valign='top'>".$Effect."</td></tr>\n";
16773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                    $ProblemNum += 1;
16774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                    $ProblemsNum += 1;
16775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                }
16776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
16778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ProblemNum -= 1;
167791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($SYMBOL_REPORT)
16780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
167811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= $ContentSpanStart."<span class='extendable'>[+]</span> ";
16782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if($Signature) {
167831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $INTERFACE_PROBLEMS .= highLight_Signature_Italic_Color($Signature);
16784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            else {
167861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $INTERFACE_PROBLEMS .= $Symbol;
16787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
167881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= " ($ProblemNum)".$ContentSpanEnd."<br/>\n";
167891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= $ContentDivStart."\n";
167901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            if($NewSignature{$Symbol})
167911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            { # argument list changed to
167921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey 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";
16793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
167941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            if($Symbol=~/\A(_Z|\?)/) {
167951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $INTERFACE_PROBLEMS .= "<span class='mangled'>&#160;&#160;&#160;&#160;[symbol: <b>$Symbol</b>]</span><br/>\n";
167961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            }
167971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey 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";
167981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= $ContentDivEnd;
16799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if($NameSpace) {
1680062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                $INTERFACE_PROBLEMS=~s/\b\Q$NameSpace\E::\b//g;
16801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
16803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
168041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $INTERFACE_PROBLEMS .= "<br/>";
16805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($INTERFACE_PROBLEMS)
16809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
168101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $INTERFACE_PROBLEMS = insertIDs($INTERFACE_PROBLEMS);
168111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Title = "Problems with Symbols, $TargetSeverity Severity";
168121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($TargetSeverity eq "Safe")
16813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # Safe Changes
16814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Title = "Other Changes in Symbols";
16815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
168160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey 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";
16817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $INTERFACE_PROBLEMS;
16820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_Report_TypeProblems($$)
16823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
168241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($TargetSeverity, $Level) = @_;
168251693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $TYPE_PROBLEMS = "";
1682674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my (%ReportMap, %TypeChanges) = ();
168271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Interface (sort keys(%{$CompatProblems{$Level}}))
16828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
168291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $Kind (keys(%{$CompatProblems{$Level}{$Interface}}))
16830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CompatRules{$Level}{$Kind}{"Kind"} eq "Types")
16832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
168331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Location (sort {cmp_locations($b, $a)} sort keys(%{$CompatProblems{$Level}{$Interface}{$Kind}}))
16834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
168351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my $TypeName = $CompatProblems{$Level}{$Interface}{$Kind}{$Location}{"Type_Name"};
168361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my $Target = $CompatProblems{$Level}{$Interface}{$Kind}{$Location}{"Target"};
168371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my $Severity = getProblemSeverity($Level, $Kind);
168381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Severity eq "Safe"
168391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    and $TargetSeverity ne "Safe") {
16840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        next;
16841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
168421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
16843dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    if(cmpSeverities($Type_MaxSeverity{$Level}{$TypeName}{$Kind}{$Target}, $Severity))
16844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # select a problem with the highest priority
16845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        next;
16846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
168471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    %{$TypeChanges{$TypeName}{$Kind}{$Location}} = %{$CompatProblems{$Level}{$Interface}{$Kind}{$Location}};
16848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %Kinds_Locations = ();
16853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $TypeName (keys(%TypeChanges))
16854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
16855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my %Kinds_Target = ();
16856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Kind (sort keys(%{$TypeChanges{$TypeName}}))
16857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Location (sort {cmp_locations($b, $a)} sort keys(%{$TypeChanges{$TypeName}{$Kind}}))
16859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
168601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my $Severity = getProblemSeverity($Level, $Kind);
168611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Severity ne $TargetSeverity)
16862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # other priority
16863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    delete($TypeChanges{$TypeName}{$Kind}{$Location});
16864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
16865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Kinds_Locations{$TypeName}{$Kind}{$Location} = 1;
16867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Target = $TypeChanges{$TypeName}{$Kind}{$Location}{"Target"};
16868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Kinds_Target{$Kind}{$Target})
16869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # duplicate target
16870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    delete($TypeChanges{$TypeName}{$Kind}{$Location});
16871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
16872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Kinds_Target{$Kind}{$Target} = 1;
1687462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $HeaderName = $TypeInfo{1}{$TName_Tid{1}{$TypeName}}{"Header"};
168751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $ReportMap{$HeaderName}{$TypeName} = 1;
16876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not keys(%{$TypeChanges{$TypeName}{$Kind}})) {
16878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                delete($TypeChanges{$TypeName}{$Kind});
16879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
168811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not keys(%{$TypeChanges{$TypeName}})) {
168821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            delete($TypeChanges{$TypeName});
168831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
16884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16885850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my @Symbols = sort {lc($tr_name{$a}?$tr_name{$a}:$a) cmp lc($tr_name{$b}?$tr_name{$b}:$b)} keys(%{$CompatProblems{$Level}});
16886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
16887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
168881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TYPE_PROBLEMS .= "  <header name=\"$HeaderName\">\n";
168911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $TypeName (keys(%{$ReportMap{$HeaderName}}))
16892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
168935c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                $TYPE_PROBLEMS .= "    <type name=\"".xmlSpecChars($TypeName)."\">\n";
16894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Kind (sort {$b=~/Size/ <=> $a=~/Size/} sort keys(%{$TypeChanges{$TypeName}}))
16895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
16896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    foreach my $Location (sort {cmp_locations($b, $a)} sort keys(%{$TypeChanges{$TypeName}{$Kind}}))
16897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
16898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my %Problem = %{$TypeChanges{$TypeName}{$Kind}{$Location}};
16899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $TYPE_PROBLEMS .= "      <problem id=\"$Kind\">\n";
16900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $Change = $CompatRules{$Level}{$Kind}{"Change"};
16901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $TYPE_PROBLEMS .= "        <change".getXmlParams($Change, \%Problem).">$Change</change>\n";
16902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $Effect = $CompatRules{$Level}{$Kind}{"Effect"};
16903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $TYPE_PROBLEMS .= "        <effect".getXmlParams($Effect, \%Problem).">$Effect</effect>\n";
16904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $Overcome = $CompatRules{$Level}{$Kind}{"Overcome"};
16905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $TYPE_PROBLEMS .= "        <overcome".getXmlParams($Overcome, \%Problem).">$Overcome</overcome>\n";
16906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $TYPE_PROBLEMS .= "      </problem>\n";
16907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
16908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16909850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $TYPE_PROBLEMS .= getAffectedSymbols($Level, $TypeName, $Kinds_Locations{$TypeName}, \@Symbols);
169101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary" and grep {$_=~/Virtual|Base_Class/} keys(%{$Kinds_Locations{$TypeName}})) {
16911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $TYPE_PROBLEMS .= showVTables($TypeName);
16912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $TYPE_PROBLEMS .= "    </type>\n";
16914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TYPE_PROBLEMS .= "  </header>\n";
16916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
169171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TYPE_PROBLEMS = "<problems_with_types severity=\"$TargetSeverity\">\n".$TYPE_PROBLEMS."</problems_with_types>\n\n";
16918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
16920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
16921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $ProblemsNum = 0;
169221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
169241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my (%NameSpace_Type) = ();
169251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $TypeName (keys(%{$ReportMap{$HeaderName}})) {
1692674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $NameSpace_Type{select_Type_NS($TypeName, 1)}{$TypeName} = 1;
16927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $NameSpace (sort keys(%NameSpace_Type))
16929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
169301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $TYPE_PROBLEMS .= getTitle($HeaderName, "", $NameSpace);
1693174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                my @SortedTypes = sort {lc(show_Type($a, 0, 1)) cmp lc(show_Type($b, 0, 1))} keys(%{$NameSpace_Type{$NameSpace}});
16932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $TypeName (@SortedTypes)
16933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
16934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $ProblemNum = 1;
16935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $TYPE_REPORT = "";
16936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    foreach my $Kind (sort {$b=~/Size/ <=> $a=~/Size/} sort keys(%{$TypeChanges{$TypeName}}))
16937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
16938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        foreach my $Location (sort {cmp_locations($b, $a)} sort keys(%{$TypeChanges{$TypeName}{$Kind}}))
16939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
16940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            my %Problem = %{$TypeChanges{$TypeName}{$Kind}{$Location}};
16941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if(my $Change = applyMacroses($Level, $Kind, $CompatRules{$Level}{$Kind}{"Change"}, \%Problem))
16942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            {
16943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                my $Effect = applyMacroses($Level, $Kind, $CompatRules{$Level}{$Kind}{"Effect"}, \%Problem);
16944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                $TYPE_REPORT .= "<tr><th>$ProblemNum</th><td align='left' valign='top'>".$Change."</td><td align='left' valign='top'>$Effect</td></tr>\n";
16945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                $ProblemNum += 1;
16946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                $ProblemsNum += 1;
16947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
16949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
16950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ProblemNum -= 1;
16951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($TYPE_REPORT)
16952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
16953850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        my $Affected = getAffectedSymbols($Level, $TypeName, $Kinds_Locations{$TypeName}, \@Symbols);
16954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $ShowVTables = "";
169551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($Level eq "Binary" and grep {$_=~/Virtual|Base_Class/} keys(%{$Kinds_Locations{$TypeName}})) {
16956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ShowVTables = showVTables($TypeName);
16957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
1695874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1695974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        $TYPE_PROBLEMS .= $ContentSpanStart."<span class='extendable'>[+]</span> ".show_Type($TypeName, 1, 1)." ($ProblemNum)".$ContentSpanEnd;
169601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $TYPE_PROBLEMS .= "<br/>\n".$ContentDivStart."<table class='ptable'><tr>\n";
169611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $TYPE_PROBLEMS .= "<th width='2%'></th><th width='47%'>Change</th>\n";
169621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $TYPE_PROBLEMS .= "<th>Effect</th></tr>".$TYPE_REPORT."</table>\n";
169631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $TYPE_PROBLEMS .= $ShowVTables.$Affected."<br/><br/>".$ContentDivEnd."\n";
16964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($NameSpace) {
1696562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            $TYPE_PROBLEMS=~s/\b\Q$NameSpace\E::(\w|\~)/$1/g;
16966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
16967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
16968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
169691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $TYPE_PROBLEMS .= "<br/>";
16970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($TYPE_PROBLEMS)
16973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
169741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $TYPE_PROBLEMS = insertIDs($TYPE_PROBLEMS);
169751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Title = "Problems with Data Types, $TargetSeverity Severity";
169761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($TargetSeverity eq "Safe")
16977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # Safe Changes
16978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Title = "Other Changes in Data Types";
16979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
169801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $TYPE_PROBLEMS = "<a name=\'".get_Anchor("Type", $Level, $TargetSeverity)."\'></a>\n<h2>$Title ($ProblemsNum)</h2><hr/>\n".$TYPE_PROBLEMS.$TOP_REF."<br/>\n";
16981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $TYPE_PROBLEMS;
16984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1698674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkosub show_Type($$$)
1698774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko{
1698874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my ($Name, $Html, $LibVersion) = @_;
1698974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $TType = $TypeInfo{$LibVersion}{$TName_Tid{$LibVersion}{$Name}}{"Type"};
1699074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    $TType = lc($TType);
1699174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($TType=~/struct|union|enum/) {
1699274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $Name=~s/\A\Q$TType\E //g;
1699374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
1699474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($Html) {
1699574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $Name = "<span class='ttype'>".$TType."</span> ".htmlSpecChars($Name);
1699674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
1699774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    else {
1699874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $Name = $TType." ".$Name;
1699974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
1700074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return $Name;
1700174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko}
1700274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
170031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub get_Anchor($$$)
170041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
170051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Kind, $Level, $Severity) = @_;
170061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($JoinReport)
170071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
170081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Severity eq "Safe") {
170091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return "Other_".$Level."_Changes_In_".$Kind."s";
170101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
170111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else {
170121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Kind."_".$Level."_Problems_".$Severity;
170131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
170141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
170151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
170161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
170171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Severity eq "Safe") {
170181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return "Other_Changes_In_".$Kind."s";
170191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
170201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else {
170211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Kind."_Problems_".$Severity;
170221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
170231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
170241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
170251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
17026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub showVTables($)
17027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
17028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TypeName = $_[0];
17029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TypeId1 = $TName_Tid{1}{$TypeName};
1703062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type1 = get_Type($TypeId1, 1);
17031ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Type1{"VTable"}
17032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and keys(%{$Type1{"VTable"}}))
17033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
17034ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $TypeId2 = $TName_Tid{2}{$TypeName};
1703562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Type2 = get_Type($TypeId2, 2);
17036ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(defined $Type2{"VTable"}
17037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and keys(%{$Type2{"VTable"}}))
17038ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my %Indexes = map {$_=>1} (keys(%{$Type1{"VTable"}}), keys(%{$Type2{"VTable"}}));
17040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my %Entries = ();
170411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $Index (sort {int($a)<=>int($b)} (keys(%Indexes)))
17042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
170431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Entries{$Index}{"E1"} = simpleVEntry($Type1{"VTable"}{$Index});
170441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Entries{$Index}{"E2"} = simpleVEntry($Type2{"VTable"}{$Index});
17045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17046ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $VTABLES = "";
17047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ReportFormat eq "xml")
17048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # XML
17049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $VTABLES .= "      <vtable>\n";
170501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Index (sort {int($a)<=>int($b)} (keys(%Entries)))
17051ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
170521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $VTABLES .= "        <entry offset=\"".$Index."\">\n";
170535c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                    $VTABLES .= "          <old>".xmlSpecChars($Entries{$Index}{"E1"})."</old>\n";
170545c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                    $VTABLES .= "          <new>".xmlSpecChars($Entries{$Index}{"E2"})."</new>\n";
17055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $VTABLES .= "        </entry>\n";
17056ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17057ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $VTABLES .= "      </vtable>\n\n";
17058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
17060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # HTML
170611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $VTABLES .= "<table class='vtable'>";
17062ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $VTABLES .= "<tr><th width='2%'>Offset</th>";
17063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $VTABLES .= "<th width='45%'>Virtual Table (Old) - ".(keys(%{$Type1{"VTable"}}))." entries</th>";
17064ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $VTABLES .= "<th>Virtual Table (New) - ".(keys(%{$Type2{"VTable"}}))." entries</th></tr>";
170651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Index (sort {int($a)<=>int($b)} (keys(%Entries)))
17066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
17067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my ($Color1, $Color2) = ("", "");
170681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Entries{$Index}{"E1"} ne $Entries{$Index}{"E2"})
17069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
170701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($Entries{$Index}{"E1"})
17071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
170721693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            $Color1 = " class='failed'";
170731693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            $Color2 = " class='failed'";
17074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
17075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        else {
170761693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            $Color2 = " class='warning'";
17077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
17078ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
170791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $VTABLES .= "<tr><th>".$Index."</th>\n";
170801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $VTABLES .= "<td$Color1>".htmlSpecChars($Entries{$Index}{"E1"})."</td>\n";
170811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $VTABLES .= "<td$Color2>".htmlSpecChars($Entries{$Index}{"E2"})."</td></tr>\n";
17082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $VTABLES .= "</table><br/>\n";
17084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $VTABLES = $ContentDivStart.$VTABLES.$ContentDivEnd;
170851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $VTABLES = $ContentSpanStart_Info."[+] show v-table (old and new)".$ContentSpanEnd."<br/>\n".$VTABLES;
17086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $VTABLES;
17088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
17091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
17093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub simpleVEntry($)
17094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
17095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $VEntry = $_[0];
17096dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if(not defined $VEntry
17097dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    or $VEntry eq "") {
17098dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        return "";
17099dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
17100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $VEntry=~s/\A(.+)::(_ZThn.+)\Z/$2/; # thunks
17101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $VEntry=~s/_ZTI\w+/typeinfo/g; # typeinfo
17102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($VEntry=~/\A_ZThn.+\Z/) {
17103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $VEntry = "non-virtual thunk";
17104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17105fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    $VEntry=~s/\A\(int \(\*\)\(...\)\)\s*([a-z_])/$1/i;
17106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # support for old GCC versions
17107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $VEntry=~s/\A0u\Z/(int (*)(...))0/;
17108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $VEntry=~s/\A4294967268u\Z/(int (*)(...))-0x000000004/;
17109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $VEntry=~s/\A&_Z\Z/& _Z/;
17110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $VEntry=~s/([^:]+)::\~([^:]+)\Z/~$1/; # destructors
17111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $VEntry;
17112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
17114850437949b65b213696469223d749c1f74c29601Andrey Ponomarenkosub getAffectedSymbols($$$$)
17115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
17116850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my ($Level, $Target_TypeName, $Kinds_Locations, $Syms) = @_;
17117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LIMIT = 1000;
17118850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($#{$Syms}>=10000)
17119850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    { # reduce size of the report
17120850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $LIMIT = 10;
17121850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
17122850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my %SProblems = ();
17123850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    foreach my $Symbol (@{$Syms})
17124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
17125850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(keys(%SProblems)>$LIMIT) {
17126850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            last;
17127850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
171281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(($Symbol=~/C2E|D2E|D0E/))
17129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # duplicated problems for C2 constructors, D2 and D0 destructors
17130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
17131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
171321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my ($SN, $SS, $SV) = separate_symbol($Symbol);
171331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Source")
171341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # remove symbol version
171351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Symbol=$SN;
171361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
17137dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        my ($MinPath_Length, $ProblemLocation_Last) = (-1, "");
17138dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        my $Severity_Max = 0;
171391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $Signature = get_Signature($Symbol, 1);
171401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $Kind (keys(%{$CompatProblems{$Level}{$Symbol}}))
17141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
171421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $Location (keys(%{$CompatProblems{$Level}{$Symbol}{$Kind}}))
17143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
17144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not defined $Kinds_Locations->{$Kind}
17145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                or not $Kinds_Locations->{$Kind}{$Location}) {
17146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
17147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
171481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($SV and defined $CompatProblems{$Level}{$SN}
171491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                and defined $CompatProblems{$Level}{$SN}{$Kind}{$Location})
17150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # duplicated problems for versioned symbols
17151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
17152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
171531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my $Type_Name = $CompatProblems{$Level}{$Symbol}{$Kind}{$Location}{"Type_Name"};
17154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next if($Type_Name ne $Target_TypeName);
17155ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
171561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my $Position = $CompatProblems{$Level}{$Symbol}{$Kind}{$Location}{"Param_Pos"};
171571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my $Param_Name = $CompatProblems{$Level}{$Symbol}{$Kind}{$Location}{"Param_Name"};
17158dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                my $Severity = getProblemSeverity($Level, $Kind);
17159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Path_Length = 0;
17160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $ProblemLocation = $Location;
17161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Type_Name) {
17162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ProblemLocation=~s/->\Q$Type_Name\E\Z//g;
17163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17164dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                while($ProblemLocation=~/\-\>/g) {
17165dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    $Path_Length += 1;
17166dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                }
17167dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if($MinPath_Length==-1 or ($Path_Length<=$MinPath_Length and $Severity_Val{$Severity}>$Severity_Max)
17168dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                or (cmp_locations($ProblemLocation, $ProblemLocation_Last) and $Severity_Val{$Severity}==$Severity_Max))
17169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
17170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $MinPath_Length = $Path_Length;
17171dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    $Severity_Max = $Severity_Val{$Severity};
17172ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ProblemLocation_Last = $ProblemLocation;
17173850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    %{$SProblems{$Symbol}} = (
17174dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        "Descr"=>getAffectDescription($Level, $Symbol, $Kind, $Location),
17175dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        "Severity_Max"=>$Severity_Max,
17176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Signature"=>$Signature,
17177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Position"=>$Position,
17178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Param_Name"=>$Param_Name,
17179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Location"=>$Location
17180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    );
17181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17185850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my @Symbols = keys(%SProblems);
171861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    @Symbols = sort {lc($tr_name{$a}?$tr_name{$a}:$a) cmp lc($tr_name{$b}?$tr_name{$b}:$b)} @Symbols;
17187850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    @Symbols = sort {$SProblems{$b}{"Severity_Max"}<=>$SProblems{$a}{"Severity_Max"}} @Symbols;
17188850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($#Symbols+1>$LIMIT)
17189850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    { # remove last element
17190850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        pop(@Symbols);
17191850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
17192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Affected = "";
17193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
17194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
17195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Affected .= "      <affected>\n";
171961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $Symbol (@Symbols)
17197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17198850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            my $Param_Name = $SProblems{$Symbol}{"Param_Name"};
17199850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            my $Description = $SProblems{$Symbol}{"Descr"};
17200850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            my $Location = $SProblems{$Symbol}{"Location"};
17201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Target = "";
17202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Param_Name) {
17203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Target = " affected=\"param\" param_name=\"$Param_Name\"";
17204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Location=~/\Aretval(\-|\Z)/i) {
17206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Target = " affected=\"retval\"";
17207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17208ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Location=~/\Athis(\-|\Z)/i) {
17209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Target = " affected=\"this\"";
17210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
172111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Affected .= "        <symbol$Target name=\"$Symbol\">\n";
172125c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            $Affected .= "          <comment>".xmlSpecChars($Description)."</comment>\n";
17213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Affected .= "        </symbol>\n";
17214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Affected .= "      </affected>\n";
17216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
17218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
172191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $Symbol (@Symbols)
17220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17221850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            my $Description = $SProblems{$Symbol}{"Descr"};
17222850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            my $Signature = $SProblems{$Symbol}{"Signature"};
17223850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            my $Pos = $SProblems{$Symbol}{"Position"};
17224a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            $Affected .= "<span class='iname_a'>".highLight_Signature_PPos_Italic($Signature, $Pos, 1, 0, 0)."</span><br/><div class='affect'>".htmlSpecChars($Description)."</div>\n";
17225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17226850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(keys(%SProblems)>$LIMIT) {
17227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Affected .= "and others ...<br/>";
17228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17229850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $Affected = "<div class='affected'>".$Affected."</div>";
17230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Affected)
17231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Affected = $ContentDivStart.$Affected.$ContentDivEnd;
17233850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            $Affected = $ContentSpanStart_Affected."[+] affected symbols (".(keys(%SProblems)>$LIMIT?">".$LIMIT:keys(%SProblems)).")".$ContentSpanEnd.$Affected;
17234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Affected;
17237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
17239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub cmp_locations($$)
17240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1724162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($L1, $L2) = @_;
1724262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($L2=~/\b(retval|this)\b/
1724362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and $L1!~/\b(retval|this)\b/ and $L1!~/\-\>/) {
17244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
17245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1724662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($L2=~/\b(retval|this)\b/ and $L2=~/\-\>/
1724762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and $L1!~/\b(retval|this)\b/ and $L1=~/\-\>/) {
17248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
17249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
17251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
17253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getAffectDescription($$$$)
17254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
172551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Level, $Symbol, $Kind, $Location) = @_;
172561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my %Problem = %{$CompatProblems{$Level}{$Symbol}{$Kind}{$Location}};
172570d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $PPos = showPos($Problem{"Param_Pos"});
17258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Sentence = ();
17259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Location=~s/\A(.*)\-\>.+?\Z/$1/;
17260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Kind eq "Overridden_Virtual_Method"
17261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $Kind eq "Overridden_Virtual_Method_B") {
17262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        push(@Sentence, "The method '".$Problem{"New_Value"}."' will be called instead of this method.");
17263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($CompatRules{$Level}{$Kind}{"Kind"} eq "Types")
17265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
17266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Location eq "this" or $Kind=~/(\A|_)Virtual(_|\Z)/)
17267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
172681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $METHOD_TYPE = $CompleteSignature{1}{$Symbol}{"Constructor"}?"constructor":"method";
1726962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $ClassName = $TypeInfo{1}{$CompleteSignature{1}{$Symbol}{"Class"}}{"Name"};
17270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ClassName eq $Problem{"Type_Name"}) {
17271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@Sentence, "This $METHOD_TYPE is from \'".$Problem{"Type_Name"}."\' class.");
17272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
17274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@Sentence, "This $METHOD_TYPE is from derived class \'".$ClassName."\'.");
17275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
17278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Location=~/retval/)
17280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # return value
17281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Location=~/\-\>/) {
17282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    push(@Sentence, "Field \'".$Location."\' in return value");
17283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
17285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    push(@Sentence, "Return value");
17286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17287dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if(my $Init = $Problem{"InitialType_Type"})
17288dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                {
17289dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    if($Init eq "Pointer") {
17290dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        push(@Sentence, "(pointer)");
17291dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
17292dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    elsif($Init eq "Ref") {
17293dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        push(@Sentence, "(reference)");
17294dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
17295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Location=~/this/)
17298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # "this" pointer
17299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Location=~/\-\>/) {
17300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    push(@Sentence, "Field \'".$Location."\' in the object of this method");
17301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
17303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    push(@Sentence, "\'this\' pointer");
17304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
17307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # parameters
17308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Location=~/\-\>/) {
17309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    push(@Sentence, "Field \'".$Location."\' in $PPos parameter");
17310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
17312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    push(@Sentence, "$PPos parameter");
17313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Problem{"Param_Name"}) {
17315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    push(@Sentence, "\'".$Problem{"Param_Name"}."\'");
17316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17317dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if(my $Init = $Problem{"InitialType_Type"})
17318dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                {
17319dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    if($Init eq "Pointer") {
17320dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        push(@Sentence, "(pointer)");
17321dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
17322dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    elsif($Init eq "Ref") {
17323dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        push(@Sentence, "(reference)");
17324dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
17325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Location eq "this") {
17328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@Sentence, "has base type \'".$Problem{"Type_Name"}."\'.");
17329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1733062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            elsif(defined $Problem{"Start_Type_Name"}
1733162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            and $Problem{"Start_Type_Name"} eq $Problem{"Type_Name"}) {
17332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@Sentence, "has type \'".$Problem{"Type_Name"}."\'.");
17333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
17335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@Sentence, "has base type \'".$Problem{"Type_Name"}."\'.");
17336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1733962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($ExtendedSymbols{$Symbol}) {
173408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        push(@Sentence, " This is a symbol from an external library that may use the \'$TargetLibraryName\' library and change the ABI after recompiling.");
17341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return join(" ", @Sentence);
17343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
17345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_XmlSign($$)
17346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
17347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
17348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Info = $CompleteSignature{$LibVersion}{$Symbol};
17349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Report = "";
17350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Pos (sort {int($a)<=>int($b)} keys(%{$Info->{"Param"}}))
17351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
17352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Name = $Info->{"Param"}{$Pos}{"name"};
1735362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $Type = $Info->{"Param"}{$Pos}{"type"};
1735462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $TypeName = $TypeInfo{$LibVersion}{$Type}{"Name"};
17355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Typedef (keys(%ChangedTypedef))
17356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
173578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(my $Base = $Typedef_BaseName{$LibVersion}{$Typedef}) {
173588f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $TypeName=~s/\b\Q$Typedef\E\b/$Base/g;
173598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
17360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Report .= "    <param pos=\"$Pos\">\n";
17362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Report .= "      <name>".$Name."</name>\n";
173635c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $Report .= "      <type>".xmlSpecChars($TypeName)."</type>\n";
17364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Report .= "    </param>\n";
17365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Return = $Info->{"Return"})
17367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1736862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $RTName = $TypeInfo{$LibVersion}{$Return}{"Name"};
17369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Report .= "    <retval>\n";
173705c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $Report .= "      <type>".xmlSpecChars($RTName)."</type>\n";
17371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Report .= "    </retval>\n";
17372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Report;
17374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
173761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub get_Report_SymbolsInfo($)
17377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
173781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
17379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Report = "<symbols_info>\n";
173801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$CompatProblems{$Level}}))
17381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
173821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my ($SN, $SS, $SV) = separate_symbol($Symbol);
173831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SV and defined $CompatProblems{$Level}{$SN}) {
17384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
17385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Report .= "  <symbol name=\"$Symbol\">\n";
17387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($S1, $P1, $S2, $P2) = ();
173881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $AddedInt{$Level}{$Symbol})
17389ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(defined $CompleteSignature{1}{$Symbol}
17391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and defined $CompleteSignature{1}{$Symbol}{"Header"})
17392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
17393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $P1 = get_XmlSign($Symbol, 1);
17394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $S1 = get_Signature($Symbol, 1);
17395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Symbol=~/\A(_Z|\?)/) {
17397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $S1 = $tr_name{$Symbol};
17398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
174001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $RemovedInt{$Level}{$Symbol})
17401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(defined $CompleteSignature{2}{$Symbol}
17403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and defined $CompleteSignature{2}{$Symbol}{"Header"})
17404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
17405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $P2 = get_XmlSign($Symbol, 2);
17406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $S2 = get_Signature($Symbol, 2);
17407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Symbol=~/\A(_Z|\?)/) {
17409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $S2 = $tr_name{$Symbol};
17410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($S1)
17413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
174145c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            $Report .= "    <old signature=\"".xmlSpecChars($S1)."\">\n";
17415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Report .= $P1;
17416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Report .= "    </old>\n";
17417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($S2 and $S2 ne $S1)
17419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
174205c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            $Report .= "    <new signature=\"".xmlSpecChars($S2)."\">\n";
17421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Report .= $P2;
17422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Report .= "    </new>\n";
17423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Report .= "  </symbol>\n";
17425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Report .= "</symbols_info>\n";
17427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Report;
17428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
174301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub writeReport($$)
17431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
174321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Level, $Report) = @_;
174331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($ReportFormat eq "xml") {
174341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Report = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n".$Report;
174351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
174361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($StdOut)
174371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --stdout option
174381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        print STDOUT $Report;
174391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
174401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
174411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
174421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $RPath = getReportPath($Level);
17443850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        mkpath(get_dirname($RPath));
17444850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
17445850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        open(REPORT, ">", $RPath) || die ("can't open file \'$RPath\': $!\n");
17446850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        print REPORT $Report;
17447850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        close(REPORT);
17448850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
1744962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Browse or $OpenReport)
1745062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # open in browser
1745162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            openReport($RPath);
174521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($JoinReport or $DoubleReport)
174531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
174541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary")
174551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # wait to open a browser
174561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    sleep(1);
174571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
174581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
174591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
174601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
174611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
174621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
1746362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub openReport($)
1746462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
1746562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $Path = $_[0];
1746662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $Cmd = "";
1746762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($Browse)
1746862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # user-defined browser
17469a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        $Cmd = $Browse." \"$Path\"";
1747062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
1747162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not $Cmd)
1747262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # default browser
1747362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($OSgroup eq "macos") {
17474f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $Cmd = "open \"$Path\"";
1747562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1747662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        elsif($OSgroup eq "windows") {
17477f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $Cmd = "start ".path_format($Path, $OSgroup);
1747862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1747962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        else
1748062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # linux, freebsd, solaris
1748162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my @Browsers = (
1748262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                "x-www-browser",
1748362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                "sensible-browser",
1748462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                "firefox",
1748562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                "opera",
1748662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                "xdg-open",
1748762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                "lynx",
1748862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                "links"
1748962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            );
1749062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            foreach my $Br (@Browsers)
1749162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
1749262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($Br = get_CmdPath($Br))
1749362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
17494a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                    $Cmd = $Br." \"$Path\"";
1749562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    last;
1749662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
1749762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
1749862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1749962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
1750062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($Cmd)
1750162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
1750262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Debug) {
1750362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            printMsg("INFO", "running $Cmd");
1750462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
17505f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($OSgroup ne "windows"
17506f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        and $OSgroup ne "macos")
17507f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        {
17508f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($Cmd!~/lynx|links/) {
175098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $Cmd .= "  >\"/dev/null\" 2>&1 &";
17510f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
1751162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1751262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        system($Cmd);
1751362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
1751462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    else {
1751562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        printMsg("ERROR", "cannot open report in browser");
1751662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
1751762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
1751862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
175191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub getReport($)
175201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
175211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
17522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
17523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
175241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
175251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Join")
175261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
175271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Report = "<reports>\n";
175281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= getReport("Binary");
175291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= getReport("Source");
175301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= "</reports>\n";
175311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Report;
175321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
175331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
175341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
175351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Report = "<report kind=\"".lc($Level)."\" version=\"$XML_REPORT_VERSION\">\n\n";
175361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my ($Summary, $MetaData) = get_Summary($Level);
175371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= $Summary."\n";
175381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= get_Report_Added($Level).get_Report_Removed($Level);
175391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= get_Report_Problems("High", $Level).get_Report_Problems("Medium", $Level).get_Report_Problems("Low", $Level).get_Report_Problems("Safe", $Level);
175401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= get_Report_SymbolsInfo($Level);
175411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= "</report>\n";
175421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Report;
175431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
17544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
17546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
175471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $CssStyles = readModule("Styles", "Report.css");
175481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $JScripts = readModule("Scripts", "Sections.js");
175491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Join")
175501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
175511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $CssStyles .= "\n".readModule("Styles", "Tabs.css");
175521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $JScripts .= "\n".readModule("Scripts", "Tabs.js");
17553b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            my $Title = $TargetLibraryFName.": ".$Descriptor{1}{"Version"}." to ".$Descriptor{2}{"Version"}." compatibility report";
17554b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            my $Keywords = $TargetLibraryFName.", compatibility, API, report";
175551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Description = "Compatibility report for the $TargetLibraryFName $TargetComponent between ".$Descriptor{1}{"Version"}." and ".$Descriptor{2}{"Version"}." versions";
175561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my ($BSummary, $BMetaData) = get_Summary("Binary");
175571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my ($SSummary, $SMetaData) = get_Summary("Source");
175581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey 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>";
175591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= get_Report_Header("Join")."
175601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            <br/><div class='tabset'>
175611693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            <a id='BinaryID' href='#BinaryTab' class='tab active'>Binary<br/>Compatibility</a>
175621693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            <a id='SourceID' href='#SourceTab' style='margin-left:3px' class='tab disabled'>Source<br/>Compatibility</a>
175631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            </div>";
175641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey 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>";
175651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey 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>";
175669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $Report .= getReportFooter($TargetLibraryFName, not $JoinReport);
175671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= "\n<div style='height:999px;'></div>\n</body></html>";
175681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Report;
175691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
175701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
175711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
175721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my ($Summary, $MetaData) = get_Summary($Level);
17573b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            my $Title = $TargetLibraryFName.": ".$Descriptor{1}{"Version"}." to ".$Descriptor{2}{"Version"}." ".lc($Level)." compatibility report";
17574b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            my $Keywords = $TargetLibraryFName.", ".lc($Level)." compatibility, API, report";
17575b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            my $Description = "$Level compatibility report for the ".$TargetLibraryFName." ".$TargetComponent." between ".$Descriptor{1}{"Version"}." and ".$Descriptor{2}{"Version"}." versions";
175761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Binary")
175771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
175781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if(getArch(1) eq getArch(2)
175791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                and getArch(1) ne "unknown") {
175801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $Description .= " on ".showArch(getArch(1));
175811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
175821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
175831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Report = "<!-\- $MetaData -\->\n".composeHTML_Head($Title, $Keywords, $Description, $CssStyles, $JScripts)."\n<body>\n<div><a name='Top'></a>\n";
175841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= get_Report_Header($Level)."\n".$Summary."\n";
175851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= get_Report_Added($Level).get_Report_Removed($Level);
175861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= get_Report_Problems("High", $Level).get_Report_Problems("Medium", $Level).get_Report_Problems("Low", $Level).get_Report_Problems("Safe", $Level);
175871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= get_SourceInfo();
175881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= "</div>\n<br/><br/><br/><hr/>\n";
175899927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $Report .= getReportFooter($TargetLibraryFName, not $JoinReport);
175901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= "\n<div style='height:999px;'></div>\n</body></html>";
175911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Report;
175921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
17593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
175941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
175951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
175961693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub getLegend()
175971693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{
175981693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return "<br/>
175991693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko<table class='summary'>
176001693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko<tr>
176011693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    <td class='new'>added</td>
176021693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    <td class='passed'>compatible</td>
176031693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko</tr>
176041693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko<tr>
176051693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    <td class='warning'>warning</td>
176061693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    <td class='failed'>incompatible</td>
176071693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko</tr></table>\n";
176081693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko}
176091693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
176101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub createReport()
176111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
176121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($JoinReport)
176130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # --stdout
176141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        writeReport("Join", getReport("Join"));
17615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
176161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($DoubleReport)
176171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # default
176181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        writeReport("Binary", getReport("Binary"));
176191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        writeReport("Source", getReport("Source"));
176201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
176211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($BinaryOnly)
176221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --binary
176231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        writeReport("Binary", getReport("Binary"));
176241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
176251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($SourceOnly)
176261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --source
176271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        writeReport("Source", getReport("Source"));
17628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
176319927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub getReportFooter($$)
17632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
176339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my ($LibName, $Wide) = @_;
176349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my $FooterStyle = $Wide?"width:99%":"width:97%;padding-top:3px";
176351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Footer = "<div style='$FooterStyle;font-size:11px;' align='right'><i>Generated on ".(localtime time); # report date
17636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Footer .= " for <span style='font-weight:bold'>$LibName</span>"; # tested library/system name
176371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $Footer .= " by <a href='".$HomePage{"Wiki"}."'>ABI Compliance Checker</a>"; # tool name
176381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $ToolSummary = "<br/>A tool for checking backward compatibility of a C/C++ library API&#160;&#160;";
17639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Footer .= " $TOOL_VERSION &#160;$ToolSummary</i></div>"; # tool version
17640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Footer;
17641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
17643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_Report_Problems($$)
17644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
17645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Priority, $Level) = @_;
17646dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my $Report = get_Report_TypeProblems($Priority, $Level);
176471693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(my $SProblems = get_Report_SymbolProblems($Priority, $Level)) {
176481693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Report .= $SProblems;
17649dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
17650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Priority eq "Low")
17651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
176528f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Report .= get_Report_ChangedConstants("Low", $Level);
1765382bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko        if($ReportFormat eq "html")
1765482bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko        {
17655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CheckImpl and $Level eq "Binary") {
17656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Report .= get_Report_Impl();
17657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
176608f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($Priority eq "Safe")
176618f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
176628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Report .= get_Report_ChangedConstants("Safe", $Level);
176638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
17664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "html")
17665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
17666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Report)
17667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # add anchor
176681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($JoinReport)
176691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
176701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Priority eq "Safe") {
176711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $Report = "<a name=\'Other_".$Level."_Changes\'></a>".$Report;
176721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
176731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                else {
176741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $Report = "<a name=\'".$Priority."_Risk_".$Level."_Problems\'></a>".$Report;
176751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
17676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
176771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            else
176781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
176791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Priority eq "Safe") {
176801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $Report = "<a name=\'Other_Changes\'></a>".$Report;
176811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
176821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                else {
176831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $Report = "<a name=\'".$Priority."_Risk_Problems\'></a>".$Report;
176841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
17685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Report;
17689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
176911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub composeHTML_Head($$$$$)
17692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
176931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Title, $Keywords, $Description, $Styles, $Scripts) = @_;
176941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    return "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
176951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    <html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">
176961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    <head>
17697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />
17698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <meta name=\"keywords\" content=\"$Keywords\" />
17699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <meta name=\"description\" content=\"$Description\" />
177001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    <title>
177011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Title
177021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    </title>
177031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    <style type=\"text/css\">
177041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $Styles
177051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    </style>
177061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    <script type=\"text/javascript\" language=\"JavaScript\">
177071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    <!--
177081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $Scripts
177091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    -->
177101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    </script>
177111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    </head>";
17712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
17714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub insertIDs($)
17715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
17716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Text = $_[0];
17717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($Text=~/CONTENT_ID/)
17718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
17719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(int($Content_Counter)%2) {
17720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ContentID -= 1;
17721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Text=~s/CONTENT_ID/c_$ContentID/;
17723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ContentID += 1;
17724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Content_Counter += 1;
17725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Text;
17727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
17729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub checkPreprocessedUnit($)
17730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
17731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
17732a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    my ($CurHeader, $CurHeaderName) = ("", "");
1773374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $CurClass = ""; # extra info
177341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    open(PREPROC, $Path) || die ("can't open file \'$Path\': $!\n");
1773574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
17736a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    while(my $Line = <PREPROC>)
177371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # detecting public and private constants
17738a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if(substr($Line, 0, 1) eq "#")
17739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17740a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            chomp($Line);
17741a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            if($Line=~/\A\#\s+\d+\s+\"(.+)\"/)
17742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
17743a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                $CurHeader = path_format($1, $OSgroup);
17744a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                $CurHeaderName = get_filename($CurHeader);
1774574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $CurClass = "";
1774674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1774774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if(index($CurHeader, $TMP_DIR)==0) {
1774874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    next;
1774974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
1775074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
17751fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(substr($CurHeaderName, 0, 1) eq "<")
17752fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                { # <built-in>, <command-line>, etc.
17753fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $CurHeaderName = "";
17754fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $CurHeader = "";
17755fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
17756fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
1775774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if($ExtraInfo)
1775874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                {
17759fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if($CurHeaderName) {
1776074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        $PreprocessedHeaders{$Version}{$CurHeader} = 1;
1776174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    }
1776274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
17763a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            }
1776474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(not $ExtraDump)
177654b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            {
17766fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($CurHeaderName)
17767fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
17768fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(not $Include_Neighbors{$Version}{$CurHeaderName}
17769fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    and not $Registered_Headers{$Version}{$CurHeader})
17770fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    { # not a target
17771fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        next;
17772fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
17773fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(not is_target_header($CurHeaderName, 1)
17774fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    and not is_target_header($CurHeaderName, 2))
17775fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    { # user-defined header
17776fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        next;
17777fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
177784b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                }
17779a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            }
177804b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko
177819927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($Line=~/\A\#\s*define\s+(\w+)\s+(.+)\s*\Z/)
17782a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            {
17783a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                my ($Name, $Value) = ($1, $2);
17784a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                if(not $Constants{$Version}{$Name}{"Access"})
17785a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                {
17786a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                    $Constants{$Version}{$Name}{"Access"} = "public";
17787a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                    $Constants{$Version}{$Name}{"Value"} = $Value;
17788fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if($CurHeaderName) {
17789fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $Constants{$Version}{$Name}{"Header"} = $CurHeaderName;
17790fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
17791a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                }
17792a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            }
17793a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            elsif($Line=~/\A\#[ \t]*undef[ \t]+([_A-Z]+)[ \t]*/) {
17794a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                $Constants{$Version}{$1}{"Access"} = "private";
17795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1779774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        else
1779874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        {
1779974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(defined $ExtraDump)
1780074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            {
1780174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if($Line=~/(\w+)\s*\(/)
1780274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                { # functions
1780374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $SymbolHeader{$Version}{$CurClass}{$1} = $CurHeader;
1780474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
1780574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                #elsif($Line=~/(\w+)\s*;/)
1780674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                #{ # data
1780774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                #    $SymbolHeader{$Version}{$CurClass}{$1} = $CurHeader;
1780874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                #}
1780974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                elsif($Line=~/(\A|\s)class\s+(\w+)/) {
1781074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $CurClass = $2;
1781174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
1781274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
1781374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
17814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    close(PREPROC);
17816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Constant (keys(%{$Constants{$Version}}))
17817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1781874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if($Constants{$Version}{$Constant}{"Access"} eq "private")
1781974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        {
1782074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            delete($Constants{$Version}{$Constant});
1782174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            next;
1782274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
17823177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not $ExtraDump and ($Constant=~/_h\Z/i
17824177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        or isBuiltIn($Constants{$Version}{$Constant}{"Header"})))
1782574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        { # skip
1782674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            delete($Constants{$Version}{$Constant});
17827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
17829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            delete($Constants{$Version}{$Constant}{"Access"});
17830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17832a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    if($Debug)
17833a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    {
17834a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        mkpath($DEBUG_PATH{$Version});
17835a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        copy($Path, $DEBUG_PATH{$Version}."/preprocessor.txt");
17836a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    }
17837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
178391693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub uncoverConstant($$)
178401693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{
178411693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my ($LibVersion, $Constant) = @_;
178421693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return "" if(not $LibVersion or not $Constant);
178431693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return $Constant if(isCyclical(\@RecurConstant, $Constant));
178441693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(defined $Cache{"uncoverConstant"}{$LibVersion}{$Constant}) {
178451693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        return $Cache{"uncoverConstant"}{$LibVersion}{$Constant};
178461693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
17847fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
17848fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(defined $Constants{$LibVersion}{$Constant})
178491693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    {
17850fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        my $Value = $Constants{$LibVersion}{$Constant}{"Value"};
17851fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(defined $Constants{$LibVersion}{$Value})
178521693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
178531693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            push(@RecurConstant, $Constant);
178541693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            my $Uncovered = uncoverConstant($LibVersion, $Value);
178551693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if($Uncovered ne "") {
178561693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $Value = $Uncovered;
178571693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
178581693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            pop(@RecurConstant);
178591693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
17860fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
178611693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        # FIXME: uncover $Value using all the enum constants
17862fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        # USE CASE: change of define NC_LONG from NC_INT (enum value) to NC_INT (define)
178631693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        return ($Cache{"uncoverConstant"}{$LibVersion}{$Constant} = $Value);
178641693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
178651693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return ($Cache{"uncoverConstant"}{$LibVersion}{$Constant} = "");
178661693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko}
178671693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
17868fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub simpleConstant($$)
17869fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko{
17870fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my ($LibVersion, $Value) = @_;
17871fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($Value=~/\W/)
17872fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
17873fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        my $Value_Copy = $Value;
17874fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        while($Value_Copy=~s/([a-z_]\w+)/\@/i)
17875fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
17876fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my $Word = $1;
17877fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($Value!~/$Word\s*\(/)
17878fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
17879fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Val = uncoverConstant($LibVersion, $Word);
17880fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Val ne "")
17881fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
17882fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $Value=~s/\b$Word\b/$Val/g;
17883fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
17884fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
17885fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
17886fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
17887fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return $Value;
17888fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko}
17889fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
17890fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub computeValue($)
17891fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko{
17892fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $Value = $_[0];
17893fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
17894fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($Value=~/\A\((-?[\d]+)\)\Z/) {
17895fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return $1;
17896fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
17897fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
17898fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($Value=~/\A[\d\-\+()]+\Z/) {
17899fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return eval($Value);
17900fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
17901fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
17902fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return $Value;
17903fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko}
17904fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
179059927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %IgnoreConstant = map {$_=>1} (
179069927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "VERSION",
179079927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "VERSIONCODE",
179089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "VERNUM",
179099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "VERS_INFO",
179109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "PATCHLEVEL",
179119927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "INSTALLPREFIX",
179129927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "VBUILD",
179139927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "VPATCH",
179149927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "VMINOR",
179159927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "BUILD_STRING",
179169927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "BUILD_TIME",
179179927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "PACKAGE_STRING",
179189927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "PRODUCTION",
179199927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "CONFIGURE_COMMAND",
179209927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "INSTALLDIR",
179219927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "BINDIR",
179229927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "CONFIG_FILE_PATH",
179239927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "DATADIR",
179249927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "EXTENSION_DIR",
179259927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "INCLUDE_PATH",
179269927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "LIBDIR",
179279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "LOCALSTATEDIR",
179289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "SBINDIR",
179299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "SYSCONFDIR",
179309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "RELEASE",
179319927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "SOURCE_ID",
179329927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "SUBMINOR",
179339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "MINOR",
179349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "MINNOR",
179359927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "MINORVERSION",
179369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "MAJOR",
179379927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "MAJORVERSION",
179389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "MICRO",
179399927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "MICROVERSION",
179409927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "BINARY_AGE",
179419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "INTERFACE_AGE",
179429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "CORE_ABI",
179439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "PATCH",
179449927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "COPYRIGHT",
179459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "TIMESTAMP",
179469927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "REVISION",
179479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "PACKAGE_TAG",
179489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "PACKAGEDATE",
179499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "NUMVERSION",
179509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "Release",
179519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "Version"
17952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
17953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
179548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub constantFilter($$$)
179558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko{
179568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my ($Name, $Value, $Level) = @_;
179578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
179588f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($Level eq "Binary")
179598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
17960fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Name=~/_t\Z/)
17961fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # __malloc_ptr_t
17962fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            return 1;
17963fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
179648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        foreach (keys(%IgnoreConstant))
179658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
179668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($Name=~/(\A|_)$_(_|\Z)/)
179678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # version
179688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                return 1;
179698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
179708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(/\A[A-Z].*[a-z]\Z/)
179718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
179728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if($Name=~/(\A|[a-z])$_([A-Z]|\Z)/)
179738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                { # version
179748f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    return 1;
179758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
179768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
179778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
179788f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Name=~/(\A|_)(lib|open|)$TargetLibraryShortName(_|)(VERSION|VER|DATE|API|PREFIX)(_|\Z)/i)
179798f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # version
179808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1;
179818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
179828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Value=~/\A('|"|)[\/\\]\w+([\/\\]|:|('|"|)\Z)/ or $Value=~/[\/\\]\w+[\/\\]\w+/)
179838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # /lib64:/usr/lib64:/lib:/usr/lib:/usr/X11R6/lib/Xaw3d ...
179848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1;
179858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
17986fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
17987fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Value=~/\A["'].*['"]/i)
17988fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # string
17989fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            return 0;
17990fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
17991fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
17992fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Value=~/\A[({]*\s*[a-z_]+\w*(\s+|[\|,])/i)
17993fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # static int gcry_pth_init
17994fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko          # extern ABC
179958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko          # (RE_BACKSLASH_ESCAPE_IN_LISTS | RE...
17996fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko          # { H5FD_MEM_SUPER, H5FD_MEM_SUPER, ...
179978f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1;
179988f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
17999fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Value=~/\w+\s*\(/i)
180008f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # foo(p)
180018f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1;
180028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
18003fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Value=~/\A[a-z_]+\w*\Z/i)
180048f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # asn1_node_st
18005fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko          # __SMTH_P
180068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1;
180078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
180088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
180098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
180108f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return 0;
180118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko}
180128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
180131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub mergeConstants($)
18014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
180151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
18016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Constant (keys(%{$Constants{1}}))
18017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
18018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SkipConstants{1}{$Constant})
18019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # skipped by the user
18020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
18021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
180228f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
18023fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my $Header = $Constants{1}{$Constant}{"Header"})
18024fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
18025fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(not is_target_header($Header, 1)
18026fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            and not is_target_header($Header, 2))
18027fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            { # user-defined header
18028fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                next;
18029fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
18030fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
18031fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        else {
18032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
18033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
180348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
180358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $Old_Value = uncoverConstant(1, $Constant);
180368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
180378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(constantFilter($Constant, $Old_Value, $Level))
180388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # separate binary and source problems
180398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            next;
180408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
180418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
180428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not defined $Constants{2}{$Constant}{"Value"})
180438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # removed
180448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            %{$CompatProblems_Constants{$Level}{$Constant}{"Removed_Constant"}} = (
180458f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                "Target"=>$Constant,
180468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                "Old_Value"=>$Old_Value  );
180478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            next;
180488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
180498f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
180508f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Constants{2}{$Constant}{"Value"} eq "")
180518f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # empty value
180528f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko          # TODO: implement a rule
180538f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            next;
180548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
180558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
180568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $New_Value = uncoverConstant(2, $Constant);
180578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
180588f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $Old_Value_Pure = $Old_Value;
180598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $New_Value_Pure = $New_Value;
180608f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
18061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Old_Value_Pure=~s/(\W)\s+/$1/g;
18062ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Old_Value_Pure=~s/\s+(\W)/$1/g;
18063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $New_Value_Pure=~s/(\W)\s+/$1/g;
18064ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $New_Value_Pure=~s/\s+(\W)/$1/g;
180658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
18066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($New_Value_Pure eq "" or $Old_Value_Pure eq "");
18067fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
18068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($New_Value_Pure ne $Old_Value_Pure)
18069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # different values
18070fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(simpleConstant(1, $Old_Value) eq simpleConstant(2, $New_Value))
18071fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            { # complex values
18072fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                next;
18073fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
18074fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(computeValue($Old_Value) eq computeValue($New_Value))
18075fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            { # expressions
18076fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                next;
18077fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
18078ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(convert_integer($Old_Value) eq convert_integer($New_Value))
18079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # 0x0001 and 0x1, 0x1 and 1 equal constants
18080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
18081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Old_Value eq "0" and $New_Value eq "NULL")
18083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # 0 => NULL
18084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
18085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Old_Value eq "NULL" and $New_Value eq "0")
18087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # NULL => 0
18088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
18089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
180908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            %{$CompatProblems_Constants{$Level}{$Constant}{"Changed_Constant"}} = (
18091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                "Target"=>$Constant,
18092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                "Old_Value"=>$Old_Value,
18093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                "New_Value"=>$New_Value  );
18094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
180968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
180978f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $Constant (keys(%{$Constants{2}}))
180988f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
180998f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not defined $Constants{1}{$Constant}{"Value"})
181008f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
181018f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($SkipConstants{2}{$Constant})
181028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # skipped by the user
181038f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                next;
181048f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
181058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
18106fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(my $Header = $Constants{2}{$Constant}{"Header"})
18107fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
18108fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(not is_target_header($Header, 1)
18109fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and not is_target_header($Header, 2))
18110fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                { # user-defined header
18111fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    next;
18112fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
18113fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
18114fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            else {
181158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                next;
181168f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
181178f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
181188f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $New_Value = uncoverConstant(2, $Constant);
181198f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(not defined $New_Value or $New_Value eq "") {
181208f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                next;
181218f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
181228f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
181238f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(constantFilter($Constant, $New_Value, $Level))
181248f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # separate binary and source problems
181258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                next;
181268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
181278f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
181288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            %{$CompatProblems_Constants{$Level}{$Constant}{"Added_Constant"}} = (
181298f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                "Target"=>$Constant,
181308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                "New_Value"=>$New_Value  );
181318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
181328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
18133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
18135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub convert_integer($)
18136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
18137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Value = $_[0];
18138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Value=~/\A0x[a-f0-9]+\Z/)
181391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # hexadecimal
18140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return hex($Value);
18141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Value=~/\A0[0-7]+\Z/)
181431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # octal
18144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return oct($Value);
18145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Value=~/\A0b[0-1]+\Z/)
181471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # binary
18148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return oct($Value);
18149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
18151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Value;
18152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
181551693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub readSymbols($)
18156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
18157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
1815862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my @LibPaths = getSOPaths($LibVersion);
181591693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($#LibPaths==-1 and not $CheckHeadersOnly)
18160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
18161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LibVersion==1)
18162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
18163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            printMsg("WARNING", "checking headers only");
18164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CheckHeadersOnly = 1;
18165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
18167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "$SLIB_TYPE libraries are not found in ".$Descriptor{$LibVersion}{"Version"});
18168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18170570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
181714b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    foreach my $LibPath (@LibPaths) {
181729927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        readSymbols_Lib($LibVersion, $LibPath, 0, "+Weak", 1, 1);
18173570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18174570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18175570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($CheckUndefined)
18176570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
18177570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my %UndefinedLibs = ();
18178570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
1817974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my @Libs = (keys(%{$Library_Symbol{$LibVersion}}), keys(%{$DepLibrary_Symbol{$LibVersion}}));
1818074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1818174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        foreach my $LibName (sort @Libs)
18182570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
1818374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(defined $UndefinedSymbols{$LibVersion}{$LibName})
18184570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
1818574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                foreach my $Symbol (keys(%{$UndefinedSymbols{$LibVersion}{$LibName}}))
18186570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
18187fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if($Symbol_Library{$LibVersion}{$Symbol}
18188fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    or $DepSymbol_Library{$LibVersion}{$Symbol})
18189fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    { # exported by target library
18190fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        next;
18191fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
18192fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(index($Symbol, '@')!=-1)
18193fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    { # exported default symbol version (@@)
18194fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $Symbol=~s/\@/\@\@/;
18195fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if($Symbol_Library{$LibVersion}{$Symbol}
18196fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        or $DepSymbol_Library{$LibVersion}{$Symbol}) {
18197fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            next;
1819874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        }
18199570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
18200fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    foreach my $Path (find_SymbolLibs($LibVersion, $Symbol)) {
18201fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $UndefinedLibs{$Path} = 1;
18202fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
18203570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
18204570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
18205570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18206570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if($ExtraInfo)
18207570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        { # extra information for other tools
18208fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(my @Paths = sort keys(%UndefinedLibs))
18209570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
18210570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                my $LibString = "";
18211fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my %Dirs = ();
18212570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                foreach (@Paths)
18213570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
1821474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $KnownLibs{$_} = 1;
18215570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    my ($Dir, $Name) = separate_path($_);
18216570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18217570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if(not grep {$Dir eq $_} (@{$SystemPaths{"lib"}})) {
18218fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $Dirs{esc($Dir)} = 1;
18219570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
18220570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18221570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $Name = parse_libname($Name, "name", $OStarget);
18222570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $Name=~s/\Alib//;
18223570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
1822474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $LibString .= " -l$Name";
18225570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
18226fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
18227fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                foreach my $Dir (sort {$b cmp $a} keys(%Dirs))
18228fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
18229fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $LibString = " -L".esc($Dir).$LibString;
18230fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
18231fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
18232570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                writeFile($ExtraInfo."/libs-string", $LibString);
18233570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
18234570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
182351693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
18236570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
1823774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraInfo) {
1823874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        writeFile($ExtraInfo."/lib-paths", join("\n", sort keys(%KnownLibs)));
1823974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
1824074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
182411693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not $CheckHeadersOnly)
182421693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    {
182431693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($#LibPaths!=-1)
182441693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
182451693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if(not keys(%{$Symbol_Library{$LibVersion}}))
182461693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            {
182470d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                printMsg("WARNING", "the set of public symbols in library(ies) is empty ($LibVersion)");
182481693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                printMsg("WARNING", "checking headers only");
182491693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $CheckHeadersOnly = 1;
182501693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
182511693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
18252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18253850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
1825407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko   # clean memory
18255850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko   %SystemObjects = ();
18256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
18258570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %Prefix_Lib_Map=(
18259570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko # symbols for autodetecting library dependencies (by prefix)
18260570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "pthread_" => ["libpthread"],
18261570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "g_" => ["libglib-2.0", "libgobject-2.0", "libgio-2.0"],
18262570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "cairo_" => ["libcairo"],
18263570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "gtk_" => ["libgtk-x11-2.0"],
18264570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "atk_" => ["libatk-1.0"],
18265570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "gdk_" => ["libgdk-x11-2.0"],
18266570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "gl" => ["libGL"],
18267570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "glu" => ["libGLU"],
18268570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "popt" => ["libpopt"],
18269570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "Py" => ["libpython"],
18270570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "jpeg_" => ["libjpeg"],
18271570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "BZ2_" => ["libbz2"],
18272570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "Fc" => ["libfontconfig"],
18273570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "Xft" => ["libXft"],
18274570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "SSL_" => ["libssl"],
18275570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "sem_" => ["libpthread"],
18276570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "snd_" => ["libasound"],
18277570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "art_" => ["libart_lgpl_2"],
18278570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "dbus_g" => ["libdbus-glib-1"],
18279570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "GOMP_" => ["libgomp"],
18280570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "omp_" => ["libgomp"],
18281570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "cms" => ["liblcms"]
18282570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko);
18283570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18284570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %Pattern_Lib_Map=(
18285570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "SL[a-z]" => ["libslang"]
18286570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko);
18287570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18288570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %Symbol_Lib_Map=(
18289570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko # symbols for autodetecting library dependencies (by name)
18290570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "pow" => "libm",
18291570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "fmod" => "libm",
18292570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "sin" => "libm",
18293570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "floor" => "libm",
18294570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "cos" => "libm",
18295570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "dlopen" => "libdl",
18296570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "deflate" => "libz",
18297570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "inflate" => "libz",
18298570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "move_panel" => "libpanel",
18299570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "XOpenDisplay" => "libX11",
18300570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "resize_term" => "libncurses",
183018f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    "clock_gettime" => "librt",
183028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    "crypt" => "libcrypt"
18303570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko);
18304570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18305570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub find_SymbolLibs($$)
18306570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko{
18307570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my ($LibVersion, $Symbol) = @_;
18308570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18309570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(index($Symbol, "g_")==0 and $Symbol=~/[A-Z]/)
18310570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # debug symbols
18311570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return ();
18312570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18313570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18314570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my %Paths = ();
18315570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18316570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(my $LibName = $Symbol_Lib_Map{$Symbol})
18317570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
18318570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(my $Path = get_LibPath($LibVersion, $LibName.".".$LIB_EXT)) {
18319570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            $Paths{$Path} = 1;
18320570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18321570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18322570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18323570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(my $SymbolPrefix = getPrefix($Symbol))
18324570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
18325570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(defined $Cache{"find_SymbolLibs"}{$SymbolPrefix}) {
18326570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            return @{$Cache{"find_SymbolLibs"}{$SymbolPrefix}};
18327570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18328570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18329570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(not keys(%Paths))
18330570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
18331570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(defined $Prefix_Lib_Map{$SymbolPrefix})
18332570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
18333570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                foreach my $LibName (@{$Prefix_Lib_Map{$SymbolPrefix}})
18334570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
18335570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if(my $Path = get_LibPath($LibVersion, $LibName.".".$LIB_EXT)) {
18336570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        $Paths{$Path} = 1;
18337570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
18338570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
18339570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
18340570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18341570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18342570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(not keys(%Paths))
18343570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
18344570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            foreach my $Prefix (sort keys(%Pattern_Lib_Map))
18345570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
18346570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if($Symbol=~/\A$Prefix/)
18347570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
18348570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    foreach my $LibName (@{$Pattern_Lib_Map{$Prefix}})
18349570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    {
18350570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        if(my $Path = get_LibPath($LibVersion, $LibName.".".$LIB_EXT)) {
18351570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                            $Paths{$Path} = 1;
18352570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        }
18353570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
18354570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
18355570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
18356570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18357570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18358570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(not keys(%Paths))
18359570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
18360570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if($SymbolPrefix)
18361570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            { # try to find a library by symbol prefix
18362570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if($SymbolPrefix eq "inotify" and
18363570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                index($Symbol, "\@GLIBC")!=-1)
18364570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
18365570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if(my $Path = get_LibPath($LibVersion, "libc.$LIB_EXT")) {
18366570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        $Paths{$Path} = 1;
18367570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
18368570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
18369570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                else
18370570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
18371570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if(my $Path = get_LibPath_Prefix($LibVersion, $SymbolPrefix)) {
18372570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        $Paths{$Path} = 1;
18373570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
18374570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
18375570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
18376570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18377570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18378570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(my @Paths = keys(%Paths)) {
18379570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            $Cache{"find_SymbolLibs"}{$SymbolPrefix} = \@Paths;
18380570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18381570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18382570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    return keys(%Paths);
18383570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko}
18384570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18385570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub get_LibPath_Prefix($$)
18386570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko{
18387570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my ($LibVersion, $Prefix) = @_;
18388570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18389570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $Prefix = lc($Prefix);
18390570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $Prefix=~s/[_]+\Z//g;
18391570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18392570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach ("-2", "2", "-1", "1", "")
18393570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # libgnome-2.so
18394570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      # libxml2.so
18395570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      # libdbus-1.so
18396570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(my $Path = get_LibPath($LibVersion, "lib".$Prefix.$_.".".$LIB_EXT)) {
18397570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            return $Path;
18398570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18399570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18400570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    return "";
18401570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko}
18402570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18403570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub getPrefix($)
18404570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko{
18405570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my $Str = $_[0];
18406570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($Str=~/\A([_]*[A-Z][a-z]{1,5})[A-Z]/)
18407570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # XmuValidArea: Xmu
18408570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return $1;
18409570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18410570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    elsif($Str=~/\A([_]*[a-z]+)[A-Z]/)
18411570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # snfReadFont: snf
18412570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return $1;
18413570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18414570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    elsif($Str=~/\A([_]*[A-Z]{2,})[A-Z][a-z]+([A-Z][a-z]+|\Z)/)
18415570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # XRRTimes: XRR
18416570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return $1;
18417570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18418570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    elsif($Str=~/\A([_]*[a-z]{1,2}\d+)[a-z\d]*_[a-z]+/i)
18419570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # H5HF_delete: H5
18420570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return $1;
18421570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18422570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    elsif($Str=~/\A([_]*[a-z0-9]{2,}_)[a-z]+/i)
18423570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # alarm_event_add: alarm_
18424570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return $1;
18425570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18426570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    elsif($Str=~/\A(([a-z])\2{1,})/i)
18427570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # ffopen
18428570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return $1;
18429570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18430570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    return "";
18431570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko}
18432570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
184331693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub getSymbolSize($$)
184341693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{ # size from the shared library
184351693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
184361693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return 0 if(not $Symbol);
184371693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(defined $Symbol_Library{$LibVersion}{$Symbol}
184381693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    and my $LibName = $Symbol_Library{$LibVersion}{$Symbol})
184391693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    {
184401693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(defined $Library_Symbol{$LibVersion}{$LibName}{$Symbol}
184411693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        and my $Size = $Library_Symbol{$LibVersion}{$LibName}{$Symbol})
184421693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
184431693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if($Size<0) {
184441693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                return -$Size;
18445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
184481693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return 0;
18449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1845107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenkosub canonifyName($$)
18452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # make TIFFStreamOpen(char const*, std::basic_ostream<char, std::char_traits<char> >*)
18453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # to be TIFFStreamOpen(char const*, std::basic_ostream<char>*)
1845407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    my ($Name, $Type) = @_;
1845507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
1845607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    # single
1845707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    while($Name=~/([^<>,]+),\s*$DEFAULT_STD_PARMS<([^<>,]+)>\s*/ and $1 eq $3)
18458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
18459850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $P = $1;
1846007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        $Name=~s/\Q$P\E,\s*$DEFAULT_STD_PARMS<\Q$P\E>\s*/$P/g;
18461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1846207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
1846307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    # double
1846407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if($Name=~/$DEFAULT_STD_PARMS/)
1846507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    {
18466e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko        if($Type eq "S")
1846707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        {
1846807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            my ($ShortName, $FuncParams) = split_Signature($Name);
1846907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
1847007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            foreach my $FParam (separate_Params($FuncParams, 0, 0))
1847107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            {
1847207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                if(index($FParam, "<")!=-1)
1847307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                {
1847407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                    $FParam=~s/>([^<>]+)\Z/>/; # remove quals
1847507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                    my $FParam_N = canonifyName($FParam, "T");
1847607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                    if($FParam_N ne $FParam) {
1847707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                        $Name=~s/\Q$FParam\E/$FParam_N/g;
1847807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                    }
1847907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                }
1848007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            }
1848107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        }
1848207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        elsif($Type eq "T")
1848307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        {
1848407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            my ($ShortTmpl, $TmplParams) = template_Base($Name);
1848507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
1848607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            my @TParams = separate_Params($TmplParams, 0, 0);
18487e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko            if($#TParams>=1)
1848807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            {
18489e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko                my $FParam = $TParams[0];
18490e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko                foreach my $Pos (1 .. $#TParams)
18491e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko                {
18492e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko                    my $TParam = $TParams[$Pos];
18493e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko                    if($TParam=~/\A$DEFAULT_STD_PARMS<\Q$FParam\E\s*>\Z/) {
18494e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko                        $Name=~s/\Q$FParam, $TParam\E\s*/$FParam/g;
18495e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko                    }
1849607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                }
1849707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            }
1849807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        }
1849907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    }
18500e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    if($Type eq "S") {
18501e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko        return formatName($Name, "S");
18502e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    }
18503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Name;
18504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
18506dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenkosub translateSymbols(@)
18507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
18508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = pop(@_);
1850962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my (@MnglNames1, @MnglNames2, @UnmangledNames) = ();
185109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    foreach my $Symbol (sort @_)
18511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
185129927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(index($Symbol, "_Z")==0)
18513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
185149927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            next if($tr_name{$Symbol});
185159927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $Symbol=~s/[\@\$]+(.*)\Z//;
185169927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            push(@MnglNames1, $Symbol);
18517ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18518570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        elsif(index($Symbol, "?")==0)
18519570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
18520570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            next if($tr_name{$Symbol});
185219927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            push(@MnglNames2, $Symbol);
18522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
18524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # not mangled
185259927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $tr_name{$Symbol} = $Symbol;
185269927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $mangled_name_gcc{$Symbol} = $Symbol;
185279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $mangled_name{$LibVersion}{$Symbol} = $Symbol;
18528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($#MnglNames1 > -1)
18531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # GCC names
1853262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        @UnmangledNames = reverse(unmangleArray(@MnglNames1));
18533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $MnglName (@MnglNames1)
18534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1853562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $Unmangled = pop(@UnmangledNames))
1853662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
1853772930b9bbe1284ca8eee0f5a2728d5bf094400e5Andrey Ponomarenko                $tr_name{$MnglName} = canonifyName($Unmangled, "S");
1853862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(not $mangled_name_gcc{$tr_name{$MnglName}}) {
1853962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $mangled_name_gcc{$tr_name{$MnglName}} = $MnglName;
1854062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
185419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if(index($MnglName, "_ZTV")==0
1854262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                and $tr_name{$MnglName}=~/vtable for (.+)/)
1854362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                { # bind class name and v-table symbol
1854462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $ClassName = $1;
1854562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $ClassVTable{$ClassName} = $MnglName;
1854662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $VTableClass{$MnglName} = $ClassName;
1854762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
18548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($#MnglNames2 > -1)
18552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # MSVC names
1855362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        @UnmangledNames = reverse(unmangleArray(@MnglNames2));
18554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $MnglName (@MnglNames2)
18555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1855662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $Unmangled = pop(@UnmangledNames))
1855762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
185589927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                $tr_name{$MnglName} = formatName($Unmangled, "S");
1855962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $mangled_name{$LibVersion}{$tr_name{$MnglName}} = $MnglName;
1856062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
18561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return \%tr_name;
18564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
18566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub link_symbol($$$)
18567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
18568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Symbol, $RunWith, $Deps) = @_;
18569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(link_symbol_internal($Symbol, $RunWith, \%Symbol_Library)) {
18570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
18571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Deps eq "+Deps")
18573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # check the dependencies
1857462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(link_symbol_internal($Symbol, $RunWith, \%DepSymbol_Library)) {
18575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
18576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18578ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
18579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
18581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub link_symbol_internal($$$)
18582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
18583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Symbol, $RunWith, $Where) = @_;
18584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not $Where or not $Symbol);
18585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Where->{$RunWith}{$Symbol})
18586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # the exact match by symbol name
18587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
18588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $VSym = $SymVer{$RunWith}{$Symbol})
18590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # indirect symbol version, i.e.
18591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # foo_old and its symlink foo@v (or foo@@v)
185929927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko      # foo_old may be in symtab table
18593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Where->{$RunWith}{$VSym}) {
18594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
18595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
185971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Sym, $Spec, $Ver) = separate_symbol($Symbol);
18598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Sym and $Ver)
18599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search for the symbol with the same version
18600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # or without version
18601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Where->{$RunWith}{$Sym})
18602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # old: foo@v|foo@@v
18603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # new: foo
18604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
18605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Where->{$RunWith}{$Sym."\@".$Ver})
18607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # old: foo|foo@@v
18608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # new: foo@v
18609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
18610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Where->{$RunWith}{$Sym."\@\@".$Ver})
18612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # old: foo|foo@v
18613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # new: foo@@v
18614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
18615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
18618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
186201693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub readSymbols_App($)
18621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
18622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
186239927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return () if(not $Path);
18624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Imported = ();
18625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup eq "macos")
18626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1862707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        my $NM = get_CmdPath("nm");
1862807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        if(not $NM) {
1862907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            exitStatus("Not_Found", "can't find \"nm\"");
18630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1863107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        open(APP, "$NM -g \"$Path\" 2>\"$TMP_DIR/null\" |");
186329927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        while(<APP>)
186339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
1863407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            if(/ U _([\w\$]+)\s*\Z/) {
18635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@Imported, $1);
18636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        close(APP);
18639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($OSgroup eq "windows")
18641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
18642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $DumpBinCmd = get_CmdPath("dumpbin");
18643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $DumpBinCmd) {
18644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"dumpbin.exe\"");
18645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18646a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        open(APP, "$DumpBinCmd /IMPORTS \"$Path\" 2>\"$TMP_DIR/null\" |");
186479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        while(<APP>)
186489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
18649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(/\s*\w+\s+\w+\s+\w+\s+([\w\?\@]+)\s*/) {
18650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@Imported, $1);
18651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        close(APP);
18654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
18656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
18657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $ReadelfCmd = get_CmdPath("readelf");
18658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $ReadelfCmd) {
18659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"readelf\"");
18660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18661a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        open(APP, "$ReadelfCmd -WhlSsdA \"$Path\" 2>\"$TMP_DIR/null\" |");
186629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        my $symtab = undef; # indicates that we are processing 'symtab' section of 'readelf' output
18663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while(<APP>)
18664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
186659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(defined $symtab)
186669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # do nothing with symtab
186679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if(index($_, "'.dynsym'")!=-1)
186689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                { # dynamic table
186699927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $symtab = undef;
186709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
18671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
186729927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            elsif(index($_, "'.symtab'")!=-1)
186739927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # symbol table
186749927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                $symtab = 1;
18675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
186769927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            elsif(my @Info = readline_ELF($_))
18677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
186789927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                my ($Ndx, $Symbol) = ($Info[5], $Info[6]);
186799927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if($Ndx eq "UND")
186809927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                { # only imported symbols
186819927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    push(@Imported, $Symbol);
18682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
18683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        close(APP);
18686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @Imported;
18688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
186909927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %ELF_BIND = map {$_=>1} (
186919927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "WEAK",
186929927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "GLOBAL"
186939927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko);
186949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
186959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %ELF_TYPE = map {$_=>1} (
186969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "FUNC",
186979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "IFUNC",
186989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "OBJECT",
186999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "COMMON"
187009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko);
187019927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
187029927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %ELF_VIS = map {$_=>1} (
187039927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "DEFAULT",
187049927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "PROTECTED"
187059927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko);
187069927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
18707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub readline_ELF($)
187089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{ # read the line of 'readelf' output corresponding to the symbol
187099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my @Info = split(/\s+/, $_[0]);
187109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    #  Num:   Value      Size Type   Bind   Vis       Ndx  Name
187119927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    #  3629:  000b09c0   32   FUNC   GLOBAL DEFAULT   13   _ZNSt12__basic_fileIcED1Ev@@GLIBCXX_3.4
18712fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    #  135:   00000000    0   FUNC   GLOBAL DEFAULT   UND  av_image_fill_pointers@LIBAVUTIL_52 (3)
187139927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    shift(@Info); # spaces
187149927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    shift(@Info); # num
18715fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
18716fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($#Info==7)
18717fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # UND SYMBOL (N)
18718fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Info[7]=~/\(\d+\)/) {
18719fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            pop(@Info);
18720fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
18721fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
18722fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
187239927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($#Info!=6)
187249927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # other lines
187259927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return ();
187269927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
1872774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return () if(not defined $ELF_TYPE{$Info[2]} and $Info[5] ne "UND");
187289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return () if(not defined $ELF_BIND{$Info[3]});
187299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return () if(not defined $ELF_VIS{$Info[4]});
187309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($Info[5] eq "ABS" and $Info[0]=~/\A0+\Z/)
187319927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # 1272: 00000000     0 OBJECT  GLOBAL DEFAULT  ABS CXXABI_1.3
187329927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return ();
187339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
187349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($OStarget eq "symbian")
187359927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # _ZN12CCTTokenType4NewLE4TUid3RFs@@ctfinder{000a0000}[102020e5].dll
187369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(index($Info[6], "_._.absent_export_")!=-1)
187379927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # "_._.absent_export_111"@@libstdcpp{00010001}[10282872].dll
18738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return ();
18739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
187409927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $Info[6]=~s/\@.+//g; # remove version
18741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
187429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(index($Info[2], "0x") == 0)
187439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # size == 0x3d158
187449927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $Info[2] = hex($Info[2]);
187459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
187469927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return @Info;
18747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
187499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub get_LibPath($$)
187501693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{
187519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my ($LibVersion, $Name) = @_;
187529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return "" if(not $LibVersion or not $Name);
187539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(defined $Cache{"get_LibPath"}{$LibVersion}{$Name}) {
187549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $Cache{"get_LibPath"}{$LibVersion}{$Name};
187551693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
187569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return ($Cache{"get_LibPath"}{$LibVersion}{$Name} = get_LibPath_I($LibVersion, $Name));
187579927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko}
187589927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
187599927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub get_LibPath_I($$)
187609927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{
187619927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my ($LibVersion, $Name) = @_;
187629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(is_abs($Name))
187631693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    {
187649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(-f $Name)
187659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # absolute path
187669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            return $Name;
187671693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
187689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        else
187699927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # broken
187709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            return "";
187719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
187729927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
1877307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if(defined $RegisteredObjects{$LibVersion}{$Name})
187749927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # registered paths
1877507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        return $RegisteredObjects{$LibVersion}{$Name};
187769927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
1877707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if(defined $RegisteredSONAMEs{$LibVersion}{$Name})
187789927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # registered paths
1877907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        return $RegisteredSONAMEs{$LibVersion}{$Name};
187809927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
187819927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(my $DefaultPath = $DyLib_DefaultPath{$Name})
187829927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # ldconfig default paths
187839927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $DefaultPath;
187849927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
18785570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Dir (@DefaultLibPaths, @{$SystemPaths{"lib"}})
187869927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # search in default linker directories
187879927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko      # and then in all system paths
187889927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(-f $Dir."/".$Name) {
1878974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            return join_P($Dir,$Name);
187901693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
187919927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
18792e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    if(not defined $Cache{"checkSystemFiles"}) {
18793e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        checkSystemFiles();
18794e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    }
187959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(my @AllObjects = keys(%{$SystemObjects{$Name}})) {
187969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $AllObjects[0];
187979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
187989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(my $ShortName = parse_libname($Name, "name+ext", $OStarget))
187999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
188009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($ShortName ne $Name)
188011693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # FIXME: check this case
188029927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(my $Path = get_LibPath($LibVersion, $ShortName)) {
188039927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                return $Path;
188049927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
188051693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
188061693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
188079927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    # can't find
188089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return "";
188091693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko}
188101693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
188119927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub readSymbols_Lib($$$$$$)
18812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
188139927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my ($LibVersion, $Lib_Path, $IsNeededLib, $Weak, $Deps, $Vers) = @_;
188149927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return () if(not $LibVersion or not $Lib_Path);
1881574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1881674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $Real_Path = realpath($Lib_Path);
1881774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1881874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(not $Real_Path)
1881974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    { # broken link
1882074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        return ();
1882174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
1882274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1882374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $Lib_Name = get_filename($Real_Path);
1882474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
18825fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($ExtraInfo)
18826fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
1882774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $KnownLibs{$Real_Path} = 1;
18828fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $KnownLibs{$Lib_Path} = 1; # links
1882974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
1883074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
188319927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($IsNeededLib)
188329927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
188339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($CheckedDyLib{$LibVersion}{$Lib_Name}) {
188349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            return ();
188359927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
188369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
188379927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return () if(isCyclical(\@RecurLib, $Lib_Name) or $#RecurLib>=1);
18838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $CheckedDyLib{$LibVersion}{$Lib_Name} = 1;
1883962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
188409927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($CheckImpl)
188419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
188429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(not $IsNeededLib) {
188439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            getImplementations($LibVersion, $Lib_Path);
188449927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
188451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
1884662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
18847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    push(@RecurLib, $Lib_Name);
18848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my (%Value_Interface, %Interface_Value, %NeededLib) = ();
1884957a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko    my $Lib_ShortName = parse_libname($Lib_Name, "name+ext", $OStarget);
1885057a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko
1885157a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko    if(not $IsNeededLib)
1885257a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko    { # special cases: libstdc++ and libc
1885357a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko        if(my $ShortName = parse_libname($Lib_Name, "short", $OStarget))
1885457a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko        {
1885557a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko            if($ShortName eq "libstdc++")
1885657a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko            { # libstdc++.so.6
1885757a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko                $STDCXX_TESTING = 1;
1885857a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko            }
1885957a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko            elsif($ShortName eq "libc")
1886057a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko            { # libc-2.11.3.so
1886157a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko                $GLIBC_TESTING = 1;
1886257a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko            }
18863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18865dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my $DebugPath = "";
18866a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    if($Debug and not $DumpSystem)
188671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # debug mode
18868dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        $DebugPath = $DEBUG_PATH{$LibVersion}."/libs/".get_filename($Lib_Path).".txt";
188691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        mkpath(get_dirname($DebugPath));
188701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
18871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OStarget eq "macos")
18872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # Mac OS X: *.dylib, *.a
1887307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        my $NM = get_CmdPath("nm");
188744b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        if(not $NM) {
188754b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"nm\"");
18876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1887707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        $NM .= " -g \"$Lib_Path\" 2>\"$TMP_DIR/null\"";
18878a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if($DebugPath)
188791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # debug mode
188801693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko          # write to file
1888107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            system($NM." >\"$DebugPath\"");
188821693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            open(LIB, $DebugPath);
188831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
188841693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        else
188851693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # write to pipe
1888607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            open(LIB, $NM." |");
188871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
18888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while(<LIB>)
18889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
18890570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if($CheckUndefined)
18891570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
18892570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if(not $IsNeededLib)
18893570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
18894570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if(/ U _([\w\$]+)\s*\Z/)
18895570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    {
1889674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        $UndefinedSymbols{$LibVersion}{$Lib_Name}{$1} = 0;
18897570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        next;
18898570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
18899570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
18900570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
18901570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
1890207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            if(/ [STD] _([\w\$]+)\s*\Z/)
18903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
18904570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                my $Symbol = $1;
1890562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($IsNeededLib)
1890662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
1890757a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko                    if(not defined $RegisteredObjects_Short{$LibVersion}{$Lib_ShortName})
1890862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    {
18909570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        $DepSymbol_Library{$LibVersion}{$Symbol} = $Lib_Name;
18910570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        $DepLibrary_Symbol{$LibVersion}{$Lib_Name}{$Symbol} = 1;
1891162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
18912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1891362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                else
18914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
18915570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $Symbol_Library{$LibVersion}{$Symbol} = $Lib_Name;
18916570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $Library_Symbol{$LibVersion}{$Lib_Name}{$Symbol} = 1;
189179927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if($COMMON_LANGUAGE{$LibVersion} ne "C++")
189189927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    {
18919570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        if(index($Symbol, "_Z")==0 or index($Symbol, "?")==0) {
189209927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            setLanguage($LibVersion, "C++");
189219927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
18922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
18923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($CheckObjectsOnly
18924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    and $LibVersion==1) {
18925570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        $CheckedSymbols{"Binary"}{$Symbol} = 1;
18926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
18927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
18928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        close(LIB);
1893107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
189329927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($Deps)
189339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
189349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($LIB_TYPE eq "dynamic")
189359927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # dependencies
1893607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
1893707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                my $OtoolCmd = get_CmdPath("otool");
189384b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                if(not $OtoolCmd) {
189394b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                    exitStatus("Not_Found", "can't find \"otool\"");
1894007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                }
1894107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
189429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                open(LIB, "$OtoolCmd -L \"$Lib_Path\" 2>\"$TMP_DIR/null\" |");
189439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                while(<LIB>)
189449927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                {
189459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if(/\s*([\/\\].+\.$LIB_EXT)\s*/
189469927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    and $1 ne $Lib_Path) {
189479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        $NeededLib{$1} = 1;
189489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    }
18949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
189509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                close(LIB);
18951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($OStarget eq "windows")
18955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # Windows *.dll, *.lib
18956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $DumpBinCmd = get_CmdPath("dumpbin");
18957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $DumpBinCmd) {
18958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"dumpbin\"");
18959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
189601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $DumpBinCmd .= " /EXPORTS \"".$Lib_Path."\" 2>$TMP_DIR/null";
18961a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if($DebugPath)
189621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # debug mode
189631693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko          # write to file
18964a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            system($DumpBinCmd." >\"$DebugPath\"");
189651693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            open(LIB, $DebugPath);
189661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
189671693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        else
189681693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # write to pipe
189691693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            open(LIB, $DumpBinCmd." |");
189701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
18971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while(<LIB>)
18972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # 1197 4AC 0000A620 SetThreadStackGuarantee
18973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # 1198 4AD          SetThreadToken (forwarded to ...)
18974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # 3368 _o2i_ECPublicKey
18975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(/\A\s*\d+\s+[a-f\d]+\s+[a-f\d]+\s+([\w\?\@]+)\s*\Z/i
18976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            or /\A\s*\d+\s+[a-f\d]+\s+([\w\?\@]+)\s*\(\s*forwarded\s+/
18977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            or /\A\s*\d+\s+_([\w\?\@]+)\s*\Z/)
18978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # dynamic, static and forwarded symbols
18979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $realname = $1;
1898062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($IsNeededLib)
1898162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
1898257a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko                    if(not defined $RegisteredObjects_Short{$LibVersion}{$Lib_ShortName})
1898362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    {
1898462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $DepSymbol_Library{$LibVersion}{$realname} = $Lib_Name;
1898562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $DepLibrary_Symbol{$LibVersion}{$Lib_Name}{$realname} = 1;
1898662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
18987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1898862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                else
18989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
18990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Symbol_Library{$LibVersion}{$realname} = $Lib_Name;
18991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Library_Symbol{$LibVersion}{$Lib_Name}{$realname} = 1;
189929927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if($COMMON_LANGUAGE{$LibVersion} ne "C++")
189939927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    {
189949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        if(index($realname, "_Z")==0 or index($realname, "?")==0) {
189959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            setLanguage($LibVersion, "C++");
189969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
18997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
18998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($CheckObjectsOnly
18999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    and $LibVersion==1) {
190001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $CheckedSymbols{"Binary"}{$realname} = 1;
19001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
19002ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
19003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
19004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        close(LIB);
190069927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($Deps)
190079927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
190089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($LIB_TYPE eq "dynamic")
190099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # dependencies
190109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                open(LIB, "$DumpBinCmd /DEPENDENTS \"$Lib_Path\" 2>\"$TMP_DIR/null\" |");
190119927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                while(<LIB>)
190129927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                {
190139927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if(/\s*([^\s]+?\.$LIB_EXT)\s*/i
190149927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    and $1 ne $Lib_Path) {
190159927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        $NeededLib{path_format($1, $OSgroup)} = 1;
190169927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    }
19017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
190189927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                close(LIB);
19019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
19020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
19023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # Unix; *.so, *.a
19024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # Symbian: *.dso, *.lib
19025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $ReadelfCmd = get_CmdPath("readelf");
19026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $ReadelfCmd) {
19027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"readelf\"");
19028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19029a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        $ReadelfCmd .= " -WhlSsdA \"$Lib_Path\" 2>\"$TMP_DIR/null\"";
19030a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if($DebugPath)
190311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # debug mode
190321693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko          # write to file
19033a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            system($ReadelfCmd." >\"$DebugPath\"");
190341693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            open(LIB, $DebugPath);
190351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
190361693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        else
190371693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # write to pipe
190381693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            open(LIB, $ReadelfCmd." |");
190391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
190409927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        my $symtab = undef; # indicates that we are processing 'symtab' section of 'readelf' output
19041ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while(<LIB>)
19042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
19043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($LIB_TYPE eq "dynamic")
19044ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # dynamic library specifics
190459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if(defined $symtab)
1904662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
190479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if(index($_, "'.dynsym'")!=-1)
1904862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    { # dynamic table
190499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        $symtab = undef;
1905062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
190519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    # do nothing with symtab
190529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    next;
19053ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
190549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                elsif(index($_, "'.symtab'")!=-1)
19055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # symbol table
190569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $symtab = 1;
19057ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
19058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
19059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
190609927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(my ($Value, $Size, $Type, $Bind, $Vis, $Ndx, $Symbol) = readline_ELF($_))
19061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # read ELF entry
190629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if($Ndx eq "UND")
19063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # ignore interfaces that are imported from somewhere else
19064570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if($CheckUndefined)
19065570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    {
19066570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        if(not $IsNeededLib) {
1906774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                            $UndefinedSymbols{$LibVersion}{$Lib_Name}{$Symbol} = 0;
19068570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        }
19069570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
19070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
19071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
19072c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko                if($Bind eq "WEAK")
19073c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko                {
1907407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                    $WeakSymbols{$LibVersion}{$Symbol} = 1;
19075c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko                    if($Weak eq "-Weak")
19076c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko                    { # skip WEAK symbols
19077c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko                        next;
19078c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko                    }
19079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
190809927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                my $Short = $Symbol;
190819927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                $Short=~s/\@.+//g;
190829927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if($Type eq "OBJECT")
19083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # global data
19084fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $GlobalDataObject{$LibVersion}{$Symbol} = $Size;
19085fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $GlobalDataObject{$LibVersion}{$Short} = $Size;
19086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1908762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($IsNeededLib)
1908862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
1908957a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko                    if(not defined $RegisteredObjects_Short{$LibVersion}{$Lib_ShortName})
1909062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    {
190919927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        $DepSymbol_Library{$LibVersion}{$Symbol} = $Lib_Name;
190929927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        $DepLibrary_Symbol{$LibVersion}{$Lib_Name}{$Symbol} = ($Type eq "OBJECT")?-$Size:1;
1909362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
19094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1909562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                else
19096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
190979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $Symbol_Library{$LibVersion}{$Symbol} = $Lib_Name;
190989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $Library_Symbol{$LibVersion}{$Lib_Name}{$Symbol} = ($Type eq "OBJECT")?-$Size:1;
190999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if($Vers)
191009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    {
191019927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        if($LIB_EXT eq "so")
191029927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        { # value
191039927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            $Interface_Value{$LibVersion}{$Symbol} = $Value;
191049927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            $Value_Interface{$LibVersion}{$Value}{$Symbol} = 1;
191059927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
19106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
191079927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if($COMMON_LANGUAGE{$LibVersion} ne "C++")
191089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    {
191099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        if(index($Symbol, "_Z")==0 or index($Symbol, "?")==0) {
191109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            setLanguage($LibVersion, "C++");
191119927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
19112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
19113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($CheckObjectsOnly
19114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    and $LibVersion==1) {
191159927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        $CheckedSymbols{"Binary"}{$Symbol} = 1;
19116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
19117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
19118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1911962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            elsif($LIB_TYPE eq "dynamic")
1912062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            { # dynamic library specifics
191219927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if($Deps)
191229927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                {
191239927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if(/NEEDED.+\[([^\[\]]+)\]/)
191249927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    { # dependencies:
191259927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                      # 0x00000001 (NEEDED) Shared library: [libc.so.6]
191269927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        $NeededLib{$1} = 1;
191279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    }
1912862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
1912962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
19130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        close(LIB);
19132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
191339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($Vers)
191349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
191359927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(not $IsNeededLib and $LIB_EXT eq "so")
191369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # get symbol versions
19137fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my %Found = ();
19138fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
19139fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            # by value
1914074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            foreach my $Symbol (keys(%{$Library_Symbol{$LibVersion}{$Lib_Name}}))
19141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
191429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                next if(index($Symbol,"\@")==-1);
191439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if(my $Value = $Interface_Value{$LibVersion}{$Symbol})
19144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
191459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    foreach my $Symbol_SameValue (keys(%{$Value_Interface{$LibVersion}{$Value}}))
19146a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                    {
191479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        if($Symbol_SameValue ne $Symbol
191489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        and index($Symbol_SameValue,"\@")==-1)
191499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        {
191509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            $SymVer{$LibVersion}{$Symbol_SameValue} = $Symbol;
19151fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $Found{$Symbol} = 1;
191529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            last;
191539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
19154a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                    }
19155fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
19156fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
19157fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
19158fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            # default
19159fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            foreach my $Symbol (keys(%{$Library_Symbol{$LibVersion}{$Lib_Name}}))
19160fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
19161fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                next if(defined $Found{$Symbol});
19162fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                next if(index($Symbol,"\@\@")==-1);
19163fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
19164fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Symbol=~/\A([^\@]*)\@\@/
19165fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and not $SymVer{$LibVersion}{$1})
19166fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
19167fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $SymVer{$LibVersion}{$1} = $Symbol;
19168fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $Found{$Symbol} = 1;
19169fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
19170fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
19171fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
19172fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            # non-default
19173fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            foreach my $Symbol (keys(%{$Library_Symbol{$LibVersion}{$Lib_Name}}))
19174fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
19175fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                next if(defined $Found{$Symbol});
19176fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                next if(index($Symbol,"\@")==-1);
19177fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
19178fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Symbol=~/\A([^\@]*)\@([^\@]*)/
19179fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and not $SymVer{$LibVersion}{$1})
19180fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
19181fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $SymVer{$LibVersion}{$1} = $Symbol;
19182fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $Found{$Symbol} = 1;
19183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
19184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
19185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
191879927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($Deps)
19188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
191899927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        foreach my $DyLib (sort keys(%NeededLib))
191909927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
19191fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $Library_Needed{$LibVersion}{$Lib_Name}{get_filename($DyLib)} = 1;
19192fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
1919374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(my $DepPath = get_LibPath($LibVersion, $DyLib))
1919474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            {
1919574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if(not $CheckedDyLib{$LibVersion}{get_filename($DepPath)}) {
1919674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    readSymbols_Lib($LibVersion, $DepPath, 1, "+Weak", $Deps, $Vers);
1919774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
191989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
19199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    pop(@RecurLib);
19202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Library_Symbol{$LibVersion};
19203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
192059927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub get_prefixes($)
19206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
19207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %Prefixes = ();
192089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    get_prefixes_I([$_[0]], \%Prefixes);
192099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return keys(%Prefixes);
192109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko}
192119927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
192129927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub get_prefixes_I($$)
192139927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{
192149927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    foreach my $P (@{$_[0]})
19215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
192169927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        my @Parts = reverse(split(/[\/\\]+/, $P));
192179927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        my $Name = $Parts[0];
192189927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        foreach (1 .. $#Parts)
192199927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
192209927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $_[1]->{$Name}{$P} = 1;
192219927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            last if($_>4 or $Parts[$_] eq "include");
192229927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $Name = $Parts[$_].$SLASH.$Name;
192239927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
19224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
19227e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenkosub checkSystemFiles()
19228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
19229e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    $Cache{"checkSystemFiles"} = 1;
19230e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
19231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @SysHeaders = ();
19232e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
19233e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    foreach my $DevelPath (@{$SystemPaths{"lib"}})
19234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not -d $DevelPath);
19236e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
19237e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        my @Files = cmd_find($DevelPath);
19238e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
19239e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        if(not $CheckObjectsOnly)
19240e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        {
19241e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            # search for headers in /usr/lib
1924213bb033145ee96b66128046473bfa6b238cf0a48Andrey Ponomarenko            my @Headers = grep { /\.h(pp|xx)?\Z|\/include\// } @Files;
1924313bb033145ee96b66128046473bfa6b238cf0a48Andrey Ponomarenko            @Headers = grep { not /\/(gcc|jvm|syslinux|kbd|parrot|xemacs|perl|llvm)/ } @Headers;
1924413bb033145ee96b66128046473bfa6b238cf0a48Andrey Ponomarenko            push(@SysHeaders, @Headers);
19245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19246e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
19247e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        # search for libraries in /usr/lib (including symbolic links)
19248e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        my @Libs = grep { /\.$LIB_EXT[0-9.]*\Z/ } @Files;
19249e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        foreach my $Path (@Libs)
192509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
19251e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            my $N = get_filename($Path);
19252e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            $SystemObjects{$N}{$Path} = 1;
19253e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            $SystemObjects{parse_libname($N, "name+ext", $OStarget)}{$Path} = 1;
19254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19256e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
19257e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    if(not $CheckObjectsOnly)
19258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19259e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        foreach my $DevelPath (@{$SystemPaths{"include"}})
19260e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        {
19261e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            next if(not -d $DevelPath);
19262e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            # search for all header files in the /usr/include
19263e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            # with or without extension (ncurses.h, QtCore, ...)
19264e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            push(@SysHeaders, cmd_find($DevelPath,"f"));
19265e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            foreach my $Link (cmd_find($DevelPath,"l"))
19266e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            { # add symbolic links
19267e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                if(-f $Link) {
19268e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    push(@SysHeaders, $Link);
19269e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                }
19270e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            }
19271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19272e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        get_prefixes_I(\@SysHeaders, \%SystemHeaders);
19273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1927662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getSOPaths($)
19277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
19278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
192794b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    my @Paths = ();
19280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Dest (split(/\s*\n\s*/, $Descriptor{$LibVersion}{"Libs"}))
19281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -e $Dest) {
19283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access \'$Dest\'");
19284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19285fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $Dest = get_abs_path($Dest);
19286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @SoPaths_Dest = getSOPaths_Dest($Dest, $LibVersion);
19287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach (@SoPaths_Dest) {
192884b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            push(@Paths, $_);
19289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
192914b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    return sort @Paths;
19292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
192948f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub skipLib($$)
19295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
19296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $LibVersion) = @_;
19297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1 if(not $Path or not $LibVersion);
192981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Name = get_filename($Path);
192991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SkipLibs{$LibVersion}{"Name"}{$Name}) {
19300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
19301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
193021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $ShortName = parse_libname($Name, "name+ext", $OStarget);
19303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SkipLibs{$LibVersion}{"Name"}{$ShortName}) {
19304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
19305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Dir (keys(%{$SkipLibs{$LibVersion}{"Path"}}))
19307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Path=~/\Q$Dir\E([\/\\]|\Z)/) {
19309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
19310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
193121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $P (keys(%{$SkipLibs{$LibVersion}{"Pattern"}}))
19313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
193141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Name=~/$P/) {
19315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
19316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
193171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($P=~/[\/\\]/ and $Path=~/$P/) {
19318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
19319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
19322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
193248f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub specificHeader($$)
193258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko{
193268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my ($Header, $Spec) = @_;
193278f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Name = get_filename($Header);
193288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
193298f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($Spec eq "windows")
193308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {# MS Windows
193318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 1 if($Name=~/(\A|[._-])(win|wince|wnt)(\d\d|[._-]|\Z)/i);
193328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 1 if($Name=~/([._-]w|win)(32|64)/i);
193338f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 1 if($Name=~/\A(Win|Windows)[A-Z]/);
193348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 1 if($Name=~/\A(w|win|windows)(32|64|\.)/i);
193358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my @Dirs = (
193368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "win32",
193378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "win64",
193388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "win",
193398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "windows",
193408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "msvcrt"
193418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        ); # /gsf-win32/
193428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(my $DIRs = join("|", @Dirs)) {
193438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1 if($Header=~/[\/\\](|[^\/\\]+[._-])($DIRs)(|[._-][^\/\\]+)([\/\\]|\Z)/i);
193448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
193458f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
193468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    elsif($Spec eq "macos")
193478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # Mac OS
193488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 1 if($Name=~/(\A|[_-])mac[._-]/i);
193498f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
193508f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
193518f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return 0;
193528f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko}
193538f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
193548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub skipAlienHeader($)
193558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko{
193568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Path = $_[0];
193578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Name = get_filename($Path);
193588f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Dir = get_dirname($Path);
193598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
193608f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($Tolerance=~/2/)
193618f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # 2 - skip internal headers
193628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my @Terms = (
193638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "p",
193648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "priv",
193658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "int",
193668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "impl",
193678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "implementation",
193688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "internal",
193698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "private",
193708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "old",
193718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "compat",
193728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "debug",
193738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "test",
193748f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "gen"
193758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        );
193768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
193778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my @Dirs = (
193788f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "private",
193798f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "priv",
193808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "port",
193818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "impl",
193828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "internal",
193838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "detail",
193848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "details",
193858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "old",
193868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "compat",
193878f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "debug",
193888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "config",
193898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "compiler",
193908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "platform",
193918f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "test"
193928f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        );
193938f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
193948f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(my $TERMs = join("|", @Terms)) {
193958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1 if($Name=~/(\A|[._-])($TERMs)([._-]|\Z)/i);
193968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
193978f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(my $DIRs = join("|", @Dirs)) {
193988f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1 if($Dir=~/(\A|[\/\\])(|[^\/\\]+[._-])($DIRs)(|[._-][^\/\\]+)([\/\\]|\Z)/i);
193998f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
194008f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
194018f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 1 if($Name=~/[a-z](Imp|Impl|I|P)(\.|\Z)/);
194028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
194038f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
194048f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($Tolerance=~/1/)
194058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # 1 - skip non-Linux headers
194068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($OSgroup ne "windows")
194078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
194088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(specificHeader($Path, "windows")) {
194098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                return 1;
194108f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
194118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
194128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($OSgroup ne "macos")
194138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
194148f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(specificHeader($Path, "macos")) {
194158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                return 1;
194168f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
194178f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
194188f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
194198f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
194208f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    # valid
194218f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return 0;
194228f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko}
194238f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
1942462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub skipHeader($$)
1942562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
1942662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($Path, $LibVersion) = @_;
1942762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return 1 if(not $Path or not $LibVersion);
1942862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"skipHeader"}{$Path}) {
1942962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"skipHeader"}{$Path};
1943062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
194318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(defined $Tolerance and $Tolerance=~/1|2/)
194328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # --tolerant
194338f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(skipAlienHeader($Path)) {
194348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return ($Cache{"skipHeader"}{$Path} = 1);
194358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
194368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
194378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(not keys(%{$SkipHeaders{$LibVersion}})) {
194388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 0;
194398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
1944062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return ($Cache{"skipHeader"}{$Path} = skipHeader_I(@_));
1944162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
1944262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
1944362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub skipHeader_I($$)
19444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # returns:
19445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  #  1 - if header should NOT be included and checked
19446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  #  2 - if header should NOT be included, but should be checked
19447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $LibVersion) = @_;
194481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Name = get_filename($Path);
194491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(my $Kind = $SkipHeaders{$LibVersion}{"Name"}{$Name}) {
19450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Kind;
19451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
194521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $D (keys(%{$SkipHeaders{$LibVersion}{"Path"}}))
19453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
194549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(index($Path, $D)!=-1)
194559927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
194569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($Path=~/\Q$D\E([\/\\]|\Z)/) {
194579927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                return $SkipHeaders{$LibVersion}{"Path"}{$D};
194589927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
19459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
194611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $P (keys(%{$SkipHeaders{$LibVersion}{"Pattern"}}))
19462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1946362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $Kind = $SkipHeaders{$LibVersion}{"Pattern"}{$P})
1946462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
1946562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($Name=~/$P/) {
1946662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return $Kind;
1946762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
1946862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($P=~/[\/\\]/ and $Path=~/$P/) {
1946962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return $Kind;
1947062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
19471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
194738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
19474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
19475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
194779927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub registerObject_Dir($$)
19478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
19479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Dir, $LibVersion) = @_;
19480570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(grep {$_ eq $Dir} @{$SystemPaths{"lib"}})
19481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # system directory
19482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
19483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
194849927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($RegisteredObject_Dirs{$LibVersion}{$Dir})
19485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # already registered
19486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
19487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (find_libs($Dir,"",1))
19489ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(ignore_path($Path));
194918f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        next if(skipLib($Path, $LibVersion));
194929927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        registerObject($Path, $LibVersion);
19493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
194949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    $RegisteredObject_Dirs{$LibVersion}{$Dir} = 1;
194959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko}
194969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
194979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub registerObject($$)
194989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{
194999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my ($Path, $LibVersion) = @_;
195009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my $Name = get_filename($Path);
1950107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    $RegisteredObjects{$LibVersion}{$Name} = $Path;
195022768170ccc4d3f55596a3ead8a8fee2ee67779bbAndrey Ponomarenko    if($OSgroup=~/linux|bsd/i)
195032768170ccc4d3f55596a3ead8a8fee2ee67779bbAndrey Ponomarenko    {
195042768170ccc4d3f55596a3ead8a8fee2ee67779bbAndrey Ponomarenko        if(my $SONAME = getSONAME($Path)) {
195052768170ccc4d3f55596a3ead8a8fee2ee67779bbAndrey Ponomarenko            $RegisteredSONAMEs{$LibVersion}{$SONAME} = $Path;
195062768170ccc4d3f55596a3ead8a8fee2ee67779bbAndrey Ponomarenko        }
195079927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
1950857a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko    if(my $Short = parse_libname($Name, "name+ext", $OStarget)) {
1950957a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko        $RegisteredObjects_Short{$LibVersion}{$Short} = $Path;
195109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
195119927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko}
195129927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
195139927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub getSONAME($)
195149927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{
195159927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my $Path = $_[0];
195169927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return if(not $Path);
195179927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(defined $Cache{"getSONAME"}{$Path}) {
195189927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $Cache{"getSONAME"}{$Path};
195199927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
195209927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my $ObjdumpCmd = get_CmdPath("objdump");
195219927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(not $ObjdumpCmd) {
195229927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        exitStatus("Not_Found", "can't find \"objdump\"");
195239927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
195249927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my $SonameCmd = "$ObjdumpCmd -x $Path 2>$TMP_DIR/null";
195259927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($OSgroup eq "windows") {
195269927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $SonameCmd .= " | find \"SONAME\"";
195279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
195289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    else {
195299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $SonameCmd .= " | grep SONAME";
195309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
195319927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(my $SonameInfo = `$SonameCmd`) {
195329927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($SonameInfo=~/SONAME\s+([^\s]+)/) {
195339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            return ($Cache{"getSONAME"}{$Path} = $1);
195349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
195359927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
195369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return ($Cache{"getSONAME"}{$Path}="");
19537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
19539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getSOPaths_Dest($$)
19540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
19541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Dest, $LibVersion) = @_;
195428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(skipLib($Dest, $LibVersion)) {
19543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ();
19544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(-f $Dest)
19546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not parse_libname($Dest, "name", $OStarget)) {
19548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "incorrect format of library (should be *.$LIB_EXT): \'$Dest\'");
19549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
195509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        registerObject($Dest, $LibVersion);
195519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        registerObject_Dir(get_dirname($Dest), $LibVersion);
19552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ($Dest);
19553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif(-d $Dest)
19555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Dest=~s/[\/\\]+\Z//g;
1955762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Libs = ();
19558570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(grep { $Dest eq $_ } @{$SystemPaths{"lib"}})
19559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # you have specified /usr/lib as the search directory (<libs>) in the XML descriptor
19560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # and the real name of the library by -l option (bz2, stdc++, Xaw, ...)
19561570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            foreach my $Path (cmd_find($Dest,"","*".esc($TargetLibraryName)."*.$LIB_EXT*",2))
19562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # all files and symlinks that match the name of a library
19563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(get_filename($Path)=~/\A(|lib)\Q$TargetLibraryName\E[\d\-]*\.$LIB_EXT[\d\.]*\Z/i)
19564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
195659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    registerObject($Path, $LibVersion);
1956674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $Libs{realpath($Path)}=1;
19567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
19568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
19569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
19571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # search for all files and symlinks
19572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Path (find_libs($Dest,"",""))
19573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
19574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next if(ignore_path($Path));
195758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                next if(skipLib($Path, $LibVersion));
195769927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                registerObject($Path, $LibVersion);
1957774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $Libs{realpath($Path)}=1;
19578ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
19579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($OSgroup eq "macos")
19580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # shared libraries on MacOS X may have no extension
19581570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                foreach my $Path (cmd_find($Dest,"f"))
19582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
19583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next if(ignore_path($Path));
195848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    next if(skipLib($Path, $LibVersion));
19585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(get_filename($Path)!~/\./
19586850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    and cmd_file($Path)=~/(shared|dynamic)\s+library/i)
19587850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    {
195889927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        registerObject($Path, $LibVersion);
1958974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        $Libs{realpath($Path)}=1;
19590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
19591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
19592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
19593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1959462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return keys(%Libs);
19595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
19597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ();
19598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
196011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub isCyclical($$)
196021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
196031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Stack, $Value) = @_;
196041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    return (grep {$_ eq $Value} @{$Stack});
19605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
19607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detectWordSize()
19608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
19609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $GCC_PATH);
19610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Cache{"detectWordSize"}) {
19611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"detectWordSize"};
19612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    writeFile("$TMP_DIR/empty.h", "");
19614a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    my $Defines = `$GCC_PATH -E -dD \"$TMP_DIR/empty.h\"`;
19615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    unlink("$TMP_DIR/empty.h");
19616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $WSize = 0;
19617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Defines=~/ __SIZEOF_POINTER__\s+(\d+)/)
196181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # GCC 4
19619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $WSize = $1;
19620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Defines=~/ __PTRDIFF_TYPE__\s+(\w+)/)
196221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # GCC 3
19623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $PTRDIFF = $1;
19624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($PTRDIFF=~/long/) {
1962562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $WSize = "8";
19626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
1962862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $WSize = "4";
19629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1963101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(not $WSize) {
19632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Error", "can't check WORD size");
19633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"detectWordSize"} = $WSize);
19635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
19637f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenkosub getWordSize($) {
19638f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    return $WORD_SIZE{$_[0]};
19639f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko}
19640f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
19641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub majorVersion($)
19642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
19643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $V = $_[0];
19644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not $V);
19645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @VParts = split(/\./, $V);
19646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $VParts[0];
19647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
19649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub cmpVersions($$)
196501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{ # compare two versions in dotted-numeric format
19651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($V1, $V2) = @_;
19652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if($V1 eq $V2);
19653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @V1Parts = split(/\./, $V1);
19654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @V2Parts = split(/\./, $V2);
19655570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    for (my $i = 0; $i <= $#V1Parts && $i <= $#V2Parts; $i++)
19656570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
19657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return -1 if(int($V1Parts[$i]) < int($V2Parts[$i]));
19658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1 if(int($V1Parts[$i]) > int($V2Parts[$i]));
19659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return -1 if($#V1Parts < $#V2Parts);
19661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1 if($#V1Parts > $#V2Parts);
19662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
19663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
19665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub read_ABI_Dump($$)
19666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
19667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($LibVersion, $Path) = @_;
19668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(not $LibVersion or not -e $Path);
19669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $FilePath = "";
196709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(isDump_U($Path))
19671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # input *.abi
19672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $FilePath = $Path;
19673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
19675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # input *.abi.tar.gz
19676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $FilePath = unpackDump($Path);
196779927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(not isDump_U($FilePath)) {
196789927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            exitStatus("Invalid_Dump", "specified ABI dump \'$Path\' is not valid, try to recreate it");
196799927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
19680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19681850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
1968201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $ABI = {};
19683850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
1968401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $Line = readLineNum($FilePath, 0);
1968501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if($Line=~/xml/)
1968601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    { # XML format
1968701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        loadModule("XmlDump");
1968801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI = readXmlDump($FilePath);
19689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1969001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    else
1969101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    { # Perl Data::Dumper format (default)
1969201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        open(DUMP, $FilePath);
1969301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        local $/ = undef;
1969401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        my $Content = <DUMP>;
1969501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        close(DUMP);
1969601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
1969701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(get_dirname($FilePath) eq $TMP_DIR."/unpack")
1969801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        { # remove temp file
1969901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            unlink($FilePath);
1970001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
1970101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if($Content!~/};\s*\Z/) {
1970201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            exitStatus("Invalid_Dump", "specified ABI dump \'$Path\' is not valid, try to recreate it");
1970301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
1970401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI = eval($Content);
1970501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(not $ABI) {
1970601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            exitStatus("Error", "internal error - eval() procedure seem to not working correctly, try to remove 'use strict' and try again");
1970701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
19708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # new dumps (>=1.22) have a personal versioning
19710570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my $DVersion = $ABI->{"ABI_DUMP_VERSION"};
1971101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $ToolVersion = $ABI->{"ABI_COMPLIANCE_CHECKER_VERSION"};
19712570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(not $DVersion)
19713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # old dumps (<=1.21.6) have been marked by the tool version
19714570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        $DVersion = $ToolVersion;
19715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19716570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $UsedDump{$LibVersion}{"V"} = $DVersion;
19717fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
19718fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($ABI->{"ABI_DUMP_VERSION"})
19719fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
19720570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(cmpVersions($DVersion, $ABI_DUMP_VERSION)>0)
19721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # Don't know how to parse future dump formats
19722570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            exitStatus("Dump_Version", "incompatible version \'$DVersion\' of specified ABI dump (newer than $ABI_DUMP_VERSION)");
19723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19724fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
19725fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    else
19726fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # support for old ABI dumps
19727fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(cmpVersions($DVersion, $TOOL_VERSION)>0)
19728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # Don't know how to parse future dump formats
19729570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            exitStatus("Dump_Version", "incompatible version \'$DVersion\' of specified ABI dump (newer than $TOOL_VERSION)");
19730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19731fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
19732fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(majorVersion($DVersion)<2)
19733fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # support for old ABI dumps
19734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($UseOldDumps)
19735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
19736570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(cmpVersions($DVersion, $OLDEST_SUPPORTED_VERSION)<0) {
19737570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                exitStatus("Dump_Version", "incompatible version \'$DVersion\' of specified ABI dump (older than $OLDEST_SUPPORTED_VERSION)");
19738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
19739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
19741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
19742fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my $Msg = "incompatible version \'$DVersion\' of specified ABI dump (allowed only 2.0<=V<=$ABI_DUMP_VERSION)";
19743570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(cmpVersions($DVersion, $OLDEST_SUPPORTED_VERSION)>=0) {
19744fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $Msg .= "\nUse -old-dumps option to use old-version dumps ($OLDEST_SUPPORTED_VERSION<=V<2.0)";
19745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
19746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Dump_Version", $Msg);
19747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19749fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
19750fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(defined $ABI->{"ABI_DUMPER_VERSION"})
19751fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # DWARF ABI Dump
19752fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $UseConv_Real{$LibVersion}{"P"} = 1;
19753fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $UseConv_Real{$LibVersion}{"R"} = 0; # not implemented yet
19754fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
19755fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $UsedDump{$LibVersion}{"DWARF"} = 1;
19756fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
19757fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $TargetComponent = "module";
19758fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
19759fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
197605c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if(not checkDump($LibVersion, "2.11"))
197615c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    { # old ABI dumps
197625c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $UsedDump{$LibVersion}{"BinOnly"} = 1;
197631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
1976401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    elsif($ABI->{"BinOnly"})
197651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # ABI dump created with --binary option
197661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $UsedDump{$LibVersion}{"BinOnly"} = 1;
197671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
197685c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    else
197695c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    { # default
197705c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $UsedDump{$LibVersion}{"SrcBin"} = 1;
197715c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
19772fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
1977301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(defined $ABI->{"Mode"}
1977401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    and $ABI->{"Mode"} eq "Extended")
19775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --ext option
19776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ExtendedCheck = 1;
19777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1977874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ABI->{"Extra"}) {
1977974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $ExtraDump = 1;
1978074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
1978174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1978201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(my $Lang = $ABI->{"Language"})
19783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $UsedDump{$LibVersion}{"L"} = $Lang;
19785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        setLanguage($LibVersion, $Lang);
19786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1978762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(checkDump($LibVersion, "2.15")) {
1978801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $TypeInfo{$LibVersion} = $ABI->{"TypeInfo"};
1978962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
1979062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    else
19791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
1979201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        my $TInfo = $ABI->{"TypeInfo"};
1979362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $TInfo)
1979462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # support for older ABI dumps
1979501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            $TInfo = $ABI->{"TypeDescr"};
1979662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1979762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Tid_TDid = ();
1979862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $TDid (keys(%{$TInfo}))
1979962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
1980062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            foreach my $Tid (keys(%{$TInfo->{$TDid}}))
1980162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
1980262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $MAX_ID = $Tid if($Tid>$MAX_ID);
1980362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $MAX_ID = $TDid if($TDid and $TDid>$MAX_ID);
19804177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $Tid_TDid{$Tid}{$TDid} = 1;
1980562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
1980662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1980762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %NewID = ();
1980862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $Tid (keys(%Tid_TDid))
1980962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
1981062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my @TDids = keys(%{$Tid_TDid{$Tid}});
1981162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($#TDids>=1)
1981262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
1981362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                foreach my $TDid (@TDids)
1981462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
1981562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($TDid) {
1981662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        %{$TypeInfo{$LibVersion}{$Tid}} = %{$TInfo->{$TDid}{$Tid}};
1981762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
1981862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    else
1981962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    {
19820177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        my $ID = ++$MAX_ID;
19821177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
19822177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $NewID{$TDid}{$Tid} = $ID;
19823177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        %{$TypeInfo{$LibVersion}{$ID}} = %{$TInfo->{$TDid}{$Tid}};
19824177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $TypeInfo{$LibVersion}{$ID}{"Tid"} = $ID;
1982562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
1982662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
1982762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
1982862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            else
1982962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
1983062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $TDid = $TDids[0];
1983162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                %{$TypeInfo{$LibVersion}{$Tid}} = %{$TInfo->{$TDid}{$Tid}};
1983262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
1983362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1983462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $Tid (keys(%{$TypeInfo{$LibVersion}}))
1983562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
1983662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my %Info = %{$TypeInfo{$LibVersion}{$Tid}};
1983762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(defined $Info{"BaseType"})
1983862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
1983962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $Bid = $Info{"BaseType"}{"Tid"};
1984062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $BDid = $Info{"BaseType"}{"TDid"};
1984162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $BDid="" if(not defined $BDid);
19842fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                delete($TypeInfo{$LibVersion}{$Tid}{"BaseType"}{"TDid"});
1984362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(defined $NewID{$BDid} and my $ID = $NewID{$BDid}{$Bid}) {
19844fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $TypeInfo{$LibVersion}{$Tid}{"BaseType"} = $ID;
1984562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
1984662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
1984762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            delete($TypeInfo{$LibVersion}{$Tid}{"TDid"});
1984862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
19849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1985001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    read_Machine_DumpInfo($ABI, $LibVersion);
1985101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $SymbolInfo{$LibVersion} = $ABI->{"SymbolInfo"};
19852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SymbolInfo{$LibVersion})
19853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old dumps
1985401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $SymbolInfo{$LibVersion} = $ABI->{"FuncDescr"};
19855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not keys(%{$SymbolInfo{$LibVersion}}))
19857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # validation of old-version dumps
19858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $ExtendedCheck) {
19859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Invalid_Dump", "the input dump d$LibVersion is invalid");
19860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1986262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(checkDump($LibVersion, "2.15")) {
1986301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $DepLibrary_Symbol{$LibVersion} = $ABI->{"DepSymbols"};
19864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1986562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    else
1986662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # support for old ABI dumps
1986701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        my $DepSymbols = $ABI->{"DepSymbols"};
1986862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $DepSymbols) {
1986901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            $DepSymbols = $ABI->{"DepInterfaces"};
1987062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1987162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $DepSymbols)
1987262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # Cannot reconstruct DepSymbols. This may result in false
1987362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko          # positives if the old dump is for library 2. Not a problem if
1987462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko          # old dumps are only from old libraries.
1987562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $DepSymbols = {};
1987662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1987762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $Symbol (keys(%{$DepSymbols})) {
1987862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $DepSymbol_Library{$LibVersion}{$Symbol} = 1;
1987962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
19880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1988101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $SymVer{$LibVersion} = $ABI->{"SymbolVersion"};
1988201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $Descriptor{$LibVersion}{"Version"} = $ABI->{"LibraryVersion"};
1988301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $SkipTypes{$LibVersion} = $ABI->{"SkipTypes"};
19884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SkipTypes{$LibVersion})
19885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old dumps
1988601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $SkipTypes{$LibVersion} = $ABI->{"OpaqueTypes"};
19887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1988801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $SkipSymbols{$LibVersion} = $ABI->{"SkipSymbols"};
19889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SkipSymbols{$LibVersion})
19890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old dumps
1989101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $SkipSymbols{$LibVersion} = $ABI->{"SkipInterfaces"};
19892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SkipSymbols{$LibVersion})
19894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old dumps
1989501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $SkipSymbols{$LibVersion} = $ABI->{"InternalInterfaces"};
19896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1989701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $SkipNameSpaces{$LibVersion} = $ABI->{"SkipNameSpaces"};
1989801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $TargetHeaders{$LibVersion} = $ABI->{"TargetHeaders"};
1989901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    foreach my $Path (keys(%{$ABI->{"SkipHeaders"}}))
19900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1990101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $SkipHeadersList{$LibVersion}{$Path} = $ABI->{"SkipHeaders"}{$Path};
19902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($CPath, $Type) = classifyPath($Path);
1990301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $SkipHeaders{$LibVersion}{$Type}{$CPath} = $ABI->{"SkipHeaders"}{$Path};
19904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19905fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    read_Source_DumpInfo($ABI, $LibVersion);
1990601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    read_Libs_DumpInfo($ABI, $LibVersion);
199075c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if(not checkDump($LibVersion, "2.10.1")
199085c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    or not $TargetHeaders{$LibVersion})
19909850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    { # support for old ABI dumps: added target headers
19910850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        foreach (keys(%{$Registered_Headers{$LibVersion}})) {
199113e69aa34938c9daf12718f2fe825c43a890edaa1Andrey Ponomarenko            $TargetHeaders{$LibVersion}{get_filename($_)} = 1;
19912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19913fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        foreach (keys(%{$Registered_Sources{$LibVersion}})) {
199143e69aa34938c9daf12718f2fe825c43a890edaa1Andrey Ponomarenko            $TargetHeaders{$LibVersion}{get_filename($_)} = 1;
19915fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
19916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1991701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $Constants{$LibVersion} = $ABI->{"Constants"};
19918fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(defined $ABI->{"GccConstants"})
19919fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # 3.0
19920fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        foreach my $Name (keys(%{$ABI->{"GccConstants"}})) {
19921fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $Constants{$LibVersion}{$Name}{"Value"} = $ABI->{"GccConstants"}{$Name};
19922fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
19923fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
19924fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
1992501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $NestedNameSpaces{$LibVersion} = $ABI->{"NameSpaces"};
19926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $NestedNameSpaces{$LibVersion})
19927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old dumps
19928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # Cannot reconstruct NameSpaces. This may affect design
19929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # of the compatibility report.
19930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $NestedNameSpaces{$LibVersion} = {};
19931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # target system type
19933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # needed to adopt HTML report
19934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $DumpSystem)
19935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # to use in createSymbolsList(...)
1993601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $OStarget = $ABI->{"Target"};
19937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # recreate environment
19939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Lib_Name (keys(%{$Library_Symbol{$LibVersion}}))
19940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1994162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $Symbol (keys(%{$Library_Symbol{$LibVersion}{$Lib_Name}}))
19942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1994362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $Symbol_Library{$LibVersion}{$Symbol} = $Lib_Name;
1994462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($Library_Symbol{$LibVersion}{$Lib_Name}{$Symbol}<=-1)
19945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # data marked as -size in the dump
19946fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $GlobalDataObject{$LibVersion}{$Symbol} = -$Library_Symbol{$LibVersion}{$Lib_Name}{$Symbol};
19947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
199489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($COMMON_LANGUAGE{$LibVersion} ne "C++")
199499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
199509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if(index($Symbol, "_Z")==0 or index($Symbol, "?")==0) {
199519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    setLanguage($LibVersion, "C++");
199529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
19953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
19954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1995662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $Lib_Name (keys(%{$DepLibrary_Symbol{$LibVersion}}))
1995762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
1995862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $Symbol (keys(%{$DepLibrary_Symbol{$LibVersion}{$Lib_Name}})) {
1995962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $DepSymbol_Library{$LibVersion}{$Symbol} = $Lib_Name;
1996062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1996162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
1996262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
19963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @VFunc = ();
199641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $InfoId (keys(%{$SymbolInfo{$LibVersion}}))
19965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19966f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if(my $MnglName = $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"})
1996762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
1996862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(not $Symbol_Library{$LibVersion}{$MnglName}
1996962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            and not $DepSymbol_Library{$LibVersion}{$MnglName}) {
1997062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                push(@VFunc, $MnglName);
1997162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
19972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    translateSymbols(@VFunc, $LibVersion);
19975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    translateSymbols(keys(%{$Symbol_Library{$LibVersion}}), $LibVersion);
1997662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    translateSymbols(keys(%{$DepSymbol_Library{$LibVersion}}), $LibVersion);
1997762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
19978fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(not checkDump($LibVersion, "3.0"))
19979fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # support for old ABI dumps
19980fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        foreach my $TypeId (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
19981fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
19982fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(my $BaseType = $TypeInfo{$LibVersion}{$TypeId}{"BaseType"})
19983fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
19984fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(ref($BaseType) eq "HASH") {
19985fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $TypeInfo{$LibVersion}{$TypeId}{"BaseType"} = $TypeInfo{$LibVersion}{$TypeId}{"BaseType"}{"Tid"};
19986fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
19987fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
19988fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
19989fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
19990fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
19991177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(not checkDump($LibVersion, "3.2"))
19992177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    { # support for old ABI dumps
19993177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $TypeId (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
19994177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
19995177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $TypeInfo{$LibVersion}{$TypeId}{"VTable"})
19996177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
19997177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach my $Offset (keys(%{$TypeInfo{$LibVersion}{$TypeId}{"VTable"}})) {
19998177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $TypeInfo{$LibVersion}{$TypeId}{"VTable"}{$Offset} = simplifyVTable($TypeInfo{$LibVersion}{$TypeId}{"VTable"}{$Offset});
19999177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
20000177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
20001177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
20002177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
20003177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        # repair target headers list
20004177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        delete($TargetHeaders{$LibVersion});
20005177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach (keys(%{$Registered_Headers{$LibVersion}})) {
200063e69aa34938c9daf12718f2fe825c43a890edaa1Andrey Ponomarenko            $TargetHeaders{$LibVersion}{get_filename($_)} = 1;
200073e69aa34938c9daf12718f2fe825c43a890edaa1Andrey Ponomarenko        }
200083e69aa34938c9daf12718f2fe825c43a890edaa1Andrey Ponomarenko        foreach (keys(%{$Registered_Sources{$LibVersion}})) {
200093e69aa34938c9daf12718f2fe825c43a890edaa1Andrey Ponomarenko            $TargetHeaders{$LibVersion}{get_filename($_)} = 1;
20010177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
20011177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
20012177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        # non-target constants from anon enums
20013177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Name (keys(%{$Constants{$LibVersion}}))
20014177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
20015177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(not $ExtraDump
20016177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            and not is_target_header($Constants{$LibVersion}{$Name}{"Header"}, $LibVersion))
20017177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
20018177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                delete($Constants{$LibVersion}{$Name});
20019177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
20020177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
20021177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
20022177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2002374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(not checkDump($LibVersion, "2.20"))
2002474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    { # support for old ABI dumps
2002574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        foreach my $TypeId (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
2002674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        {
2002774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $TType = $TypeInfo{$LibVersion}{$TypeId}{"Type"};
2002874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2002974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if($TType=~/Struct|Union|Enum|Typedef/)
2003074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            { # repair complex types first
2003174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                next;
2003274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
2003374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
20034fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(my $BaseId = $TypeInfo{$LibVersion}{$TypeId}{"BaseType"})
2003574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            {
2003674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                my $BType = lc($TypeInfo{$LibVersion}{$BaseId}{"Type"});
2003774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if($BType=~/Struct|Union|Enum/i)
2003874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                {
2003974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    my $BName = $TypeInfo{$LibVersion}{$BaseId}{"Name"};
2004074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $TypeInfo{$LibVersion}{$TypeId}{"Name"}=~s/\A\Q$BName\E\b/$BType $BName/g;
2004174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
2004274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
2004374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
2004474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        foreach my $TypeId (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
2004574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        {
2004674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $TType = $TypeInfo{$LibVersion}{$TypeId}{"Type"};
2004774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $TName = $TypeInfo{$LibVersion}{$TypeId}{"Name"};
2004874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if($TType=~/Struct|Union|Enum/) {
2004974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $TypeInfo{$LibVersion}{$TypeId}{"Name"} = lc($TType)." ".$TName;
2005074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
2005174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
2005274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
2005374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2005462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $TypeId (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
20055f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    { # order is important
2005662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(defined $TypeInfo{$LibVersion}{$TypeId}{"BaseClass"})
2005762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # support for old ABI dumps < 2.0 (ACC 1.22)
2005862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            foreach my $BId (keys(%{$TypeInfo{$LibVersion}{$TypeId}{"BaseClass"}}))
2005962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
2006062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(my $Access = $TypeInfo{$LibVersion}{$TypeId}{"BaseClass"}{$BId})
20061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
2006262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($Access ne "public") {
2006362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $TypeInfo{$LibVersion}{$TypeId}{"Base"}{$BId}{"access"} = $Access;
20064ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
20065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
2006662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $TypeInfo{$LibVersion}{$TypeId}{"Base"}{$BId} = {};
2006762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2006862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            delete($TypeInfo{$LibVersion}{$TypeId}{"BaseClass"});
2006962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
200709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(my $Header = $TypeInfo{$LibVersion}{$TypeId}{"Header"})
200719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # support for old ABI dumps
200729927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $TypeInfo{$LibVersion}{$TypeId}{"Header"} = path_format($Header, $OSgroup);
200739927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
20074fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        elsif(my $Source = $TypeInfo{$LibVersion}{$TypeId}{"Source"})
20075fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # DWARF ABI Dumps
20076fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TypeInfo{$LibVersion}{$TypeId}{"Header"} = $Source;
20077fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
2007801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(not defined $TypeInfo{$LibVersion}{$TypeId}{"Tid"}) {
2007901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            $TypeInfo{$LibVersion}{$TypeId}{"Tid"} = $TypeId;
2008001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
2008162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %TInfo = %{$TypeInfo{$LibVersion}{$TypeId}};
2008262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(defined $TInfo{"Base"})
2008362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
2008462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            foreach (keys(%{$TInfo{"Base"}})) {
2008562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $Class_SubClasses{$LibVersion}{$_}{$TypeId}=1;
2008662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2008762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2008801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if($TInfo{"Type"} eq "MethodPtr")
2008901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        {
2009001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if(defined $TInfo{"Param"})
2009101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # support for old ABI dumps <= 1.17
2009201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                if(not defined $TInfo{"Param"}{"0"})
2009301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                {
2009401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    my $Max = keys(%{$TInfo{"Param"}});
2009501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    foreach my $Pos (1 .. $Max) {
2009601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                        $TInfo{"Param"}{$Pos-1} = $TInfo{"Param"}{$Pos};
2009701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    }
2009801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    delete($TInfo{"Param"}{$Max});
2009901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    %{$TypeInfo{$LibVersion}{$TypeId}} = %TInfo;
2010001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                }
2010101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
2010201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
20103fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($TInfo{"BaseType"} eq $TypeId)
20104fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # fix ABI dump
20105fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            delete($TypeInfo{$LibVersion}{$TypeId}{"BaseType"});
20106fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
20107fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($TInfo{"Type"} eq "Typedef" and not $TInfo{"Artificial"})
2010862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
20109fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(my $BTid = $TInfo{"BaseType"})
2011062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
2011162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $BName = $TypeInfo{$LibVersion}{$BTid}{"Name"};
2011262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(not $BName)
2011362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                { # broken type
2011462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    next;
2011562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
2011662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($TInfo{"Name"} eq $BName)
2011762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                { # typedef to "class Class"
201188f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                  # should not be registered in TName_Tid
2011962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    next;
2012062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
2012162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(not $Typedef_BaseName{$LibVersion}{$TInfo{"Name"}}) {
2012262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $Typedef_BaseName{$LibVersion}{$TInfo{"Name"}} = $BName;
2012362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
20124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2012562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2012662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $TName_Tid{$LibVersion}{$TInfo{"Name"}})
2012762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # classes: class (id1), typedef (artificial, id2 > id1)
20128fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TName_Tid{$LibVersion}{formatName($TInfo{"Name"}, "T")} = $TypeId;
2012962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2013062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
2013162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
2013262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not checkDump($LibVersion, "2.15"))
2013362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # support for old ABI dumps
2013462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Dups = ();
2013562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $InfoId (keys(%{$SymbolInfo{$LibVersion}}))
2013662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
2013762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $ClassId = $SymbolInfo{$LibVersion}{$InfoId}{"Class"})
20138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
2013962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(not defined $TypeInfo{$LibVersion}{$ClassId})
2014062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                { # remove template decls
2014162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    delete($SymbolInfo{$LibVersion}{$InfoId});
2014262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    next;
20143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20145b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            my $MName = $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"};
20146b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if(not $MName and $SymbolInfo{$LibVersion}{$InfoId}{"Class"})
2014762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            { # templates
2014862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                delete($SymbolInfo{$LibVersion}{$InfoId});
20149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20153f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    foreach my $InfoId (keys(%{$SymbolInfo{$LibVersion}}))
20154f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    {
20155ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        if(my $Class = $SymbolInfo{$LibVersion}{$InfoId}{"Class"}
20156ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        and not $SymbolInfo{$LibVersion}{$InfoId}{"Static"}
20157ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        and not $SymbolInfo{$LibVersion}{$InfoId}{"Data"})
20158ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        { # support for old ABI dumps (< 3.1)
20159ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko            if(not defined $SymbolInfo{$LibVersion}{$InfoId}{"Param"}
20160ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko            or $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{0}{"name"} ne "this")
20161ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko            { # add "this" first parameter
20162ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                my $ThisTid = getTypeIdByName($TypeInfo{$LibVersion}{$Class}{"Name"}."*const", $LibVersion);
20163ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                my %PInfo = ("name"=>"this", "type"=>"$ThisTid");
20164ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko
20165ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                if(defined $SymbolInfo{$LibVersion}{$InfoId}{"Param"})
20166ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                {
20167ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                    my @Pos = sort {int($a)<=>int($b)} keys(%{$SymbolInfo{$LibVersion}{$InfoId}{"Param"}});
20168ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                    foreach my $Pos (reverse(0 .. $#Pos)) {
20169ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                        %{$SymbolInfo{$LibVersion}{$InfoId}{"Param"}{$Pos+1}} = %{$SymbolInfo{$LibVersion}{$InfoId}{"Param"}{$Pos}};
20170ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                    }
20171ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                }
20172ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{"0"} = \%PInfo;
20173ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko            }
20174ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        }
20175ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko
20176f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if(not $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"})
20177f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        { # ABI dumps have no mangled names for C-functions
20178f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"} = $SymbolInfo{$LibVersion}{$InfoId}{"ShortName"};
20179f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
201809927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(my $Header = $SymbolInfo{$LibVersion}{$InfoId}{"Header"})
201819927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # support for old ABI dumps
201829927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $SymbolInfo{$LibVersion}{$InfoId}{"Header"} = path_format($Header, $OSgroup);
201839927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
20184fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        elsif(my $Source = $SymbolInfo{$LibVersion}{$InfoId}{"Source"})
20185fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # DWARF ABI Dumps
20186fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $SymbolInfo{$LibVersion}{$InfoId}{"Header"} = $Source;
20187fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
20188f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
20189f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
20190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Descriptor{$LibVersion}{"Dump"} = 1;
20191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub read_Machine_DumpInfo($$)
20194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2019501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my ($ABI, $LibVersion) = @_;
2019601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if($ABI->{"Arch"}) {
2019701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $CPU_ARCH{$LibVersion} = $ABI->{"Arch"};
20198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2019901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if($ABI->{"WordSize"}) {
2020001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $WORD_SIZE{$LibVersion} = $ABI->{"WordSize"};
20201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
20203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old dumps
2020401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $WORD_SIZE{$LibVersion} = $ABI->{"SizeOfPointer"};
20205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $WORD_SIZE{$LibVersion})
20207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old dumps (<1.23)
20208ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $Tid = getTypeIdByName("char*", $LibVersion))
20209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # size of char*
2021062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $WORD_SIZE{$LibVersion} = $TypeInfo{$LibVersion}{$Tid}{"Size"};
20211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
20213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
20214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $PSize = 0;
2021562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            foreach my $Tid (keys(%{$TypeInfo{$LibVersion}}))
20216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
2021762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($TypeInfo{$LibVersion}{$Tid}{"Type"} eq "Pointer")
2021862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                { # any "pointer"-type
2021962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $PSize = $TypeInfo{$LibVersion}{$Tid}{"Size"};
20220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    last;
20221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($PSize)
20224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # a pointer type size
20225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $WORD_SIZE{$LibVersion} = $PSize;
20226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
20228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                printMsg("WARNING", "cannot identify a WORD size in the ABI dump (too old format)");
20229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2023201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if($ABI->{"GccVersion"}) {
2023301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $GCC_VERSION{$LibVersion} = $ABI->{"GccVersion"};
20234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub read_Libs_DumpInfo($$)
20238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2023901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my ($ABI, $LibVersion) = @_;
202409927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    $Library_Symbol{$LibVersion} = $ABI->{"Symbols"};
202419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(not $Library_Symbol{$LibVersion})
202429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # support for old dumps
202439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $Library_Symbol{$LibVersion} = $ABI->{"Interfaces"};
202449927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
20245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(keys(%{$Library_Symbol{$LibVersion}})
20246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and not $DumpAPI) {
20247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Descriptor{$LibVersion}{"Libs"} = "OK";
20248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20251fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub read_Source_DumpInfo($$)
20252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2025301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my ($ABI, $LibVersion) = @_;
20254fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
2025501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(keys(%{$ABI->{"Headers"}})
20256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and not $DumpAPI) {
20257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Descriptor{$LibVersion}{"Headers"} = "OK";
20258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2025901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    foreach my $Identity (sort {$ABI->{"Headers"}{$a}<=>$ABI->{"Headers"}{$b}} keys(%{$ABI->{"Headers"}}))
20260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # headers info is stored in the old dumps in the different way
20261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($UseOldDumps
2026201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        and my $Name = $ABI->{"Headers"}{$Identity}{"Name"})
20263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # support for old dumps: headers info corrected in 1.22
20264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Identity = $Name;
20265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Registered_Headers{$LibVersion}{$Identity}{"Identity"} = $Identity;
2026701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $Registered_Headers{$LibVersion}{$Identity}{"Pos"} = $ABI->{"Headers"}{$Identity};
20268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20269fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
20270fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(keys(%{$ABI->{"Sources"}})
20271fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    and not $DumpAPI) {
20272fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $Descriptor{$LibVersion}{"Sources"} = "OK";
20273fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
20274fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    foreach my $Name (sort {$ABI->{"Sources"}{$a}<=>$ABI->{"Sources"}{$b}} keys(%{$ABI->{"Sources"}}))
20275fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # headers info is stored in the old dumps in the different way
20276fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $Registered_Sources{$LibVersion}{$Name}{"Identity"} = $Name;
20277fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $Registered_Sources{$LibVersion}{$Name}{"Pos"} = $ABI->{"Headers"}{$Name};
20278fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
20279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub find_libs($$$)
20282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Type, $MaxDepth) = @_;
20284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # FIXME: correct the search pattern
202858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return cmd_find($Path, $Type, '\.'.$LIB_EXT.'[0-9.]*\Z', $MaxDepth, 1);
20286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub createDescriptor($$)
20289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($LibVersion, $Path) = @_;
20291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $LibVersion or not $Path
20292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or not -e $Path) {
20293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
20294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(-d $Path)
20296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # directory with headers files and shared objects
20297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "
20298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            <version>
20299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                ".$TargetVersion{$LibVersion}."
20300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            </version>
20301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            <headers>
20303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Path
20304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            </headers>
20305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            <libs>
20307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Path
20308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            </libs>";
20309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
20311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # files
203129927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($Path=~/\.(xml|desc)\Z/i)
20313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # standard XML-descriptor
20314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return readFile($Path);
20315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(is_header($Path, 2, $LibVersion))
20317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # header file
20318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "
20319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <version>
20320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    ".$TargetVersion{$LibVersion}."
20321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </version>
20322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <headers>
20324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Path
20325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </headers>
20326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <libs>
20328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    none
20329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </libs>";
20330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(parse_libname($Path, "name", $OStarget))
20332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # shared object
20333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "
20334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <version>
20335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    ".$TargetVersion{$LibVersion}."
20336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </version>
20337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <headers>
20339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    none
20340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </headers>
20341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <libs>
20343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Path
20344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </libs>";
20345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
20347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # standard XML-descriptor
20348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return readFile($Path);
20349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_lib_default_paths()
20354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %LPaths = ();
20356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup eq "bsd")
20357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20358a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if(my $LdConfig = get_CmdPath("ldconfig"))
20359a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        {
20360a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            foreach my $Line (split(/\n/, `$LdConfig -r 2>\"$TMP_DIR/null\"`))
20361a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            {
2036274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if($Line=~/\A[ \t]*\d+:\-l(.+) \=\> (.+)\Z/)
2036374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                {
2036474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    my $Name = "lib".$1;
2036574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    if(not defined $LPaths{$Name}) {
2036674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        $LPaths{$Name} = $2;
2036774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    }
20368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
20372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            printMsg("WARNING", "can't find ldconfig");
20373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
20376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $LdConfig = get_CmdPath("ldconfig"))
20378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
20379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($SystemRoot and $OSgroup eq "linux")
20380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # use host (x86) ldconfig with the target (arm) ld.so.conf
20381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(-e $SystemRoot."/etc/ld.so.conf") {
20382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $LdConfig .= " -f ".$SystemRoot."/etc/ld.so.conf";
20383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20385a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            foreach my $Line (split(/\n/, `$LdConfig -p 2>\"$TMP_DIR/null\"`))
20386a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            {
20387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Line=~/\A[ \t]*([^ \t]+) .* \=\> (.+)\Z/)
20388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
20389ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my ($Name, $Path) = ($1, $2);
20390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Path=~s/[\/]{2,}/\//;
2039174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    if(not defined $LPaths{$Name})
2039274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    { # get first element from the list of available paths
2039374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2039474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                      # libstdc++.so.6 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libstdc++.so.6
2039574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                      # libstdc++.so.6 (libc6) => /usr/lib/i386-linux-gnu/libstdc++.so.6
2039674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                      # libstdc++.so.6 (libc6) => /usr/lib32/libstdc++.so.6
2039774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2039874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        $LPaths{$Name} = $Path;
2039974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    }
20400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2040382b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko        elsif($OSgroup eq "linux") {
20404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            printMsg("WARNING", "can't find ldconfig");
20405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return \%LPaths;
20408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_bin_default_paths()
20411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $EnvPaths = $ENV{"PATH"};
20413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup eq "beos") {
20414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $EnvPaths.=":".$ENV{"BETOOLS"};
20415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Sep = ($OSgroup eq "windows")?";":":|;";
20417570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Path (split(/$Sep/, $EnvPaths))
20418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = path_format($Path, $OSgroup);
20420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Path);
20421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SystemRoot
20422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Path=~/\A\Q$SystemRoot\E\//)
20423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # do NOT use binaries from target system
20424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
20425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20426570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push_U(\@DefaultBinPaths, $Path);
20427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_inc_default_paths()
20431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $GCC_PATH);
20433570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my %DPaths = ("Cpp"=>[],"Gcc"=>[],"Inc"=>[]);
20434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    writeFile("$TMP_DIR/empty.h", "");
20435a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    foreach my $Line (split(/\n/, `$GCC_PATH -v -x c++ -E \"$TMP_DIR/empty.h\" 2>&1`))
204361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # detecting GCC default include paths
20437570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        next if(index($Line, "/cc1plus ")!=-1);
20438570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
20439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Line=~/\A[ \t]*((\/|\w+:\\).+)[ \t]*\Z/)
20440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
2044174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $Path = realpath($1);
20442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Path = path_format($Path, $OSgroup);
20443570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(index($Path, "c++")!=-1
20444570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            or index($Path, "/g++/")!=-1)
20445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
20446570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push_U($DPaths{"Cpp"}, $Path);
20447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not defined $MAIN_CPP_DIR
20448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                or get_depth($MAIN_CPP_DIR)>get_depth($Path)) {
20449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $MAIN_CPP_DIR = $Path;
20450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20452570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            elsif(index($Path, "gcc")!=-1) {
20453570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push_U($DPaths{"Gcc"}, $Path);
20454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
20456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
20457570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if($Path=~/local[\/\\]+include/)
20458570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                { # local paths
20459570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    next;
20460570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
20461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($SystemRoot
20462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                and $Path!~/\A\Q$SystemRoot\E(\/|\Z)/)
20463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # The GCC include path for user headers is not a part of the system root
20464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  # The reason: you are not specified the --cross-gcc option or selected a wrong compiler
20465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  # or it is the internal cross-GCC path like arm-linux-gnueabi/include
20466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
20467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20468570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push_U($DPaths{"Inc"}, $Path);
20469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    unlink("$TMP_DIR/empty.h");
20473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return %DPaths;
20474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_default_paths($)
20477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($HSearch, $LSearch, $BSearch, $GSearch) = (1, 1, 1, 1);
20479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Search = $_[0];
20480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Search!~/inc/) {
20481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $HSearch = 0;
20482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Search!~/lib/) {
20484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $LSearch = 0;
20485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Search!~/bin/) {
20487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $BSearch = 0;
20488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20489ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Search!~/gcc/) {
20490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GSearch = 0;
20491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20492570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(@{$SystemPaths{"include"}})
20493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # <search_headers> section of the XML descriptor
20494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # do NOT search for systems headers
20495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $HSearch = 0;
20496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20497570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(@{$SystemPaths{"lib"}})
20498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # <search_headers> section of the XML descriptor
20499ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # do NOT search for systems headers
20500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $LSearch = 0;
20501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Type (keys(%{$OS_AddPath{$OSgroup}}))
20503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # additional search paths
20504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($Type eq "include" and not $HSearch);
20505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($Type eq "lib" and not $LSearch);
20506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($Type eq "bin" and not $BSearch);
20507570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push_U($SystemPaths{$Type}, grep { -d $_ } @{$OS_AddPath{$OSgroup}{$Type}});
20508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup ne "windows")
20510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # unix-like
20511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Type ("include", "lib", "bin")
20512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # automatic detection of system "devel" directories
20513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if($Type eq "include" and not $HSearch);
20514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if($Type eq "lib" and not $LSearch);
20515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if($Type eq "bin" and not $BSearch);
20516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my ($UsrDir, $RootDir) = ("/usr", "/");
20517ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($SystemRoot and $Type ne "bin")
20518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # 1. search for target headers and libraries
20519ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # 2. use host commands: ldconfig, readelf, etc.
20520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                ($UsrDir, $RootDir) = ("$SystemRoot/usr", $SystemRoot);
20521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20522570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            push_U($SystemPaths{$Type}, cmd_find($RootDir,"d","*$Type*",1));
20523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(-d $RootDir."/".$Type)
20524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # if "/lib" is symbolic link
20525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($RootDir eq "/") {
20526570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    push_U($SystemPaths{$Type}, "/".$Type);
20527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
20529570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    push_U($SystemPaths{$Type}, $RootDir."/".$Type);
20530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20532570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(-d $UsrDir)
20533570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
20534570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push_U($SystemPaths{$Type}, cmd_find($UsrDir,"d","*$Type*",1));
20535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(-d $UsrDir."/".$Type)
20536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # if "/usr/lib" is symbolic link
20537570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    push_U($SystemPaths{$Type}, $UsrDir."/".$Type);
20538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($BSearch)
20543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        detect_bin_default_paths();
20545570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push_U($SystemPaths{"bin"}, @DefaultBinPaths);
20546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # check environment variables
20548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup eq "beos")
20549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
205504b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        foreach (my @Paths = @{$SystemPaths{"bin"}})
20551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
205524b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            if($_ eq ".") {
205534b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                next;
205544b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            }
205554b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            # search for /boot/develop/abi/x86/gcc4/tools/gcc-4.4.4-haiku-101111/bin/
205564b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            if(my @Dirs = sort cmd_find($_, "d", "bin")) {
205574b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                push_U($SystemPaths{"bin"}, sort {get_depth($a)<=>get_depth($b)} @Dirs);
20558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($HSearch)
20561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
20562570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            push_U(\@DefaultIncPaths, grep { is_abs($_) } (
20563570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                split(/:|;/, $ENV{"BEINCLUDES"})
20564570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                ));
20565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LSearch)
20567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
20568570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            push_U(\@DefaultLibPaths, grep { is_abs($_) } (
20569570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                split(/:|;/, $ENV{"BELIBRARIES"}),
20570570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                split(/:|;/, $ENV{"LIBRARY_PATH"})
20571570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                ));
20572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($LSearch)
20575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # using linker to get system paths
20576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $LPaths = detect_lib_default_paths())
20577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # unix-like
20578570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            my %Dirs = ();
20579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Name (keys(%{$LPaths}))
20580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
20581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($SystemRoot
20582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                and $LPaths->{$Name}!~/\A\Q$SystemRoot\E\//)
20583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # wrong ldconfig configuration
20584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  # check your <sysroot>/etc/ld.so.conf
20585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
20586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $DyLib_DefaultPath{$Name} = $LPaths->{$Name};
20588570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if(my $Dir = get_dirname($LPaths->{$Name})) {
20589570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $Dirs{$Dir} = 1;
20590570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
20591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20592570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            push_U(\@DefaultLibPaths, sort {get_depth($a)<=>get_depth($b)} sort keys(%Dirs));
20593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20594570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push_U($SystemPaths{"lib"}, @DefaultLibPaths);
20595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($BSearch)
20597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CrossGcc)
20599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # --cross-gcc=arm-linux-gcc
20600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(-e $CrossGcc)
20601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # absolute or relative path
20602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $GCC_PATH = get_abs_path($CrossGcc);
20603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($CrossGcc!~/\// and get_CmdPath($CrossGcc))
20605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # command name
20606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $GCC_PATH = $CrossGcc;
20607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
20609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Access_Error", "can't access \'$CrossGcc\'");
20610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($GCC_PATH=~/\s/) {
20612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $GCC_PATH = "\"".$GCC_PATH."\"";
20613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($GSearch)
20617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # GCC path and default include dirs
20618570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(not $CrossGcc)
20619570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        { # try default gcc
20620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $GCC_PATH = get_CmdPath("gcc");
20621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2062201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(not $GCC_PATH)
2062301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        { # try to find gcc-X.Y
20624570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            foreach my $Path (@{$SystemPaths{"bin"}})
2062501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            {
206268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if(my @GCCs = cmd_find($Path, "", '/gcc-[0-9.]*\Z', 1, 1))
2062701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                { # select the latest version
2062801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    @GCCs = sort {$b cmp $a} @GCCs;
2062901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    if(check_gcc($GCCs[0], "3"))
2063001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    {
2063101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                        $GCC_PATH = $GCCs[0];
2063201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                        last;
2063301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    }
2063401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                }
2063501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
2063601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
20637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $GCC_PATH) {
20638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find GCC>=3.0 in PATH");
20639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $CheckObjectsOnly_Opt)
20641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
20642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my $GCC_Ver = get_dumpversion($GCC_PATH))
20643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
20644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $GccTarget = get_dumpmachine($GCC_PATH);
20645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                printMsg("INFO", "Using GCC $GCC_Ver ($GccTarget)");
20646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($GccTarget=~/symbian/)
20647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
20648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $OStarget = "symbian";
20649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $LIB_EXT = $OS_LibExt{$LIB_TYPE}{$OStarget};
20650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
20653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Error", "something is going wrong with the GCC compiler");
20654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20656570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if($HSearch)
20657570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
20658570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(not $NoStdInc)
20659570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            { # do NOT search in GCC standard paths
20660570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                my %DPaths = detect_inc_default_paths();
20661570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                @DefaultCppPaths = @{$DPaths{"Cpp"}};
20662570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                @DefaultGccPaths = @{$DPaths{"Gcc"}};
20663570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                @DefaultIncPaths = @{$DPaths{"Inc"}};
20664570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push_U($SystemPaths{"include"}, @DefaultIncPaths);
20665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($HSearch)
20669570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # users include paths
20670dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        my $IncPath = "/usr/include";
20671dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($SystemRoot) {
20672dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $IncPath = $SystemRoot.$IncPath;
20673dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
20674dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if(-d $IncPath) {
20675570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            push_U(\@UsersIncPath, $IncPath);
20676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2067874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2067974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraInfo)
2068074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    {
2068174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        writeFile($ExtraInfo."/default-libs", join("\n", @DefaultLibPaths));
2068274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        writeFile($ExtraInfo."/default-includes", join("\n", (@DefaultCppPaths, @DefaultGccPaths, @DefaultIncPaths)));
2068374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
20684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getLIB_EXT($)
20687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Target = $_[0];
20689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Ext = $OS_LibExt{$LIB_TYPE}{$Target}) {
20690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Ext;
20691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $OS_LibExt{$LIB_TYPE}{"default"};
20693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getAR_EXT($)
20696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Target = $_[0];
20698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Ext = $OS_Archive{$Target}) {
20699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Ext;
20700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $OS_Archive{"default"};
20702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_dumpversion($)
20705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Cmd = $_[0];
20707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Cmd);
20708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Cache{"get_dumpversion"}{$Cmd}) {
20709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"get_dumpversion"}{$Cmd};
20710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20711a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    my $V = `$Cmd -dumpversion 2>\"$TMP_DIR/null\"`;
20712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    chomp($V);
20713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"get_dumpversion"}{$Cmd} = $V);
20714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_dumpmachine($)
20717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Cmd = $_[0];
20719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Cmd);
20720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Cache{"get_dumpmachine"}{$Cmd}) {
20721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"get_dumpmachine"}{$Cmd};
20722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20723a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    my $Machine = `$Cmd -dumpmachine 2>\"$TMP_DIR/null\"`;
20724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    chomp($Machine);
20725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"get_dumpmachine"}{$Cmd} = $Machine);
20726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20728570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub checkCmd($)
20729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Cmd = $_[0];
20731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Cmd);
20732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Options = (
20733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "--version",
20734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "-help"
20735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
20736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Opt (@Options)
20737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20738a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        my $Info = `$Cmd $Opt 2>\"$TMP_DIR/null\"`;
20739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Info) {
20740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
20741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
20744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2074662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub check_gcc($$)
20747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2074862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($Cmd, $ReqVer) = @_;
2074962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return 0 if(not $Cmd or not $ReqVer);
2075062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"check_gcc"}{$Cmd}{$ReqVer}) {
2075162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"check_gcc"}{$Cmd}{$ReqVer};
20752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2075362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $GccVer = get_dumpversion($Cmd))
2075462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
2075562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $GccVer=~s/(-|_)[a-z_]+.*\Z//; # remove suffix (like "-haiku-100818")
2075662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(cmpVersions($GccVer, $ReqVer)>=0) {
2075762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ($Cache{"check_gcc"}{$Cmd}{$ReqVer} = $Cmd);
2075862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2075962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
2076062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return ($Cache{"check_gcc"}{$Cmd}{$ReqVer} = "");
20761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_depth($)
20764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Cache{"get_depth"}{$_[0]}) {
207669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $Cache{"get_depth"}{$_[0]};
20767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"get_depth"}{$_[0]} = ($_[0]=~tr![\/\\]|\:\:!!));
20769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20771570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub registerGccHeaders()
20772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20773570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    return if($Cache{"registerGccHeaders"}); # this function should be called once
20774570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
20775570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Path (@DefaultGccPaths)
20776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20777570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my @Headers = cmd_find($Path,"f");
20778570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        @Headers = sort {get_depth($a)<=>get_depth($b)} @Headers;
20779570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        foreach my $HPath (@Headers)
20780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
20781570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            my $FileName = get_filename($HPath);
20782570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(not defined $DefaultGccHeader{$FileName})
20783570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            { # skip duplicated
20784570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                $DefaultGccHeader{$FileName} = $HPath;
20785570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
20786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20788570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $Cache{"registerGccHeaders"} = 1;
20789570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko}
20790570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
20791570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub registerCppHeaders()
20792570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko{
20793570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    return if($Cache{"registerCppHeaders"}); # this function should be called once
20794570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
20795570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $CppDir (@DefaultCppPaths)
20796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20797570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my @Headers = cmd_find($CppDir,"f");
20798570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        @Headers = sort {get_depth($a)<=>get_depth($b)} @Headers;
20799570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        foreach my $Path (@Headers)
20800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
20801570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            my $FileName = get_filename($Path);
20802570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(not defined $DefaultCppHeader{$FileName})
20803570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            { # skip duplicated
20804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $DefaultCppHeader{$FileName} = $Path;
20805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20808570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $Cache{"registerCppHeaders"} = 1;
20809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub parse_libname($$$)
20812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
208139927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return "" if(not $_[0]);
208149927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(defined $Cache{"parse_libname"}{$_[2]}{$_[1]}{$_[0]}) {
208159927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $Cache{"parse_libname"}{$_[2]}{$_[1]}{$_[0]};
20816dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
208179927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return ($Cache{"parse_libname"}{$_[2]}{$_[1]}{$_[0]} = parse_libname_I(@_));
208189927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko}
208199927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
208209927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub parse_libname_I($$$)
208219927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{
208229927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my ($Name, $Type, $Target) = @_;
20823fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
20824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Target eq "symbian") {
20825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return parse_libname_symbian($Name, $Type);
20826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Target eq "windows") {
20828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return parse_libname_windows($Name, $Type);
20829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20830fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
20831fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    # unix
20832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Ext = getLIB_EXT($Target);
20833a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    if($Name=~/((((lib|).+?)([\-\_][\d\-\.\_]+.*?|))\.$Ext)(\.(.+)|)\Z/)
20834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # libSDL-1.2.so.0.7.1
20835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # libwbxml2.so.0.0.18
20836a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko      # libopcodes-2.21.53-system.20110810.so
20837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type eq "name")
20838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # libSDL-1.2
20839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # libwbxml2
20840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $2;
20841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "name+ext")
20843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # libSDL-1.2.so
20844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # libwbxml2.so
20845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $1;
20846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "version")
20848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
20849a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            if(defined $7
20850a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            and $7 ne "")
20851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # 0.7.1
20852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return $7;
20853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
20855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # libc-2.5.so (=>2.5 version)
20856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $MV = $5;
20857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $MV=~s/\A[\-\_]+//g;
20858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return $MV;
20859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "short")
20862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # libSDL
20863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # libwbxml2
20864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $3;
20865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "shortest")
20867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # SDL
20868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # wbxml
20869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return shortest_name($3);
20870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";# error
20873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub parse_libname_symbian($$)
20876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Name, $Type) = @_;
20878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Ext = getLIB_EXT("symbian");
20879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Name=~/(((.+?)(\{.+\}|))\.$Ext)\Z/)
20880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # libpthread{00010001}.dso
20881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type eq "name")
20882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # libpthread{00010001}
20883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $2;
20884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "name+ext")
20886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # libpthread{00010001}.dso
20887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $1;
20888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "version")
20890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # 00010001
20891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $V = $4;
20892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $V=~s/\{(.+)\}/$1/;
20893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $V;
20894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "short")
20896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # libpthread
20897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $3;
20898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "shortest")
20900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # pthread
20901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return shortest_name($3);
20902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";# error
20905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub parse_libname_windows($$)
20908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Name, $Type) = @_;
20910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Ext = getLIB_EXT("windows");
20911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Name=~/((.+?)\.$Ext)\Z/)
20912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # netapi32.dll
20913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type eq "name")
20914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # netapi32
20915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $2;
20916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "name+ext")
20918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # netapi32.dll
20919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $1;
20920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "version")
20922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # DLL version embedded
20923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # at binary-level
20924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "";
20925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "short")
20927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # netapi32
20928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $2;
20929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "shortest")
20931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # netapi
20932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return shortest_name($2);
20933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";# error
20936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub shortest_name($)
20939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
20941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # remove prefix
20942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Name=~s/\A(lib|open)//;
20943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # remove suffix
20944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Name=~s/[\W\d_]+\Z//i;
20945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Name=~s/([a-z]{2,})(lib)\Z/$1/i;
20946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Name;
20947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub createSymbolsList($$$$$)
20950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($DPath, $SaveTo, $LName, $LVersion, $ArchName) = @_;
20952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    read_ABI_Dump(1, $DPath);
20953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $CheckObjectsOnly) {
209541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        prepareSymbols(1);
20955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %SymbolHeaderLib = ();
20957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Total = 0;
20958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Get List
20959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$CompleteSignature{1}}))
20960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not link_symbol($Symbol, 1, "-Deps"))
209621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # skip src only and all external functions
20963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
20964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
209651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not symbolFilter($Symbol, 1, "Public", "Binary"))
20966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # skip other symbols
20967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
20968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $HeaderName = $CompleteSignature{1}{$Symbol}{"Header"};
20970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $HeaderName)
209711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # skip src only and all external functions
20972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
20973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $DyLib = $Symbol_Library{1}{$Symbol};
20975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $DyLib)
209761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # skip src only and all external functions
20977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
20978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SymbolHeaderLib{$HeaderName}{$DyLib}{$Symbol} = 1;
20980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Total+=1;
20981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Draw List
20983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $SYMBOLS_LIST = "<h1>Public symbols in <span style='color:Blue;'>$LName</span> (<span style='color:Red;'>$LVersion</span>)";
20984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $SYMBOLS_LIST .= " on <span style='color:Blue;'>".showArch($ArchName)."</span><br/>Total: $Total</h1><br/>";
20985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%SymbolHeaderLib))
20986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $DyLib (sort {lc($a) cmp lc($b)} keys(%{$SymbolHeaderLib{$HeaderName}}))
20988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
20989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my %NS_Symbol = ();
20990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Symbol (keys(%{$SymbolHeaderLib{$HeaderName}{$DyLib}})) {
2099174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $NS_Symbol{select_Symbol_NS($Symbol, 1)}{$Symbol} = 1;
20992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $NameSpace (sort keys(%NS_Symbol))
20994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
209951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $SYMBOLS_LIST .= getTitle($HeaderName, $DyLib, $NameSpace);
20996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my @SortedInterfaces = sort {lc(get_Signature($a, 1)) cmp lc(get_Signature($b, 1))} keys(%{$NS_Symbol{$NameSpace}});
20997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Symbol (@SortedInterfaces)
20998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
20999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $SubReport = "";
21000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $Signature = get_Signature($Symbol, 1);
21001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($NameSpace) {
2100262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $Signature=~s/\b\Q$NameSpace\E::\b//g;
21003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
21004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($Symbol=~/\A(_Z|\?)/)
21005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
21006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($Signature) {
210071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey 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");
210089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
21009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        else {
21010ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $SubReport = "<span class='iname'>".$Symbol."</span><br/>\n";
21011ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
21012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
21013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    else
21014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
21015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($Signature) {
21016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $SubReport = "<span class='iname'>".highLight_Signature_Italic_Color($Signature)."</span><br/>\n";
21017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
21018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        else {
21019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $SubReport = "<span class='iname'>".$Symbol."</span><br/>\n";
21020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
21021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
21022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $SYMBOLS_LIST .= $SubReport;
21023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
21024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SYMBOLS_LIST .= "<br/>\n";
21026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2102862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    # clear info
2102962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    (%TypeInfo, %SymbolInfo, %Library_Symbol, %DepSymbol_Library,
2103062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    %DepLibrary_Symbol, %SymVer, %SkipTypes, %SkipSymbols,
2103162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    %NestedNameSpaces, %ClassMethods, %AllocableClass, %ClassNames,
2103262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    %CompleteSignature, %SkipNameSpaces, %Symbol_Library, %Library_Symbol) = ();
21033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ($Content_Counter, $ContentID) = (0, 0);
2103462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    # print report
210351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $CssStyles = readModule("Styles", "SymbolsList.css");
210361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $JScripts = readModule("Scripts", "Sections.js");
210371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $SYMBOLS_LIST = "<a name='Top'></a>".$SYMBOLS_LIST.$TOP_REF."<br/>\n";
21038ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Title = "$LName: public symbols";
21039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Keywords = "$LName, API, symbols";
21040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Description = "List of symbols in $LName ($LVersion) on ".showArch($ArchName);
210411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $SYMBOLS_LIST = composeHTML_Head($Title, $Keywords, $Description, $CssStyles, $JScripts)."
21042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <body><div>\n$SYMBOLS_LIST</div>
210439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    <br/><br/><hr/>\n".getReportFooter($LName, 1)."
21044ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <div style='height:999px;'></div></body></html>";
21045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    writeFile($SaveTo, $SYMBOLS_LIST);
21046ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
210489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub add_target_libs($)
210499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{
210509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    foreach (@{$_[0]}) {
210519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $TargetLibs{$_} = 1;
210529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
210539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko}
210549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
21055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub is_target_lib($)
21056ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21057ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LName = $_[0];
21058a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    if(not $LName) {
21059a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        return 0;
21060a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    }
21061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TargetLibraryName
21062ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $LName!~/\Q$TargetLibraryName\E/) {
21063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
21064ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(keys(%TargetLibs)
21066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and not $TargetLibs{$LName}
21067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and not $TargetLibs{parse_libname($LName, "name+ext", $OStarget)}) {
21068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
21069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1;
21071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21073850437949b65b213696469223d749c1f74c29601Andrey Ponomarenkosub is_target_header($$)
21074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # --header, --headers-list
21075850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my ($H, $V) = @_;
21076850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(keys(%{$TargetHeaders{$V}}))
21077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21078850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($TargetHeaders{$V}{$H}) {
21079850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            return 1;
21080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21082850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return 0;
21083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub checkVersionNum($$)
21086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($LibVersion, $Path) = @_;
21088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $VerNum = $TargetVersion{$LibVersion}) {
21089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $VerNum;
21090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $UsedAltDescr = 0;
21092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Part (split(/\s*,\s*/, $Path))
210931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # try to get version string from file path
210949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        next if(isDump($Part)); # ABI dump
210959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        next if($Part=~/\.(xml|desc)\Z/i); # XML descriptor
2109662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $VerNum = "";
2109762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(parse_libname($Part, "name", $OStarget))
21098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
21099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $UsedAltDescr = 1;
2110062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $VerNum = parse_libname($Part, "version", $OStarget);
2110162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(not $VerNum) {
2110207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                $VerNum = readStrVer($Part);
2110362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2110462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2110562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        elsif(is_header($Part, 2, $LibVersion) or -d $Part)
2110662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
2110762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $UsedAltDescr = 1;
2110807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $VerNum = readStrVer($Part);
2110962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2111062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($VerNum ne "")
2111162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
2111262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $TargetVersion{$LibVersion} = $VerNum;
2111362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($DumpAPI) {
21114570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                printMsg("WARNING", "setting version number to $VerNum (use -vnum option to change it)");
21115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2111662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            else {
21117570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                printMsg("WARNING", "setting ".($LibVersion==1?"1st":"2nd")." version number to \"$VerNum\" (use -v$LibVersion option to change it)");
2111862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2111962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $TargetVersion{$LibVersion};
21120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($UsedAltDescr)
21123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($DumpAPI) {
21125570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            exitStatus("Error", "version number is not set (use -vnum option)");
21126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
21128570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            exitStatus("Error", ($LibVersion==1?"1st":"2nd")." version number is not set (use -v$LibVersion option)");
21129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2113307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenkosub readStrVer($)
21134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Str = $_[0];
21136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Str);
21137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/\Q$TargetLibraryName\E//g;
21138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Str=~/(\/|\\|\w|\A)[\-\_]*(\d+[\d\.\-]+\d+|\d+)/)
211391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # .../libssh-0.4.0/...
21140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $2;
21141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif(my $V = parse_libname($Str, "version", $OStarget)) {
21143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $V;
21144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
21146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub readLibs($)
21149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
21151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OStarget eq "windows")
21152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # dumpbin.exe will crash
21153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # without VS Environment
21154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        check_win32_env();
21155ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
211561693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    readSymbols($LibVersion);
21157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    translateSymbols(keys(%{$Symbol_Library{$LibVersion}}), $LibVersion);
2115862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    translateSymbols(keys(%{$DepSymbol_Library{$LibVersion}}), $LibVersion);
21159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub dump_sorting($)
21162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21163989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    my $Hash = $_[0];
21164989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return [] if(not $Hash);
21165989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    my @Keys = keys(%{$Hash});
21166989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return [] if($#Keys<0);
21167989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($Keys[0]=~/\A\d+\Z/)
21168989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    { # numbers
21169989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        return [sort {int($a)<=>int($b)} @Keys];
21170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21171989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    else
21172989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    { # strings
21173989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        return [sort {$a cmp $b} @Keys];
21174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub printMsg($$)
21178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Type, $Msg) = @_;
21180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type!~/\AINFO/) {
21181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Msg = $Type.": ".$Msg;
21182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type!~/_C\Z/) {
21184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Msg .= "\n";
21185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Quiet)
21187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --quiet option
21188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        appendFile($COMMON_LOG_PATH, $Msg);
21189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
21191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type eq "ERROR") {
21193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            print STDERR $Msg;
21194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
21196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            print $Msg;
21197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub exitStatus($$)
21202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Code, $Msg) = @_;
21204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("ERROR", $Msg);
21205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    exit($ERROR_CODE{$Code});
21206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21208ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub exitReport()
21209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # the tool has run without any errors
21210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printReport();
21211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($COMPILE_ERRORS)
21212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # errors in headers may add false positives/negatives
21213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit($ERROR_CODE{"Compile_Error"});
21214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
212151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($BinaryOnly and $RESULT{"Binary"}{"Problems"})
212161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --binary
212171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        exit($ERROR_CODE{"Incompatible"});
212181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
212191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($SourceOnly and $RESULT{"Source"}{"Problems"})
212201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --source
212211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        exit($ERROR_CODE{"Incompatible"});
212221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
212231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($RESULT{"Source"}{"Problems"}
212241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $RESULT{"Binary"}{"Problems"})
212251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # default
21226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit($ERROR_CODE{"Incompatible"});
21227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
21229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit($ERROR_CODE{"Compatible"});
21230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub readRules($)
21234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Kind = $_[0];
21236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not -f $RULES_PATH{$Kind}) {
21237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Module_Error", "can't access \'".$RULES_PATH{$Kind}."\'");
21238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Content = readFile($RULES_PATH{$Kind});
21240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while(my $Rule = parseTag(\$Content, "rule"))
21241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $RId = parseTag(\$Rule, "id");
21243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Properties = ("Severity", "Change", "Effect", "Overcome", "Kind");
21244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Prop (@Properties) {
21245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my $Value = parseTag(\$Rule, lc($Prop)))
21246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
21247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Value=~s/\n[ ]*//;
21248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $CompatRules{$Kind}{$RId}{$Prop} = $Value;
21249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CompatRules{$Kind}{$RId}{"Kind"}=~/\A(Symbols|Parameters)\Z/) {
21252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CompatRules{$Kind}{$RId}{"Kind"} = "Symbols";
21253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
21255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CompatRules{$Kind}{$RId}{"Kind"} = "Types";
21256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
212601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub getReportPath($)
212611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
212621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
212631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Dir = "compat_reports/$TargetLibraryName/".$Descriptor{1}{"Version"}."_to_".$Descriptor{2}{"Version"};
212641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Level eq "Binary")
212651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
212661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($BinaryReportPath)
212671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --bin-report-path
212681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $BinaryReportPath;
212691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
212701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif($OutputReportPath)
212711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --report-path
212721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $OutputReportPath;
212731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
212741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
212751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # default
212761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Dir."/abi_compat_report.$ReportFormat";
212771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
212781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
212791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($Level eq "Source")
212801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
212811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SourceReportPath)
212821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --src-report-path
212831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $SourceReportPath;
212841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
212851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif($OutputReportPath)
212861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --report-path
212871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $OutputReportPath;
212881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
212891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
212901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # default
212911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Dir."/src_compat_report.$ReportFormat";
212921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
212931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
212941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
212951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
212961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($OutputReportPath)
212971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --report-path
212981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $OutputReportPath;
212991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
213001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
213011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # default
213021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Dir."/compat_report.$ReportFormat";
213031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
213041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
213051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
213061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
213071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub printStatMsg($)
213081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
213091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
213101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    printMsg("INFO", "total \"$Level\" compatibility problems: ".$RESULT{$Level}{"Problems"}.", warnings: ".$RESULT{$Level}{"Warnings"});
213111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
213121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
213131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub listAffected($)
213141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
213151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
213161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $List = "";
213171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach (keys(%{$TotalAffected{$Level}}))
213181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
213191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($StrictCompat and $TotalAffected{$Level}{$_} eq "Low")
213201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # skip "Low"-severity problems
213211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
213221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
213231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $List .= "$_\n";
213241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
213251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Dir = get_dirname(getReportPath($Level));
213261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Level eq "Binary") {
213271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        writeFile($Dir."/abi_affected.txt", $List);
213281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
213291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($Level eq "Source") {
213301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        writeFile($Dir."/src_affected.txt", $List);
213311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
213321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
213331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
21334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub printReport()
21335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("INFO", "creating compatibility report ...");
213371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    createReport();
213381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($JoinReport or $DoubleReport)
213391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
213401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($RESULT{"Binary"}{"Problems"}
213411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or $RESULT{"Source"}{"Problems"}) {
213421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "result: INCOMPATIBLE (Binary: ".$RESULT{"Binary"}{"Affected"}."\%, Source: ".$RESULT{"Source"}{"Affected"}."\%)");
213431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
213441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else {
213451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "result: COMPATIBLE");
213461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
213471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        printStatMsg("Binary");
213481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        printStatMsg("Source");
213491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($ListAffected)
213501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --list-affected
213511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            listAffected("Binary");
213521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            listAffected("Source");
21353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
213551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($BinaryOnly)
213561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
213571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($RESULT{"Binary"}{"Problems"}) {
213581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "result: INCOMPATIBLE (".$RESULT{"Binary"}{"Affected"}."\%)");
213591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
213601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else {
213611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "result: COMPATIBLE");
213621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
213631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        printStatMsg("Binary");
213641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($ListAffected)
213651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --list-affected
213661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            listAffected("Binary");
213671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
21368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
213691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($SourceOnly)
213701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
213711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($RESULT{"Source"}{"Problems"}) {
213721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "result: INCOMPATIBLE (".$RESULT{"Source"}{"Affected"}."\%)");
213731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
213741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else {
213751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "result: COMPATIBLE");
213761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
213771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        printStatMsg("Source");
213781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($ListAffected)
213791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --list-affected
213801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            listAffected("Source");
213811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
21382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
213831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($StdOut)
213841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
213851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($JoinReport or not $DoubleReport)
213860d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # --binary or --source
213871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "compatibility report has been generated to stdout");
213881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
213891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
213901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # default
213911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "compatibility reports have been generated to stdout");
213921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
21393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
213941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
213951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
213961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($JoinReport)
213970d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
213981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "see detailed report:\n  ".getReportPath("Join"));
213991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
214001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif($DoubleReport)
214011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # default
214021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "see detailed reports:\n  ".getReportPath("Binary")."\n  ".getReportPath("Source"));
214031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
214041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif($BinaryOnly)
214051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --binary
214061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "see detailed report:\n  ".getReportPath("Binary"));
214071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
214081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif($SourceOnly)
214091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --source
214101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "see detailed report:\n  ".getReportPath("Source"));
214111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
21412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub check_win32_env()
21416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $ENV{"DevEnvDir"}
21418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or not $ENV{"LIB"}) {
21419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Error", "can't start without VS environment (vsvars32.bat)");
21420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
214235c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenkosub diffSets($$)
214245c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko{
214255c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    my ($S1, $S2) = @_;
214265c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    my @SK1 = keys(%{$S1});
214275c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    my @SK2 = keys(%{$S2});
214285c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if($#SK1!=$#SK2) {
214295c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        return 1;
214305c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
214315c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    foreach my $K1 (@SK1)
214325c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    {
214335c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        if(not defined $S2->{$K1}) {
214345c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            return 1;
214355c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
214365c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
214375c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    return 0;
214385c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko}
214395c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko
21440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub create_ABI_Dump()
21441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not -e $DumpAPI) {
21443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Access_Error", "can't access \'$DumpAPI\'");
21444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @DParts = split(/\s*,\s*/, $DumpAPI);
21446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Part (@DParts)
21447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -e $Part) {
21449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access \'$Part\'");
21450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    checkVersionNum(1, $DumpAPI);
21453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Part (@DParts)
21454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(isDump($Part)) {
21456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            read_ABI_Dump(1, $Part);
21457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
21459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            readDescriptor(1, createDescriptor(1, $Part));
21460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21462fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
21463fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(not $Descriptor{1}{"Version"})
21464fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # set to default: X
21465fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $Descriptor{1}{"Version"} = "X";
21466fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
21467fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
21468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    initLogging(1);
21469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    detect_default_paths("inc|lib|bin|gcc"); # complete analysis
2147074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
214718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $DumpPath = "abi_dumps/$TargetLibraryName/".$TargetLibraryName."_".$Descriptor{1}{"Version"}.".abi";
214728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $DumpPath .= ".".$AR_EXT; # gzipped by default
214738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($OutputDumpPath)
214748f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # user defined path
214758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $DumpPath = $OutputDumpPath;
2147674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
214778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Archive = ($DumpPath=~s/\Q.$AR_EXT\E\Z//g);
214788f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
214798f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(not $Archive and not $StdOut)
214808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # check archive utilities
214818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($OSgroup eq "windows")
214828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # using zip
214838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $ZipCmd = get_CmdPath("zip");
214848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(not $ZipCmd) {
214858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                exitStatus("Not_Found", "can't find \"zip\"");
214868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
2148774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
214888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        else
214898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # using tar and gzip
214908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $TarCmd = get_CmdPath("tar");
214918f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(not $TarCmd) {
214928f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                exitStatus("Not_Found", "can't find \"tar\"");
214938f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
214948f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $GzipCmd = get_CmdPath("gzip");
214958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(not $GzipCmd) {
214968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                exitStatus("Not_Found", "can't find \"gzip\"");
214978f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
2149874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
2149974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
2150074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2150101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(not $Descriptor{1}{"Dump"})
2150201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    {
2150301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(not $CheckHeadersOnly) {
2150401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            readLibs(1);
2150501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
2150601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if($CheckHeadersOnly) {
2150701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            setLanguage(1, "C++");
2150801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
2150901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(not $CheckObjectsOnly) {
2151001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            searchForHeaders(1);
2151101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
2151201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $WORD_SIZE{1} = detectWordSize();
21513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2151401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(not $Descriptor{1}{"Dump"})
2151501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    {
2151601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if($Descriptor{1}{"Headers"}) {
2151701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            readHeaders(1);
2151801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
21519ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21520850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    cleanDump(1);
21521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not keys(%{$SymbolInfo{1}}))
21522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # check if created dump is valid
21523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $ExtendedCheck and not $CheckObjectsOnly)
21524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
21525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CheckHeadersOnly) {
21526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Empty_Set", "the set of public symbols is empty");
21527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
21529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Empty_Intersection", "the sets of public symbols in headers and libraries have empty intersection");
21530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %HeadersInfo = ();
21534fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    foreach my $HPath (keys(%{$Registered_Headers{1}})) {
21535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $HeadersInfo{$Registered_Headers{1}{$HPath}{"Identity"}} = $Registered_Headers{1}{$HPath}{"Pos"};
21536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21537570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($ExtraDump)
21538570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # add unmangled names to the ABI dump
21539570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my @Names = ();
21540570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        foreach my $InfoId (keys(%{$SymbolInfo{1}}))
21541570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
21542570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(my $MnglName = $SymbolInfo{1}{$InfoId}{"MnglName"}) {
21543570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push(@Names, $MnglName);
21544570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
21545570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
21546570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        translateSymbols(@Names, 1);
21547570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        foreach my $InfoId (keys(%{$SymbolInfo{1}}))
21548570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
21549570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(my $MnglName = $SymbolInfo{1}{$InfoId}{"MnglName"})
21550570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
21551570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if(my $Unmangled = $tr_name{$MnglName})
21552570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
21553570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if($MnglName ne $Unmangled) {
21554570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        $SymbolInfo{1}{$InfoId}{"Unmangled"} = $Unmangled;
21555570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
21556570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
21557570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
21558570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
21559570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
21560fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
21561fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my %GccConstants = (); # built-in GCC constants
21562fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    foreach my $Name (keys(%{$Constants{1}}))
21563fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
21564fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(not defined $Constants{1}{$Name}{"Header"})
21565fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
21566fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $GccConstants{$Name} = $Constants{1}{$Name}{"Value"};
21567fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            delete($Constants{1}{$Name});
21568fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
21569fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
21570fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
21571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("INFO", "creating library ABI dump ...");
2157201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my %ABI = (
21573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "TypeInfo" => $TypeInfo{1},
21574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "SymbolInfo" => $SymbolInfo{1},
21575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "Symbols" => $Library_Symbol{1},
2157662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        "DepSymbols" => $DepLibrary_Symbol{1},
21577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "SymbolVersion" => $SymVer{1},
21578ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "LibraryVersion" => $Descriptor{1}{"Version"},
21579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "LibraryName" => $TargetLibraryName,
21580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "Language" => $COMMON_LANGUAGE{1},
21581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "SkipTypes" => $SkipTypes{1},
21582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "SkipSymbols" => $SkipSymbols{1},
21583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "SkipNameSpaces" => $SkipNameSpaces{1},
21584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "SkipHeaders" => $SkipHeadersList{1},
21585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "Headers" => \%HeadersInfo,
21586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "Constants" => $Constants{1},
21587fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        "GccConstants" => \%GccConstants,
21588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "NameSpaces" => $NestedNameSpaces{1},
21589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "Target" => $OStarget,
21590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "Arch" => getArch(1),
21591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "WordSize" => $WORD_SIZE{1},
21592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "GccVersion" => get_dumpversion($GCC_PATH),
21593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "ABI_DUMP_VERSION" => $ABI_DUMP_VERSION,
21594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "ABI_COMPLIANCE_CHECKER_VERSION" => $TOOL_VERSION
21595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
215965c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if(diffSets($TargetHeaders{1}, \%HeadersInfo)) {
2159701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI{"TargetHeaders"} = $TargetHeaders{1};
215985c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
215995c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if($UseXML) {
2160001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI{"XML_ABI_DUMP_VERSION"} = $XML_ABI_DUMP_VERSION;
216015c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
21602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ExtendedCheck)
21603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --ext option
2160401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI{"Mode"} = "Extended";
21605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
216061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($BinaryOnly)
216071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --binary
2160801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI{"BinOnly"} = 1;
216091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
2161074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraDump)
21611fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # --extra-dump
2161274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $ABI{"Extra"} = 1;
21613fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $ABI{"UndefinedSymbols"} = $UndefinedSymbols{1};
21614fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $ABI{"Needed"} = $Library_Needed{1};
2161574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
216165c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko
216175c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    my $ABI_DUMP = "";
216185c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if($UseXML)
216195c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    {
216205c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        loadModule("XmlDump");
2162101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI_DUMP = createXmlDump(\%ABI);
216225c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
216231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
216241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # default
2162501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI_DUMP = Dumper(\%ABI);
216261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
21627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($StdOut)
21628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --stdout option
216295c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        print STDOUT $ABI_DUMP;
21630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        printMsg("INFO", "ABI dump has been generated to stdout");
21631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
21632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
21634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # write to gzipped file
21635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($DDir, $DName) = separate_path($DumpPath);
21636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $DPath = $TMP_DIR."/".$DName;
216375c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        if(not $Archive) {
216385c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            $DPath = $DumpPath;
216395c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
216405c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko
21641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        mkpath($DDir);
21642850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
21643850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        open(DUMP, ">", $DPath) || die ("can't open file \'$DPath\': $!\n");
216445c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        print DUMP $ABI_DUMP;
21645850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        close(DUMP);
21646850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
21647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -s $DPath) {
21648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "can't create ABI dump because something is going wrong with the Data::Dumper module");
21649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2165007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        if($Archive) {
2165107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $DumpPath = createArchive($DPath, $DDir);
216525c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
2165307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
21654ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        if($OutputDumpPath) {
21655ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko            printMsg("INFO", "library ABI has been dumped to:\n  $OutputDumpPath");
21656ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        }
21657ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        else {
216585c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            printMsg("INFO", "library ABI has been dumped to:\n  $DumpPath");
216595c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
21660ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        printMsg("INFO", "you can transfer this dump everywhere and use instead of the ".$Descriptor{1}{"Version"}." version descriptor");
21661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub quickEmptyReports()
21665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # Quick "empty" reports
21666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # 4 times faster than merging equal dumps
21667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # NOTE: the dump contains the "LibraryVersion" attribute
21668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # if you change the version, then your dump will be different
21669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # OVERCOME: use -v1 and v2 options for comparing dumps
21670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # and don't change version in the XML descriptor (and dumps)
21671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # OVERCOME 2: separate meta info from the dumps in ACC 2.0
21672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(-s $Descriptor{1}{"Path"} == -s $Descriptor{2}{"Path"})
21673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $FilePath1 = unpackDump($Descriptor{1}{"Path"});
21675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $FilePath2 = unpackDump($Descriptor{2}{"Path"});
21676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($FilePath1 and $FilePath2)
21677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
2167801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            my $Line = readLineNum($FilePath1, 0);
2167901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if($Line=~/xml/)
2168001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # XML format
2168101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                # is not supported yet
2168201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                return;
2168301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
2168401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
21685850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            local $/ = undef;
21686850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
21687850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            open(DUMP1, $FilePath1);
21688850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            my $Content1 = <DUMP1>;
21689850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            close(DUMP1);
21690850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
21691850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            open(DUMP2, $FilePath2);
21692850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            my $Content2 = <DUMP2>;
21693850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            close(DUMP2);
21694850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
21695850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($Content1 eq $Content2)
21696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
21697850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                # clean memory
21698850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                undef $Content2;
21699850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
21700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                # read a number of headers, libs, symbols and types
21701850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                my $ABIdump = eval($Content1);
21702850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
21703850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                # clean memory
21704850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                undef $Content1;
21705850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
21706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not $ABIdump) {
217079927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    exitStatus("Error", "internal error - eval() procedure seem to not working correctly, try to remove 'use strict' and try again");
21708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
21709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not $ABIdump->{"TypeInfo"})
217101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # support for old dumps
21711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ABIdump->{"TypeInfo"} = $ABIdump->{"TypeDescr"};
21712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
21713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not $ABIdump->{"SymbolInfo"})
217141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # support for old dumps
21715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ABIdump->{"SymbolInfo"} = $ABIdump->{"FuncDescr"};
21716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
21717fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                read_Source_DumpInfo($ABIdump, 1);
21718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                read_Libs_DumpInfo($ABIdump, 1);
21719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                read_Machine_DumpInfo($ABIdump, 1);
21720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                read_Machine_DumpInfo($ABIdump, 2);
217211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
217221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CheckedTypes{"Binary"}} = %{$ABIdump->{"TypeInfo"}};
217231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CheckedTypes{"Source"}} = %{$ABIdump->{"TypeInfo"}};
217241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
217251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CheckedSymbols{"Binary"}} = %{$ABIdump->{"SymbolInfo"}};
217261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CheckedSymbols{"Source"}} = %{$ABIdump->{"SymbolInfo"}};
217271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
21728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Descriptor{1}{"Version"} = $TargetVersion{1}?$TargetVersion{1}:$ABIdump->{"LibraryVersion"};
21729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Descriptor{2}{"Version"} = $TargetVersion{2}?$TargetVersion{2}:$ABIdump->{"LibraryVersion"};
21730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitReport();
21731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub initLogging($)
21737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
21739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # create log directory
21740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($LOG_DIR, $LOG_FILE) = ("logs/$TargetLibraryName/".$Descriptor{$LibVersion}{"Version"}, "log.txt");
21741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OutputLogPath{$LibVersion})
21742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # user-defined by -log-path option
21743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        ($LOG_DIR, $LOG_FILE) = separate_path($OutputLogPath{$LibVersion});
21744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($LogMode ne "n") {
21746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        mkpath($LOG_DIR);
21747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $LOG_PATH{$LibVersion} = get_abs_path($LOG_DIR)."/".$LOG_FILE;
21749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Debug)
21750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # debug directory
21751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $DEBUG_PATH{$LibVersion} = "debug/$TargetLibraryName/".$Descriptor{$LibVersion}{"Version"};
2175274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2175374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(not $ExtraInfo)
2175474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        { # enable --extra-info
2175574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $ExtraInfo = $DEBUG_PATH{$LibVersion}."/extra-info";
2175674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
21757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2175835c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    resetLogging($LibVersion);
21759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub writeLog($$)
21762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($LibVersion, $Msg) = @_;
21764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($LogMode ne "n") {
21765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        appendFile($LOG_PATH{$LibVersion}, $Msg);
21766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub resetLogging($)
21770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
21772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($LogMode!~/a|n/)
21773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # remove old log
21774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        unlink($LOG_PATH{$LibVersion});
2177535c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        if($Debug) {
2177635c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            rmtree($DEBUG_PATH{$LibVersion});
2177735c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        }
21778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub printErrorLog($)
21782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
21784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($LogMode ne "n") {
21785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        printMsg("ERROR", "see log for details:\n  ".$LOG_PATH{$LibVersion}."\n");
21786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isDump($)
21790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21791fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(get_filename($_[0])=~/\A(.+)\.(abi|abidump|dump)(\.tar\.gz|\.zip|\.xml|)(\.\w+|)\Z/) {
217929927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $1;
217939927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
217949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return 0;
217959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko}
217969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
217979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub isDump_U($)
217989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{
21799fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(get_filename($_[0])=~/\A(.+)\.(abi|abidump|dump)(\.xml|)(\.\w+|)\Z/) {
21800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $1;
21801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
21803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
218051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub compareInit()
21806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # read input XML descriptors or ABI dumps
21808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Descriptor{1}{"Path"}) {
218090d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        exitStatus("Error", "-old option is not specified");
21810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @DParts1 = split(/\s*,\s*/, $Descriptor{1}{"Path"});
21812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Part (@DParts1)
21813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -e $Part) {
21815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access \'$Part\'");
21816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Descriptor{2}{"Path"}) {
218190d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        exitStatus("Error", "-new option is not specified");
21820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @DParts2 = split(/\s*,\s*/, $Descriptor{2}{"Path"});
21822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Part (@DParts2)
21823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -e $Part) {
21825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access \'$Part\'");
21826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    detect_default_paths("bin"); # to extract dumps
21829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($#DParts1==0 and $#DParts2==0
21830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and isDump($Descriptor{1}{"Path"})
21831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and isDump($Descriptor{2}{"Path"}))
21832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # optimization: equal ABI dumps
21833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        quickEmptyReports();
21834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    checkVersionNum(1, $Descriptor{1}{"Path"});
21836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    checkVersionNum(2, $Descriptor{2}{"Path"});
21837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("INFO", "preparation, please wait ...");
21838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Part (@DParts1)
21839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(isDump($Part)) {
21841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            read_ABI_Dump(1, $Part);
21842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
21844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            readDescriptor(1, createDescriptor(1, $Part));
21845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Part (@DParts2)
21848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(isDump($Part)) {
21850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            read_ABI_Dump(2, $Part);
21851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
21853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            readDescriptor(2, createDescriptor(2, $Part));
21854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21856fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
21857fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(not $Descriptor{1}{"Version"})
21858fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # set to default: X
21859fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $Descriptor{1}{"Version"} = "X";
21860fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
21861fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
21862fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(not $Descriptor{2}{"Version"})
21863fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # set to default: Y
21864fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $Descriptor{2}{"Version"} = "Y";
21865fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
21866fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
21867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    initLogging(1);
21868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    initLogging(2);
21869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # check consistency
21870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Descriptor{1}{"Headers"}
21871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and not $Descriptor{1}{"Libs"}) {
21872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Error", "descriptor d1 does not contain both header files and libraries info");
21873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Descriptor{2}{"Headers"}
21875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and not $Descriptor{2}{"Libs"}) {
21876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Error", "descriptor d2 does not contain both header files and libraries info");
21877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Descriptor{1}{"Headers"} and not $Descriptor{1}{"Libs"}
21879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and not $Descriptor{2}{"Headers"} and $Descriptor{2}{"Libs"}) {
21880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Error", "can't compare headers with $SLIB_TYPE libraries");
21881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif(not $Descriptor{1}{"Headers"} and $Descriptor{1}{"Libs"}
21883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Descriptor{2}{"Headers"} and not $Descriptor{2}{"Libs"}) {
21884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Error", "can't compare $SLIB_TYPE libraries with headers");
21885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21886bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko    if(not $Descriptor{1}{"Headers"})
21887bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko    {
21888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CheckHeadersOnly_Opt) {
21889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "can't find header files info in descriptor d1");
21890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21892bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko    if(not $Descriptor{2}{"Headers"})
21893bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko    {
21894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CheckHeadersOnly_Opt) {
21895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "can't find header files info in descriptor d2");
21896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Descriptor{1}{"Headers"}
21899bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko    or not $Descriptor{2}{"Headers"})
21900bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko    {
21901bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko        if(not $CheckObjectsOnly_Opt)
21902bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko        {
21903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            printMsg("WARNING", "comparing $SLIB_TYPE libraries only");
21904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CheckObjectsOnly = 1;
21905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21907bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko    if(not $Descriptor{1}{"Libs"})
21908bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko    {
21909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CheckObjectsOnly_Opt) {
21910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "can't find $SLIB_TYPE libraries info in descriptor d1");
21911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21913bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko    if(not $Descriptor{2}{"Libs"})
21914bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko    {
21915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CheckObjectsOnly_Opt) {
21916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "can't find $SLIB_TYPE libraries info in descriptor d2");
21917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Descriptor{1}{"Libs"}
21920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or not $Descriptor{2}{"Libs"})
21921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # comparing standalone header files
21922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # comparing ABI dumps created with --headers-only
21923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $CheckHeadersOnly_Opt)
21924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
21925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            printMsg("WARNING", "checking headers only");
21926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CheckHeadersOnly = 1;
21927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($UseDumps)
21930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --use-dumps
21931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # parallel processing
2193274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my $DumpPath1 = "abi_dumps/$TargetLibraryName/".$TargetLibraryName."_".$Descriptor{1}{"Version"}.".abi.$AR_EXT";
2193374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my $DumpPath2 = "abi_dumps/$TargetLibraryName/".$TargetLibraryName."_".$Descriptor{2}{"Version"}.".abi.$AR_EXT";
2193474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2193574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        unlink($DumpPath1);
2193674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        unlink($DumpPath2);
2193774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
21938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $pid = fork();
21939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($pid)
21940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # dump on two CPU cores
21941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my @PARAMS = ("-dump", $Descriptor{1}{"Path"}, "-l", $TargetLibraryName);
21942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($RelativeDirectory{1}) {
21943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-relpath", $RelativeDirectory{1});
21944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($OutputLogPath{1}) {
21946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-log-path", $OutputLogPath{1});
21947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CrossGcc) {
21949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-cross-gcc", $CrossGcc);
21950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21951dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if($Quiet)
21952dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
21953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-quiet");
21954dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                @PARAMS = (@PARAMS, "-logging-mode", "a");
21955dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
21956dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            elsif($LogMode and $LogMode ne "w")
21957dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            { # "w" is default
21958dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                @PARAMS = (@PARAMS, "-logging-mode", $LogMode);
21959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ExtendedCheck) {
21961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-extended");
21962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($UserLang) {
21964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-lang", $UserLang);
21965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($TargetVersion{1}) {
21967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-vnum", $TargetVersion{1});
21968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21969850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($BinaryOnly) {
21970850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                @PARAMS = (@PARAMS, "-binary");
21971850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
21972850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($SourceOnly) {
21973850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                @PARAMS = (@PARAMS, "-source");
21974850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
2197562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($SortDump) {
2197662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                @PARAMS = (@PARAMS, "-sort");
2197762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2197801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if($DumpFormat and $DumpFormat ne "perl") {
2197901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                @PARAMS = (@PARAMS, "-dump-format", $DumpFormat);
2198001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
21981f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($CheckHeadersOnly) {
21982f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                @PARAMS = (@PARAMS, "-headers-only");
21983f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
21984f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($CheckObjectsOnly) {
21985f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                @PARAMS = (@PARAMS, "-objects-only");
21986f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
21987850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($Debug)
21988850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
21989850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                @PARAMS = (@PARAMS, "-debug");
2199062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                printMsg("INFO", "running perl $0 @PARAMS");
21991850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
21992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            system("perl", $0, @PARAMS);
2199374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(not -f $DumpPath1) {
21994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exit(1);
21995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
21998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # child
21999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my @PARAMS = ("-dump", $Descriptor{2}{"Path"}, "-l", $TargetLibraryName);
22000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($RelativeDirectory{2}) {
22001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-relpath", $RelativeDirectory{2});
22002ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($OutputLogPath{2}) {
22004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-log-path", $OutputLogPath{2});
22005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CrossGcc) {
22007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-cross-gcc", $CrossGcc);
22008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22009dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if($Quiet)
22010dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
22011ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-quiet");
22012dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                @PARAMS = (@PARAMS, "-logging-mode", "a");
22013dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
22014dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            elsif($LogMode and $LogMode ne "w")
22015dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            { # "w" is default
22016dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                @PARAMS = (@PARAMS, "-logging-mode", $LogMode);
22017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ExtendedCheck) {
22019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-extended");
22020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($UserLang) {
22022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-lang", $UserLang);
22023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($TargetVersion{2}) {
22025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-vnum", $TargetVersion{2});
22026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22027850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($BinaryOnly) {
22028850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                @PARAMS = (@PARAMS, "-binary");
22029850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
22030850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($SourceOnly) {
22031850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                @PARAMS = (@PARAMS, "-source");
22032850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
2203362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($SortDump) {
2203462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                @PARAMS = (@PARAMS, "-sort");
2203562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2203601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if($DumpFormat and $DumpFormat ne "perl") {
2203701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                @PARAMS = (@PARAMS, "-dump-format", $DumpFormat);
2203801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
22039f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($CheckHeadersOnly) {
22040f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                @PARAMS = (@PARAMS, "-headers-only");
22041f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
22042f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($CheckObjectsOnly) {
22043f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                @PARAMS = (@PARAMS, "-objects-only");
22044f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
22045850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($Debug)
22046850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
22047850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                @PARAMS = (@PARAMS, "-debug");
2204862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                printMsg("INFO", "running perl $0 @PARAMS");
22049850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
22050ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            system("perl", $0, @PARAMS);
2205174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(not -f $DumpPath2) {
22052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exit(1);
22053ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22054ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
22055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exit(0);
22056ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22057ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        waitpid($pid, 0);
22059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @CMP_PARAMS = ("-l", $TargetLibraryName);
2206074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        @CMP_PARAMS = (@CMP_PARAMS, "-d1", $DumpPath1);
2206174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        @CMP_PARAMS = (@CMP_PARAMS, "-d2", $DumpPath2);
22062ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($TargetLibraryFName ne $TargetLibraryName) {
22063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-l-full", $TargetLibraryFName);
22064ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($ShowRetVal) {
22066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-show-retval");
22067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CrossGcc) {
22069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-cross-gcc", $CrossGcc);
22070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2207135c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        @CMP_PARAMS = (@CMP_PARAMS, "-logging-mode", "a");
2207235c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        if($Quiet) {
22073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-quiet");
22074dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
22075dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($ReportFormat and $ReportFormat ne "html")
22076dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        { # HTML is default format
22077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-report-format", $ReportFormat);
22078ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
220791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($OutputReportPath) {
220801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-report-path", $OutputReportPath);
220811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
220821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($BinaryReportPath) {
220831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-bin-report-path", $BinaryReportPath);
220841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
220851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SourceReportPath) {
220861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-src-report-path", $SourceReportPath);
220871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
220881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($LoggingPath) {
220891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-log-path", $LoggingPath);
220901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
22091f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($CheckHeadersOnly) {
22092f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-headers-only");
22093f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
22094f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($CheckObjectsOnly) {
22095f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-objects-only");
22096f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
22097f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($BinaryOnly) {
22098f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-binary");
22099f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
22100f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($SourceOnly) {
22101f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-source");
22102f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
22103850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Browse) {
22104850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-browse", $Browse);
22105850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
2210662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($OpenReport) {
2210762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-open");
2210862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2210962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Debug)
2211062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
2211162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-debug");
2211262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            printMsg("INFO", "running perl $0 @CMP_PARAMS");
22113850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
22114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        system("perl", $0, @CMP_PARAMS);
22115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit($?>>8);
22116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Descriptor{1}{"Dump"}
22118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or not $Descriptor{2}{"Dump"})
22119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # need GCC toolchain to analyze
22120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # header files and libraries
22121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        detect_default_paths("inc|lib|gcc");
22122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Descriptor{1}{"Dump"})
22124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $CheckHeadersOnly) {
22126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            readLibs(1);
22127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CheckHeadersOnly) {
22129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            setLanguage(1, "C++");
22130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22131850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(not $CheckObjectsOnly) {
22132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            searchForHeaders(1);
22133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $WORD_SIZE{1} = detectWordSize();
22135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Descriptor{2}{"Dump"})
22137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $CheckHeadersOnly) {
22139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            readLibs(2);
22140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CheckHeadersOnly) {
22142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            setLanguage(2, "C++");
22143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22144850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(not $CheckObjectsOnly) {
22145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            searchForHeaders(2);
22146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $WORD_SIZE{2} = detectWordSize();
22148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($WORD_SIZE{1} ne $WORD_SIZE{2})
22150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
22151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # try to synch different WORD sizes
2215262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not checkDump(1, "2.1"))
22153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
22154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $WORD_SIZE{1} = $WORD_SIZE{2};
22155ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            printMsg("WARNING", "set WORD size to ".$WORD_SIZE{2}." bytes");
22156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2215762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        elsif(not checkDump(2, "2.1"))
22158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
22159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $WORD_SIZE{2} = $WORD_SIZE{1};
22160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            printMsg("WARNING", "set WORD size to ".$WORD_SIZE{1}." bytes");
22161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif(not $WORD_SIZE{1}
22164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and not $WORD_SIZE{2})
22165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
2216662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $WORD_SIZE{1} = "4";
2216762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $WORD_SIZE{2} = "4";
22168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Descriptor{1}{"Dump"})
22170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
22171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        prepareTypes(1);
22172ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22173ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Descriptor{2}{"Dump"})
22174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
22175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        prepareTypes(2);
22176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($AppPath and not keys(%{$Symbol_Library{1}})) {
22178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        printMsg("WARNING", "the application ".get_filename($AppPath)." has no symbols imported from the $SLIB_TYPE libraries");
22179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # started to process input data
22181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $CheckObjectsOnly)
22182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Descriptor{1}{"Headers"}
22184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and not $Descriptor{1}{"Dump"}) {
22185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            readHeaders(1);
22186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Descriptor{2}{"Headers"}
22188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and not $Descriptor{2}{"Dump"}) {
22189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            readHeaders(2);
22190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22192850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
22193850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
22194850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %SystemHeaders = ();
22195850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %mangled_name_gcc = ();
22196850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
221971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    prepareSymbols(1);
221981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    prepareSymbols(2);
221991693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
22200850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
222011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    %SymbolInfo = ();
222021693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
222031693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    # Virtual Tables
222041693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    registerVTable(1);
222051693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    registerVTable(2);
222061693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
2220762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not checkDump(1, "1.22")
2220862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and checkDump(2, "1.22"))
222091693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # support for old ABI dumps
222101693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        foreach my $ClassName (keys(%{$VirtualTable{2}}))
222111693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
222121693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if($ClassName=~/</)
222131693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            { # templates
222141693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                if(not defined $VirtualTable{1}{$ClassName})
222151693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                { # synchronize
222161693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    delete($VirtualTable{2}{$ClassName});
222171693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                }
222181693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
222191693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
222201693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
222211693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
222221693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    registerOverriding(1);
222231693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    registerOverriding(2);
222241693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
222251693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    setVirtFuncPositions(1);
222261693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    setVirtFuncPositions(2);
222271693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
222281693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    # Other
222291693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    addParamNames(1);
222301693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    addParamNames(2);
222311693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
222321693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    detectChangedTypedefs();
222331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
222341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
222351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub compareAPIs($)
222361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
222371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
222381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    readRules($Level);
22239f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    loadModule("CallConv");
222401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Level eq "Binary") {
222411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        printMsg("INFO", "comparing ABIs ...");
222421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
222431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else {
222441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        printMsg("INFO", "comparing APIs ...");
222451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
222461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($CheckHeadersOnly
222471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $Level eq "Source")
22248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # added/removed in headers
222491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        detectAdded_H($Level);
222501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        detectRemoved_H($Level);
22251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
222531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # added/removed in libs
222541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        detectAdded($Level);
222551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        detectRemoved($Level);
222561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
222571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(not $CheckObjectsOnly)
22258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
222598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        mergeSymbols($Level);
222601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(keys(%{$CheckedSymbols{$Level}})) {
222611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            mergeConstants($Level);
222621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
222631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
222641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($CheckHeadersOnly
222651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $Level eq "Source")
222661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # added/removed in headers
222671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        mergeHeaders($Level);
222681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
222691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
222701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # added/removed in libs
222711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        mergeLibs($Level);
222721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CheckImpl
222731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        and $Level eq "Binary") {
22274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            mergeImpl();
22275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
22278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
222799927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub getSysOpts()
22280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
22281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %Opts = (
22282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "OStarget"=>$OStarget,
22283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Debug"=>$Debug,
22284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Quiet"=>$Quiet,
22285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "LogMode"=>$LogMode,
22286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "CheckHeadersOnly"=>$CheckHeadersOnly,
22287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
22288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "SystemRoot"=>$SystemRoot,
22289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "MODULES_DIR"=>$MODULES_DIR,
22290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "GCC_PATH"=>$GCC_PATH,
22291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "TargetSysInfo"=>$TargetSysInfo,
22292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "CrossPrefix"=>$CrossPrefix,
22293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "TargetLibraryName"=>$TargetLibraryName,
22294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "CrossGcc"=>$CrossGcc,
22295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "UseStaticLibs"=>$UseStaticLibs,
222969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "NoStdInc"=>$NoStdInc,
222979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
222989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "BinaryOnly" => $BinaryOnly,
222999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "SourceOnly" => $SourceOnly
22300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
22301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return \%Opts;
22302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
22303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2230474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkosub get_CodeError($)
22305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
22306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %CODE_ERROR = reverse(%ERROR_CODE);
22307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $CODE_ERROR{$_[0]};
22308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
22309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
22310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub scenario()
22311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
22312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($StdOut)
22313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # enable quiet mode
22314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Quiet = 1;
223151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $JoinReport = 1;
22316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22317dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if(not $LogMode)
22318dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    { # default
22319dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        $LogMode = "w";
22320dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
22321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($UserLang)
22322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --lang=C++
22323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $UserLang = uc($UserLang);
22324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $COMMON_LANGUAGE{1}=$UserLang;
22325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $COMMON_LANGUAGE{2}=$UserLang;
22326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($LoggingPath)
22328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $OutputLogPath{1} = $LoggingPath;
22330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $OutputLogPath{2} = $LoggingPath;
22331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Quiet) {
22332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $COMMON_LOG_PATH = $LoggingPath;
22333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22335e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    if($Quick) {
22336e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        $ADD_TMPL_INSTANCES = 0;
22337e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    }
223385c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if($OutputDumpPath)
223395c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    { # validate
2234074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(not isDump($OutputDumpPath)) {
223415c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            exitStatus("Error", "the dump path should be a path to *.abi.$AR_EXT or *.abi file");
223425c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
223435c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
223441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($BinaryOnly and $SourceOnly)
223451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # both --binary and --source
223461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      # is the default mode
223471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $DoubleReport = 1;
223481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $JoinReport = 0;
223491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $BinaryOnly = 0;
223501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SourceOnly = 0;
223511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($OutputReportPath)
223521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --report-path
223531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $DoubleReport = 0;
223541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $JoinReport = 1;
223551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
223561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
223571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($BinaryOnly or $SourceOnly)
223581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --binary or --source
223591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $DoubleReport = 0;
223601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $JoinReport = 0;
223611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
223621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($UseXML)
223631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --xml option
223641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $ReportFormat = "xml";
223655c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $DumpFormat = "xml";
223661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
22367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat)
22368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # validate
223691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $ReportFormat = lc($ReportFormat);
223701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($ReportFormat!~/\A(xml|html|htm)\Z/) {
223715c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            exitStatus("Error", "unknown report format \'$ReportFormat\'");
22372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
223731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($ReportFormat eq "htm")
223741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # HTM == HTML
223751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $ReportFormat = "html";
223761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
223771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif($ReportFormat eq "xml")
223781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --report-format=XML equal to --xml
223791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $UseXML = 1;
223801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
22381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
22383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # default: HTML
22384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ReportFormat = "html";
22385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
223865c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if($DumpFormat)
223875c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    { # validate
223885c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $DumpFormat = lc($DumpFormat);
223895c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        if($DumpFormat!~/\A(xml|perl)\Z/) {
223905c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            exitStatus("Error", "unknown ABI dump format \'$DumpFormat\'");
223915c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
223925c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        if($DumpFormat eq "xml")
223935c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        { # --dump-format=XML equal to --xml
223945c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            $UseXML = 1;
223955c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
223965c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
223975c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    else
2239801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    { # default: Perl Data::Dumper
223995c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $DumpFormat = "perl";
224005c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
22401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Quiet and $LogMode!~/a|n/)
22402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --quiet log
22403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-f $COMMON_LOG_PATH) {
22404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            unlink($COMMON_LOG_PATH);
22405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
224074b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    if($ExtraInfo) {
22408570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        $CheckUndefined = 1;
22409570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
22410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TestTool and $UseDumps)
22411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --test && --use-dumps == --test-dump
22412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestDump = 1;
22413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
224148f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($Tolerant)
224158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # enable all
224168f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Tolerance = 1234;
224178f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
22418570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($Help)
22419570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
22420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        HELP_MESSAGE();
22421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit(0);
22422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($InfoMsg) {
22424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        INFO_MESSAGE();
22425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit(0);
22426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22427570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($ShowVersion)
22428570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
22429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey 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.");
22430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit(0);
22431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22432570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($DumpVersion)
22433570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
22434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        printMsg("INFO", $TOOL_VERSION);
22435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit(0);
22436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ExtendedCheck) {
22438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $CheckHeadersOnly = 1;
22439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SystemRoot_Opt)
22441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # user defined root
22442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -e $SystemRoot_Opt) {
22443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access \'$SystemRoot\'");
22444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SystemRoot = $SystemRoot_Opt;
22446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SystemRoot=~s/[\/]+\Z//g;
22447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SystemRoot) {
22448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SystemRoot = get_abs_path($SystemRoot);
22449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Data::Dumper::Sortkeys = 1;
22452989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko
2245362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($SortDump)
2245462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
2245562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $Data::Dumper::Useperl = 1;
2245662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $Data::Dumper::Sortkeys = \&dump_sorting;
2245762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
22458989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko
22459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TargetLibsPath)
22460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -f $TargetLibsPath) {
22462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$TargetLibsPath\'");
22463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Lib (split(/\s*\n\s*/, readFile($TargetLibsPath))) {
22465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TargetLibs{$Lib} = 1;
22466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TargetHeadersPath)
22469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --headers-list
22470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -f $TargetHeadersPath) {
22471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$TargetHeadersPath\'");
22472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Header (split(/\s*\n\s*/, readFile($TargetHeadersPath)))
22474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
22475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TargetHeaders{1}{$Header} = 1;
22476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TargetHeaders{2}{$Header} = 1;
22477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TargetHeader)
22480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --header
22481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TargetHeaders{1}{$TargetHeader} = 1;
22482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TargetHeaders{2}{$TargetHeader} = 1;
22483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TestTool
22485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $TestDump)
22486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --test, --test-dump
22487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        detect_default_paths("bin|gcc"); # to compile libs
22488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        loadModule("RegTests");
22489f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        testTool($TestDump, $Debug, $Quiet, $ExtendedCheck, $LogMode, $ReportFormat, $DumpFormat,
22490f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        $LIB_EXT, $GCC_PATH, $Browse, $OpenReport, $SortDump, $CheckHeadersOnly, $CheckObjectsOnly);
22491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit(0);
22492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($DumpSystem)
22494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --dump-system
22495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        loadModule("SysCheck");
224969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($DumpSystem=~/\.(xml|desc)\Z/)
22497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # system XML descriptor
22498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not -f $DumpSystem) {
22499ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Access_Error", "can't access file \'$DumpSystem\'");
22500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Ret = readSystemDescriptor(readFile($DumpSystem));
225029927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            foreach (@{$Ret->{"Tools"}})
225039927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
22504570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push_U($SystemPaths{"bin"}, $_);
22505570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                $TargetTools{$_} = 1;
22506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Ret->{"CrossPrefix"}) {
22508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $CrossPrefix = $Ret->{"CrossPrefix"};
22509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($SystemRoot_Opt)
22512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # -sysroot "/" option
22513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # default target: /usr/lib, /usr/include
22514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # search libs: /usr/lib and /lib
22515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not -e $SystemRoot."/usr/lib") {
22516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Access_Error", "can't access '".$SystemRoot."/usr/lib'");
22517ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not -e $SystemRoot."/lib") {
22519ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Access_Error", "can't access '".$SystemRoot."/lib'");
22520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not -e $SystemRoot."/usr/include") {
22522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Access_Error", "can't access '".$SystemRoot."/usr/include'");
22523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            readSystemDescriptor("
22525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <name>
22526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $DumpSystem
22527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </name>
22528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <headers>
22529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $SystemRoot/usr/include
22530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </headers>
22531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <libs>
22532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $SystemRoot/usr/lib
22533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </libs>
22534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <search_libs>
22535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $SystemRoot/lib
22536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </search_libs>");
22537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
22539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "-sysroot <dirpath> option should be specified, usually it's \"/\"");
22540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        detect_default_paths("bin|gcc"); # to check symbols
22542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($OStarget eq "windows")
22543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # to run dumpbin.exe
22544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # and undname.exe
22545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            check_win32_env();
22546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
225479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        dumpSystem(getSysOpts());
22548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit(0);
22549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($CmpSystems)
22551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --cmp-systems
22552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        detect_default_paths("bin"); # to extract dumps
22553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        loadModule("SysCheck");
225549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        cmpSystems($Descriptor{1}{"Path"}, $Descriptor{2}{"Path"}, getSysOpts());
22555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit(0);
22556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22557570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($GenerateTemplate)
22558570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
22559570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        writeFile("VERSION.xml", $DescriptorTemplate."\n");
22560570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        printMsg("INFO", "XML-descriptor template ./VERSION.xml has been generated");
22561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit(0);
22562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $TargetLibraryName) {
22564570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        exitStatus("Error", "library name is not selected (-l option)");
22565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
22567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # validate library name
22568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($TargetLibraryName=~/[\*\/\\]/) {
22569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "\"\\\", \"\/\" and \"*\" symbols are not allowed in the library name");
22570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $TargetLibraryFName) {
22573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TargetLibraryFName = $TargetLibraryName;
22574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($CheckHeadersOnly_Opt and $CheckObjectsOnly_Opt) {
22576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Error", "you can't specify both -headers-only and -objects-only options at the same time");
22577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22578ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolsListPath)
22579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -f $SymbolsListPath) {
22581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$SymbolsListPath\'");
22582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Interface (split(/\s*\n\s*/, readFile($SymbolsListPath))) {
22584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SymbolsList{$Interface} = 1;
22585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22587fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($SkipSymbolsListPath)
22588fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
22589fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(not -f $SkipSymbolsListPath) {
22590fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$SkipSymbolsListPath\'");
22591fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
22592fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        foreach my $Interface (split(/\s*\n\s*/, readFile($SkipSymbolsListPath))) {
22593fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $SkipSymbolsList{$Interface} = 1;
22594fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
22595fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
22596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SkipHeadersPath)
22597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -f $SkipHeadersPath) {
22599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$SkipHeadersPath\'");
22600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Path (split(/\s*\n\s*/, readFile($SkipHeadersPath)))
226021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # register for both versions
226031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $SkipHeadersList{1}{$Path} = 1;
226041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $SkipHeadersList{2}{$Path} = 1;
22605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my ($CPath, $Type) = classifyPath($Path);
22606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SkipHeaders{1}{$Type}{$CPath} = 1;
22607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SkipHeaders{2}{$Type}{$CPath} = 1;
22608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ParamNamesPath)
22611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -f $ParamNamesPath) {
22613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$ParamNamesPath\'");
22614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Line (split(/\n/, readFile($ParamNamesPath)))
22616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
22617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Line=~s/\A(\w+)\;//)
22618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
22619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Interface = $1;
2262062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($Line=~/;(\d+);/)
2262162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
22622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    while($Line=~s/(\d+);(\w+)//) {
22623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $AddIntParams{$Interface}{$1}=$2;
22624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
22625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
2262662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                else
2262762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
22628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $Num = 0;
22629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    foreach my $Name (split(/;/, $Line)) {
22630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $AddIntParams{$Interface}{$Num++}=$Name;
22631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
22632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
22633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($AppPath)
22637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -f $AppPath) {
22639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$AppPath\'");
22640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
226411693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        foreach my $Interface (readSymbols_App($AppPath)) {
22642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SymbolsList_App{$Interface} = 1;
22643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($DumpAPI)
22646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --dump-abi
22647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # make an API dump
22648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        create_ABI_Dump();
22649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit($COMPILE_ERRORS);
22650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # default: compare APIs
22652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #  -d1 <path>
22653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #  -d2 <path>
226541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    compareInit();
226551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($JoinReport or $DoubleReport)
226561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
226571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        compareAPIs("Binary");
226581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        compareAPIs("Source");
226591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
226601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($BinaryOnly) {
226611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        compareAPIs("Binary");
226621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
226631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($SourceOnly) {
226641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        compareAPIs("Source");
226651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
22666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    exitReport();
22667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
22668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
22669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkoscenario();
22670