[
  {
    "path": ".github/FUNDING.yml",
    "content": "# These are supported funding model platforms\n\npatreon: LINUXABI\ncustom: https://abi-laboratory.pro/?view=donate\n"
  },
  {
    "path": "Dockerfile",
    "content": "FROM ubuntu\nRUN apt update && \\\n    apt install -y git perl-base binutils automake autoconf \\\n        libtool pkg-config elfutils libelf-dev && \\\n    git clone https://github.com/universal-ctags/ctags && cd ctags && \\\n        ./autogen.sh && ./configure && make install && cd .. && \\\n    git clone https://github.com/lvc/vtable-dumper && cd vtable-dumper && \\\n        make install && cd .. && \\\n    git clone https://github.com/lvc/abi-dumper && cd abi-dumper && \\\n        make install && cd .. && \\\n    rm -rf ctags vtable-dumper abi-dumper\n"
  },
  {
    "path": "INSTALL",
    "content": "\nCopyright (C) 2013-2025 Andrey Ponomarenko's ABI Laboratory\nAll rights reserved.\n\n\nRELEASE INFORMATION\n\nProject:           ABI Dumper\nVersion:           1.4\nDate:              Jan 11, 2025\n\n\nThis file explains how to install and setup environment\nfor the tool in your computer.\n\n\nContent:\n\n   1. Requirements for Linux and FreeBSD\n   2. Configure and Install\n   3. Usage\n\n\n1. REQUIREMENTS FOR LINUX AND FREEBSD\n=====================================\n\n   1. Perl 5 (5.8 or newer)\n   2. Elfutils (eu-readelf)\n   3. Vtable-Dumper (1.1 or newer)\n   4. Binutils (objdump)\n   5. Universal Ctags\n\n\n\n2. CONFIGURE AND INSTALL\n========================\n\n   This command will install an abi-dumper program in the\n   PREFIX/bin system directory:\n\n     sudo make install prefix=PREFIX [/usr, /usr/local, ...]\n\n2.1 Remove\n\n     sudo make uninstall prefix=PREFIX\n\n\n\n3. USAGE\n========\n\n   Dump ABI of a library:\n   \n     abi-dumper libTest.so -o ABI.dump\n     \n   Dump ABI of a kernel module:\n   \n     abi-dumper Module.ko.debug -o ABI.dump\n\n   For advanced usage, see output of --help option\n\n\n\nEnjoy!\n"
  },
  {
    "path": "LICENSE",
    "content": "                  GNU LESSER GENERAL PUBLIC LICENSE\n                       Version 2.1, February 1999\n\n Copyright (C) 1991, 1999 Free Software Foundation, Inc.\n 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n[This is the first released version of the Lesser GPL.  It also counts\n as the successor of the GNU Library Public License, version 2, hence\n the version number 2.1.]\n\n                            Preamble\n\n  The licenses for most software are designed to take away your\nfreedom to share and change it.  By contrast, the GNU General Public\nLicenses are intended to guarantee your freedom to share and change\nfree software--to make sure the software is free for all its users.\n\n  This license, the Lesser General Public License, applies to some\nspecially designated software packages--typically libraries--of the\nFree Software Foundation and other authors who decide to use it.  You\ncan use it too, but we suggest you first think carefully about whether\nthis license or the ordinary General Public License is the better\nstrategy to use in any particular case, based on the explanations below.\n\n  When we speak of free software, we are referring to freedom of use,\nnot price.  Our General Public Licenses are designed to make sure that\nyou have the freedom to distribute copies of free software (and charge\nfor this service if you wish); that you receive source code or can get\nit if you want it; that you can change the software and use pieces of\nit in new free programs; and that you are informed that you can do\nthese things.\n\n  To protect your rights, we need to make restrictions that forbid\ndistributors to deny you these rights or to ask you to surrender these\nrights.  These restrictions translate to certain responsibilities for\nyou if you distribute copies of the library or if you modify it.\n\n  For example, if you distribute copies of the library, whether gratis\nor for a fee, you must give the recipients all the rights that we gave\nyou.  You must make sure that they, too, receive or can get the source\ncode.  If you link other code with the library, you must provide\ncomplete object files to the recipients, so that they can relink them\nwith the library after making changes to the library and recompiling\nit.  And you must show them these terms so they know their rights.\n\n  We protect your rights with a two-step method: (1) we copyright the\nlibrary, and (2) we offer you this license, which gives you legal\npermission to copy, distribute and/or modify the library.\n\n  To protect each distributor, we want to make it very clear that\nthere is no warranty for the free library.  Also, if the library is\nmodified by someone else and passed on, the recipients should know\nthat what they have is not the original version, so that the original\nauthor's reputation will not be affected by problems that might be\nintroduced by others.\n\n  Finally, software patents pose a constant threat to the existence of\nany free program.  We wish to make sure that a company cannot\neffectively restrict the users of a free program by obtaining a\nrestrictive license from a patent holder.  Therefore, we insist that\nany patent license obtained for a version of the library must be\nconsistent with the full freedom of use specified in this license.\n\n  Most GNU software, including some libraries, is covered by the\nordinary GNU General Public License.  This license, the GNU Lesser\nGeneral Public License, applies to certain designated libraries, and\nis quite different from the ordinary General Public License.  We use\nthis license for certain libraries in order to permit linking those\nlibraries into non-free programs.\n\n  When a program is linked with a library, whether statically or using\na shared library, the combination of the two is legally speaking a\ncombined work, a derivative of the original library.  The ordinary\nGeneral Public License therefore permits such linking only if the\nentire combination fits its criteria of freedom.  The Lesser General\nPublic License permits more lax criteria for linking other code with\nthe library.\n\n  We call this license the \"Lesser\" General Public License because it\ndoes Less to protect the user's freedom than the ordinary General\nPublic License.  It also provides other free software developers Less\nof an advantage over competing non-free programs.  These disadvantages\nare the reason we use the ordinary General Public License for many\nlibraries.  However, the Lesser license provides advantages in certain\nspecial circumstances.\n\n  For example, on rare occasions, there may be a special need to\nencourage the widest possible use of a certain library, so that it becomes\na de-facto standard.  To achieve this, non-free programs must be\nallowed to use the library.  A more frequent case is that a free\nlibrary does the same job as widely used non-free libraries.  In this\ncase, there is little to gain by limiting the free library to free\nsoftware only, so we use the Lesser General Public License.\n\n  In other cases, permission to use a particular library in non-free\nprograms enables a greater number of people to use a large body of\nfree software.  For example, permission to use the GNU C Library in\nnon-free programs enables many more people to use the whole GNU\noperating system, as well as its variant, the GNU/Linux operating\nsystem.\n\n  Although the Lesser General Public License is Less protective of the\nusers' freedom, it does ensure that the user of a program that is\nlinked with the Library has the freedom and the wherewithal to run\nthat program using a modified version of the Library.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.  Pay close attention to the difference between a\n\"work based on the library\" and a \"work that uses the library\".  The\nformer contains code derived from the library, whereas the latter must\nbe combined with the library in order to run.\n\n                  GNU LESSER GENERAL PUBLIC LICENSE\n   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\n\n  0. This License Agreement applies to any software library or other\nprogram which contains a notice placed by the copyright holder or\nother authorized party saying it may be distributed under the terms of\nthis Lesser General Public License (also called \"this License\").\nEach licensee is addressed as \"you\".\n\n  A \"library\" means a collection of software functions and/or data\nprepared so as to be conveniently linked with application programs\n(which use some of those functions and data) to form executables.\n\n  The \"Library\", below, refers to any such software library or work\nwhich has been distributed under these terms.  A \"work based on the\nLibrary\" means either the Library or any derivative work under\ncopyright law: that is to say, a work containing the Library or a\nportion of it, either verbatim or with modifications and/or translated\nstraightforwardly into another language.  (Hereinafter, translation is\nincluded without limitation in the term \"modification\".)\n\n  \"Source code\" for a work means the preferred form of the work for\nmaking modifications to it.  For a library, complete source code means\nall the source code for all modules it contains, plus any associated\ninterface definition files, plus the scripts used to control compilation\nand installation of the library.\n\n  Activities other than copying, distribution and modification are not\ncovered by this License; they are outside its scope.  The act of\nrunning a program using the Library is not restricted, and output from\nsuch a program is covered only if its contents constitute a work based\non the Library (independent of the use of the Library in a tool for\nwriting it).  Whether that is true depends on what the Library does\nand what the program that uses the Library does.\n\n  1. You may copy and distribute verbatim copies of the Library's\ncomplete source code as you receive it, in any medium, provided that\nyou conspicuously and appropriately publish on each copy an\nappropriate copyright notice and disclaimer of warranty; keep intact\nall the notices that refer to this License and to the absence of any\nwarranty; and distribute a copy of this License along with the\nLibrary.\n\n  You may charge a fee for the physical act of transferring a copy,\nand you may at your option offer warranty protection in exchange for a\nfee.\n\n  2. You may modify your copy or copies of the Library or any portion\nof it, thus forming a work based on the Library, and copy and\ndistribute such modifications or work under the terms of Section 1\nabove, provided that you also meet all of these conditions:\n\n    a) The modified work must itself be a software library.\n\n    b) You must cause the files modified to carry prominent notices\n    stating that you changed the files and the date of any change.\n\n    c) You must cause the whole of the work to be licensed at no\n    charge to all third parties under the terms of this License.\n\n    d) If a facility in the modified Library refers to a function or a\n    table of data to be supplied by an application program that uses\n    the facility, other than as an argument passed when the facility\n    is invoked, then you must make a good faith effort to ensure that,\n    in the event an application does not supply such function or\n    table, the facility still operates, and performs whatever part of\n    its purpose remains meaningful.\n\n    (For example, a function in a library to compute square roots has\n    a purpose that is entirely well-defined independent of the\n    application.  Therefore, Subsection 2d requires that any\n    application-supplied function or table used by this function must\n    be optional: if the application does not supply it, the square\n    root function must still compute square roots.)\n\nThese requirements apply to the modified work as a whole.  If\nidentifiable sections of that work are not derived from the Library,\nand can be reasonably considered independent and separate works in\nthemselves, then this License, and its terms, do not apply to those\nsections when you distribute them as separate works.  But when you\ndistribute the same sections as part of a whole which is a work based\non the Library, the distribution of the whole must be on the terms of\nthis License, whose permissions for other licensees extend to the\nentire whole, and thus to each and every part regardless of who wrote\nit.\n\nThus, it is not the intent of this section to claim rights or contest\nyour rights to work written entirely by you; rather, the intent is to\nexercise the right to control the distribution of derivative or\ncollective works based on the Library.\n\nIn addition, mere aggregation of another work not based on the Library\nwith the Library (or with a work based on the Library) on a volume of\na storage or distribution medium does not bring the other work under\nthe scope of this License.\n\n  3. You may opt to apply the terms of the ordinary GNU General Public\nLicense instead of this License to a given copy of the Library.  To do\nthis, you must alter all the notices that refer to this License, so\nthat they refer to the ordinary GNU General Public License, version 2,\ninstead of to this License.  (If a newer version than version 2 of the\nordinary GNU General Public License has appeared, then you can specify\nthat version instead if you wish.)  Do not make any other change in\nthese notices.\n\n  Once this change is made in a given copy, it is irreversible for\nthat copy, so the ordinary GNU General Public License applies to all\nsubsequent copies and derivative works made from that copy.\n\n  This option is useful when you wish to copy part of the code of\nthe Library into a program that is not a library.\n\n  4. You may copy and distribute the Library (or a portion or\nderivative of it, under Section 2) in object code or executable form\nunder the terms of Sections 1 and 2 above provided that you accompany\nit with the complete corresponding machine-readable source code, which\nmust be distributed under the terms of Sections 1 and 2 above on a\nmedium customarily used for software interchange.\n\n  If distribution of object code is made by offering access to copy\nfrom a designated place, then offering equivalent access to copy the\nsource code from the same place satisfies the requirement to\ndistribute the source code, even though third parties are not\ncompelled to copy the source along with the object code.\n\n  5. A program that contains no derivative of any portion of the\nLibrary, but is designed to work with the Library by being compiled or\nlinked with it, is called a \"work that uses the Library\".  Such a\nwork, in isolation, is not a derivative work of the Library, and\ntherefore falls outside the scope of this License.\n\n  However, linking a \"work that uses the Library\" with the Library\ncreates an executable that is a derivative of the Library (because it\ncontains portions of the Library), rather than a \"work that uses the\nlibrary\".  The executable is therefore covered by this License.\nSection 6 states terms for distribution of such executables.\n\n  When a \"work that uses the Library\" uses material from a header file\nthat is part of the Library, the object code for the work may be a\nderivative work of the Library even though the source code is not.\nWhether this is true is especially significant if the work can be\nlinked without the Library, or if the work is itself a library.  The\nthreshold for this to be true is not precisely defined by law.\n\n  If such an object file uses only numerical parameters, data\nstructure layouts and accessors, and small macros and small inline\nfunctions (ten lines or less in length), then the use of the object\nfile is unrestricted, regardless of whether it is legally a derivative\nwork.  (Executables containing this object code plus portions of the\nLibrary will still fall under Section 6.)\n\n  Otherwise, if the work is a derivative of the Library, you may\ndistribute the object code for the work under the terms of Section 6.\nAny executables containing that work also fall under Section 6,\nwhether or not they are linked directly with the Library itself.\n\n  6. As an exception to the Sections above, you may also combine or\nlink a \"work that uses the Library\" with the Library to produce a\nwork containing portions of the Library, and distribute that work\nunder terms of your choice, provided that the terms permit\nmodification of the work for the customer's own use and reverse\nengineering for debugging such modifications.\n\n  You must give prominent notice with each copy of the work that the\nLibrary is used in it and that the Library and its use are covered by\nthis License.  You must supply a copy of this License.  If the work\nduring execution displays copyright notices, you must include the\ncopyright notice for the Library among them, as well as a reference\ndirecting the user to the copy of this License.  Also, you must do one\nof these things:\n\n    a) Accompany the work with the complete corresponding\n    machine-readable source code for the Library including whatever\n    changes were used in the work (which must be distributed under\n    Sections 1 and 2 above); and, if the work is an executable linked\n    with the Library, with the complete machine-readable \"work that\n    uses the Library\", as object code and/or source code, so that the\n    user can modify the Library and then relink to produce a modified\n    executable containing the modified Library.  (It is understood\n    that the user who changes the contents of definitions files in the\n    Library will not necessarily be able to recompile the application\n    to use the modified definitions.)\n\n    b) Use a suitable shared library mechanism for linking with the\n    Library.  A suitable mechanism is one that (1) uses at run time a\n    copy of the library already present on the user's computer system,\n    rather than copying library functions into the executable, and (2)\n    will operate properly with a modified version of the library, if\n    the user installs one, as long as the modified version is\n    interface-compatible with the version that the work was made with.\n\n    c) Accompany the work with a written offer, valid for at\n    least three years, to give the same user the materials\n    specified in Subsection 6a, above, for a charge no more\n    than the cost of performing this distribution.\n\n    d) If distribution of the work is made by offering access to copy\n    from a designated place, offer equivalent access to copy the above\n    specified materials from the same place.\n\n    e) Verify that the user has already received a copy of these\n    materials or that you have already sent this user a copy.\n\n  For an executable, the required form of the \"work that uses the\nLibrary\" must include any data and utility programs needed for\nreproducing the executable from it.  However, as a special exception,\nthe materials to be distributed need not include anything that is\nnormally distributed (in either source or binary form) with the major\ncomponents (compiler, kernel, and so on) of the operating system on\nwhich the executable runs, unless that component itself accompanies\nthe executable.\n\n  It may happen that this requirement contradicts the license\nrestrictions of other proprietary libraries that do not normally\naccompany the operating system.  Such a contradiction means you cannot\nuse both them and the Library together in an executable that you\ndistribute.\n\n  7. You may place library facilities that are a work based on the\nLibrary side-by-side in a single library together with other library\nfacilities not covered by this License, and distribute such a combined\nlibrary, provided that the separate distribution of the work based on\nthe Library and of the other library facilities is otherwise\npermitted, and provided that you do these two things:\n\n    a) Accompany the combined library with a copy of the same work\n    based on the Library, uncombined with any other library\n    facilities.  This must be distributed under the terms of the\n    Sections above.\n\n    b) Give prominent notice with the combined library of the fact\n    that part of it is a work based on the Library, and explaining\n    where to find the accompanying uncombined form of the same work.\n\n  8. You may not copy, modify, sublicense, link with, or distribute\nthe Library except as expressly provided under this License.  Any\nattempt otherwise to copy, modify, sublicense, link with, or\ndistribute the Library is void, and will automatically terminate your\nrights under this License.  However, parties who have received copies,\nor rights, from you under this License will not have their licenses\nterminated so long as such parties remain in full compliance.\n\n  9. You are not required to accept this License, since you have not\nsigned it.  However, nothing else grants you permission to modify or\ndistribute the Library or its derivative works.  These actions are\nprohibited by law if you do not accept this License.  Therefore, by\nmodifying or distributing the Library (or any work based on the\nLibrary), you indicate your acceptance of this License to do so, and\nall its terms and conditions for copying, distributing or modifying\nthe Library or works based on it.\n\n  10. Each time you redistribute the Library (or any work based on the\nLibrary), the recipient automatically receives a license from the\noriginal licensor to copy, distribute, link with or modify the Library\nsubject to these terms and conditions.  You may not impose any further\nrestrictions on the recipients' exercise of the rights granted herein.\nYou are not responsible for enforcing compliance by third parties with\nthis License.\n\n  11. If, as a consequence of a court judgment or allegation of patent\ninfringement or for any other reason (not limited to patent issues),\nconditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot\ndistribute so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you\nmay not distribute the Library at all.  For example, if a patent\nlicense would not permit royalty-free redistribution of the Library by\nall those who receive copies directly or indirectly through you, then\nthe only way you could satisfy both it and this License would be to\nrefrain entirely from distribution of the Library.\n\nIf any portion of this section is held invalid or unenforceable under any\nparticular circumstance, the balance of the section is intended to apply,\nand the section as a whole is intended to apply in other circumstances.\n\nIt is not the purpose of this section to induce you to infringe any\npatents or other property right claims or to contest validity of any\nsuch claims; this section has the sole purpose of protecting the\nintegrity of the free software distribution system which is\nimplemented by public license practices.  Many people have made\ngenerous contributions to the wide range of software distributed\nthrough that system in reliance on consistent application of that\nsystem; it is up to the author/donor to decide if he or she is willing\nto distribute software through any other system and a licensee cannot\nimpose that choice.\n\nThis section is intended to make thoroughly clear what is believed to\nbe a consequence of the rest of this License.\n\n  12. If the distribution and/or use of the Library is restricted in\ncertain countries either by patents or by copyrighted interfaces, the\noriginal copyright holder who places the Library under this License may add\nan explicit geographical distribution limitation excluding those countries,\nso that distribution is permitted only in or among countries not thus\nexcluded.  In such case, this License incorporates the limitation as if\nwritten in the body of this License.\n\n  13. The Free Software Foundation may publish revised and/or new\nversions of the Lesser General Public License from time to time.\nSuch new versions will be similar in spirit to the present version,\nbut may differ in detail to address new problems or concerns.\n\nEach version is given a distinguishing version number.  If the Library\nspecifies a version number of this License which applies to it and\n\"any later version\", you have the option of following the terms and\nconditions either of that version or of any later version published by\nthe Free Software Foundation.  If the Library does not specify a\nlicense version number, you may choose any version ever published by\nthe Free Software Foundation.\n\n  14. If you wish to incorporate parts of the Library into other free\nprograms whose distribution conditions are incompatible with these,\nwrite to the author to ask for permission.  For software which is\ncopyrighted by the Free Software Foundation, write to the Free\nSoftware Foundation; we sometimes make exceptions for this.  Our\ndecision will be guided by the two goals of preserving the free status\nof all derivatives of our free software and of promoting the sharing\nand reuse of software generally.\n\n                            NO WARRANTY\n\n  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO\nWARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.\nEXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR\nOTHER PARTIES PROVIDE THE LIBRARY \"AS IS\" WITHOUT WARRANTY OF ANY\nKIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE\nLIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME\nTHE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN\nWRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY\nAND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU\nFOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR\nCONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE\nLIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING\nRENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A\nFAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF\nSUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\nDAMAGES.\n\n                     END OF TERMS AND CONDITIONS\n\n           How to Apply These Terms to Your New Libraries\n\n  If you develop a new library, and you want it to be of the greatest\npossible use to the public, we recommend making it free software that\neveryone can redistribute and change.  You can do so by permitting\nredistribution under these terms (or, alternatively, under the terms of the\nordinary General Public License).\n\n  To apply these terms, attach the following notices to the library.  It is\nsafest to attach them to the start of each source file to most effectively\nconvey the exclusion of warranty; and each file should have at least the\n\"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the library's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This library is free software; you can redistribute it and/or\n    modify it under the terms of the GNU Lesser General Public\n    License as published by the Free Software Foundation; either\n    version 2.1 of the License, or (at your option) any later version.\n\n    This library is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n    Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public\n    License along with this library; if not, write to the Free Software\n    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301\n    USA\n\nAlso add information on how to contact you by electronic and paper mail.\n\nYou should also get your employer (if you work as a programmer) or your\nschool, if any, to sign a \"copyright disclaimer\" for the library, if\nnecessary.  Here is a sample; alter the names:\n\n  Yoyodyne, Inc., hereby disclaims all copyright interest in the\n  library `Frob' (a library for tweaking knobs) written by James Random\n  Hacker.\n\n  <signature of Ty Coon>, 1 April 1990\n  Ty Coon, President of Vice\n\nThat's all there is to it!\n"
  },
  {
    "path": "Makefile",
    "content": "prefix ?= /usr\n\n.PHONY: install\ninstall:\n\tperl Makefile.pl -install -prefix \"$(prefix)\"\n\nuninstall:\n\tperl Makefile.pl -remove -prefix \"$(prefix)\"\n"
  },
  {
    "path": "Makefile.pl",
    "content": "#!/usr/bin/perl\n###########################################################################\n# Makefile for ABI Dumper\n# Install/remove the tool for GNU/Linux\n#\n# Copyright (C) 2013-2015 Andrey Ponomarenko's ABI Laboratory\n#\n# Written by Andrey Ponomarenko\n#\n# This program is free software: you can redistribute it and/or modify\n# it under the terms of the GNU General Public License or the GNU Lesser\n# General Public License as published by the Free Software Foundation.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# and the GNU Lesser General Public License along with this program.\n# If not, see <http://www.gnu.org/licenses/>.\n########################################################################### \nuse Getopt::Long;\nGetopt::Long::Configure (\"posix_default\", \"no_ignore_case\");\nuse File::Path qw(mkpath rmtree);\nuse File::Copy qw(copy);\nuse File::Basename qw(dirname);\nuse Cwd qw(abs_path);\nuse File::Find;\nuse strict;\n\nmy $TOOL_SNAME = \"abi-dumper\";\nmy $ARCHIVE_DIR = abs_path(dirname($0));\n\nmy $HELP_MSG = \"\nNAME:\n  Makefile for ABI Dumper\n\nDESCRIPTION:\n  Install $TOOL_SNAME command and private modules.\n\nUSAGE:\n  sudo perl $0 -install -prefix /usr\n  sudo perl $0 -remove -prefix /usr\n\nOPTIONS:\n  -h|-help\n      Print this help.\n\n  --prefix=PREFIX\n      Install files in PREFIX [/usr].\n\n  -install\n      Command to install the tool.\n\n  -remove\n      Command to remove the tool.\n\nEXTRA OPTIONS:\n  --destdir=DESTDIR\n      This option is for maintainers to build\n      RPM or DEB packages inside the build root.\n      The environment variable DESTDIR is also\n      supported.\n\\n\";\n\nif(not @ARGV)\n{\n    print $HELP_MSG;\n    exit(0);\n}\n\nmy ($PREFIX, $DESTDIR, $Help, $Install, $Remove);\n\nGetOptions(\n    \"h|help!\" => \\$Help,\n    \"prefix=s\" => \\$PREFIX,\n    \"destdir=s\" => \\$DESTDIR,\n    \"install!\" => \\$Install,\n    \"remove!\" => \\$Remove\n) or exit(1);\n\nsub scenario()\n{\n    if($Help)\n    {\n        print $HELP_MSG;\n        exit(0);\n    }\n    if(not $Install and not $Remove)\n    {\n        print STDERR \"ERROR: command is not selected (-install or -remove)\\n\";\n        exit(1);\n    }\n    \n    if($Install)\n    { # remove old version first\n        $Remove = 1;\n    }\n    \n    if($PREFIX ne \"/\") {\n        $PREFIX=~s/[\\/]+\\Z//g;\n    }\n    if(not $PREFIX)\n    { # default prefix\n        $PREFIX = \"/usr\";\n    }\n    if(my $Var = $ENV{\"DESTDIR\"})\n    {\n        print \"Using DESTDIR environment variable\\n\";\n        $DESTDIR = $Var;\n    }\n    if($DESTDIR)\n    {\n        if($DESTDIR ne \"/\") {\n            $DESTDIR=~s/[\\/]+\\Z//g;\n        }\n        if($DESTDIR!~/\\A\\//)\n        {\n            print STDERR \"ERROR: destdir is not absolute path\\n\";\n            exit(1);\n        }\n        if(not -d $DESTDIR)\n        {\n            print STDERR \"ERROR: you should create destdir directory first\\n\";\n            exit(1);\n        }\n        $PREFIX = $DESTDIR.$PREFIX;\n        if(not -d $PREFIX)\n        {\n            print STDERR \"ERROR: you should create installation directory first (destdir + prefix):\\n  mkdir -p $PREFIX\\n\";\n            exit(1);\n        }\n    }\n    else\n    {\n        if($PREFIX!~/\\A\\//)\n        {\n            print STDERR \"ERROR: prefix is not absolute path\\n\";\n            exit(1);\n        }\n        if(not -d $PREFIX)\n        {\n            print STDERR \"ERROR: you should create prefix directory first\\n\";\n            exit(1);\n        }\n    }\n    \n    print \"INSTALL PREFIX: $PREFIX\\n\";\n    \n    # paths\n    my $EXE_PATH = \"$PREFIX/bin\";\n    my $MODULES_PATH = \"$PREFIX/share/$TOOL_SNAME\";\n    my $REL_PATH = \"../share/$TOOL_SNAME\";\n    my $TOOL_PATH = \"$EXE_PATH/$TOOL_SNAME\";\n    \n    if(not -w $PREFIX)\n    {\n        print STDERR \"ERROR: you should be root\\n\";\n        exit(1);\n    }\n    if($Remove)\n    {\n        if(-e $EXE_PATH.\"/\".$TOOL_SNAME)\n        { # remove executable\n            print \"-- Removing $TOOL_PATH\\n\";\n            unlink($EXE_PATH.\"/\".$TOOL_SNAME);\n        }\n        elsif(not $Install) {\n            print \"The tool is not installed\\n\";\n        }\n        \n        if(-d $ARCHIVE_DIR.\"/modules\")\n        {\n            if(-d $MODULES_PATH)\n            { # remove modules\n                print \"-- Removing $MODULES_PATH\\n\";\n                rmtree($MODULES_PATH);\n            }\n            elsif(not $Install) {\n                print \"The modules of the tool are not installed\\n\";\n            }\n        }\n    }\n    if($Install)\n    {\n        # configure\n        my $Content = readFile($ARCHIVE_DIR.\"/\".$TOOL_SNAME.\".pl\");\n        if($DESTDIR) { # relative path\n            $Content=~s/MODULES_INSTALL_PATH/$REL_PATH/;\n        }\n        else { # absolute path\n            $Content=~s/MODULES_INSTALL_PATH/$MODULES_PATH/;\n        }\n        \n        # copy executable\n        print \"-- Installing $TOOL_PATH\\n\";\n        mkpath($EXE_PATH);\n        writeFile($EXE_PATH.\"/\".$TOOL_SNAME, $Content);\n        chmod(0755, $EXE_PATH.\"/\".$TOOL_SNAME);\n        \n        # copy modules\n        if(-d $ARCHIVE_DIR.\"/modules\")\n        {\n            print \"-- Installing $MODULES_PATH\\n\";\n            mkpath($MODULES_PATH);\n            copyDir($ARCHIVE_DIR.\"/modules\", $MODULES_PATH);\n        }\n        \n        # check PATH\n        if($ENV{\"PATH\"}!~/(\\A|:)\\Q$EXE_PATH\\E[\\/]?(\\Z|:)/) {\n            print \"WARNING: your PATH variable doesn't include \\'$EXE_PATH\\'\\n\";\n        }\n    }\n    exit(0);\n}\n\nsub copyDir($$)\n{\n    my ($From, $To) = @_;\n    my %Files;\n    find(\\&wanted, $From);\n    sub wanted {\n        $Files{$File::Find::dir.\"/$_\"} = 1 if($_ ne \".\");\n    }\n    foreach my $Path (sort keys(%Files))\n    {\n        my $Inst = $Path;\n        $Inst=~s/\\A\\Q$ARCHIVE_DIR\\E/$To/;\n        if(-d $Path)\n        { # directories\n            mkpath($Inst);\n        }\n        else\n        { # files\n            mkpath(dirname($Inst));\n            copy($Path, $Inst);\n        }\n    }\n}\n\nsub readFile($)\n{\n    my $Path = $_[0];\n    return \"\" if(not $Path or not -f $Path);\n    open(FILE, $Path) || die (\"can't open file \\'$Path\\': $!\\n\");\n    local $/ = undef;\n    my $Content = <FILE>;\n    close(FILE);\n    return $Content;\n}\n\nsub writeFile($$)\n{\n    my ($Path, $Content) = @_;\n    return if(not $Path);\n    open(FILE, \">\".$Path) || die (\"can't open file \\'$Path\\': $!\\n\");\n    print FILE $Content;\n    close(FILE);\n}\n\nscenario();\n"
  },
  {
    "path": "README.md",
    "content": "ABI Dumper 1.4\n==============\n\nABI Dumper — a tool to dump ABI of an ELF object containing DWARF debug info.\n\nContents\n--------\n\n1. [ About                 ](#about)\n2. [ Install               ](#install)\n3. [ Usage                 ](#usage)\n4. [ Filter public ABI     ](#filter-public-abi)\n5. [ Check for ABI changes ](#check-for-abi-changes)\n\nAbout\n-----\n\nThe tool is intended to be used with ABI Compliance Checker tool for tracking\nABI changes of a C/C++ library or kernel module: https://github.com/lvc/abi-compliance-checker\n\nThe tool is developed by Andrey Ponomarenko.\n\nInstall\n-------\n\n    sudo make install prefix=/usr\n\n###### Requires\n\n* Perl 5\n* Elfutils (eu-readelf)\n* GNU Binutils\n* Universal Ctags (https://github.com/universal-ctags/ctags)\n* Vtable Dumper >= 1.1 (https://github.com/lvc/vtable-dumper)\n* ABI Compliance Checker >= 2.2 (https://github.com/lvc/abi-compliance-checker)\n* GCC C++\n\nUsage\n-----\n\nInput objects should be compiled with `-g -Og -fno-eliminate-unused-debug-types` additional options to contain DWARF debug info.\n\n    abi-dumper libTest.so -o ABI.dump\n    abi-dumper Module.ko.debug\n\n###### Examples\n\n    abi-dumper lib/libssh.so.3\n    abi-dumper drm/nouveau/nouveau.ko.debug\n\n###### Docker\n\nYou can try Docker image if the tool is not packaged for your Linux distribution (example for Harfbuzz):\n\n    FROM ebraminio/abi-dumper\n    RUN apt update && \\\n        apt install -y ragel cpanminus && \\\n        git clone https://github.com/harfbuzz/harfbuzz && cd harfbuzz && \\\n            CFLAGS=\"-Og -g\" CXXFLAGS=\"-Og -g\" ./autogen.sh && make && cd .. && \\\n        abi-dumper `find . -name 'libharfbuzz.so.0.*'` && \\\n        cpanm JSON && \\\n        perl -le 'use JSON; print to_json(do shift, {canonical => 1, pretty => 1});' ./ABI.dump > ABI.json\n\n###### Adv. usage\n\n  For advanced usage, see output of `--help` option.\n\nFilter public ABI\n-----------------\n\n    abi-dumper libTest.so -public-headers PATH\n\nPATH — path to the install tree of a library.\n\nCheck for ABI changes\n---------------------\n\n    abi-dumper libTest.so.0 -o ABIv0.dump\n    abi-dumper libTest.so.1 -o ABIv1.dump\n    abi-compliance-checker -l libTest -old ABIv0.dump -new ABIv1.dump\n"
  },
  {
    "path": "abi-dumper.pl",
    "content": "#!/usr/bin/perl\n###########################################################################\n# ABI Dumper 1.3\n# Dump ABI of an ELF object containing DWARF debug info\n#\n# Copyright (C) 2013-2025 Andrey Ponomarenko's ABI Laboratory\n#\n# Written by Andrey Ponomarenko\n#\n# PLATFORMS\n# =========\n#  Linux\n#\n# REQUIREMENTS\n# ============\n#  Perl 5 (5.8 or newer)\n#  Elfutils (eu-readelf)\n#  GNU Binutils (objdump)\n#  Vtable-Dumper (1.1 or newer)\n#  Universal Ctags\n#  GCC C++\n#\n# COMPATIBILITY\n# =============\n#  ABI Viewer >= 1.0\n#  ABI Compliance Checker >= 2.2\n#\n# This library is free software; you can redistribute it and/or\n# modify it under the terms of the GNU Lesser General Public\n# License as published by the Free Software Foundation; either\n# version 2.1 of the License, or (at your option) any later version.\n#\n# This library is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n# Lesser General Public License for more details.\n#\n# You should have received a copy of the GNU Lesser General Public\n# License along with this library; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,\n# MA  02110-1301 USA\n###########################################################################\nuse Getopt::Long;\nGetopt::Long::Configure (\"posix_default\", \"no_ignore_case\", \"permute\");\nuse File::Path qw(mkpath rmtree);\nuse File::Temp qw(tempdir);\nuse Cwd qw(abs_path cwd realpath);\nuse Storable qw(dclone);\nuse Data::Dumper;\n\nmy $TOOL_VERSION = \"1.4\";\nmy $ABI_DUMP_VERSION = \"3.5\";\nmy $ORIG_DIR = cwd();\nmy $TMP_DIR = tempdir(CLEANUP=>1);\n\nmy $VTABLE_DUMPER = \"vtable-dumper\";\nmy $VTABLE_DUMPER_VERSION = \"1.0\";\n\nmy $LOCALE = \"LANG=C.UTF-8\";\nmy $EU_READELF = \"eu-readelf\";\nmy $EU_READELF_L = $LOCALE.\" \".$EU_READELF;\nmy $OBJDUMP = \"objdump\";\nmy $CTAGS = \"ctags\";\nmy $EXUBERANT_CTAGS = 0;\nmy $GPP = \"g++\";\n\nmy ($Help, $ShowVersion, $DumpVersion, $OutputDump, $SortDump, $StdOut,\n$TargetVersion, $ExtraInfo, $FullDump, $AllTypes, $AllSymbols, $BinOnly,\n$SkipCxx, $Loud, $AddrToName, $DumpStatic, $Compare, $AltDebugInfoOpt,\n$AddDirs, $VTDumperPath, $SymbolsListPath, $PublicHeadersPath,\n$IgnoreTagsPath, @CtagsDef, $KernelExport, $UseTU, $ReimplementStd,\n$IncludePreamble, $IncludePaths, $CacheHeaders, $MixedHeaders, $Debug,\n$SearchDirDebuginfo, $KeepRegsAndOffsets, $Quiet, $IncludeDefines,\n$AllUnits, $LambdaSupport, $LdLibraryPath, $ExtraDump);\n\nmy $CmdName = getFilename($0);\n\nmy %ERROR_CODE = (\n    \"Success\"=>0,\n    \"Error\"=>2,\n    # System command is not found\n    \"Not_Found\"=>3,\n    # Cannot access input files\n    \"Access_Error\"=>4,\n    # Cannot find a module\n    \"Module_Error\"=>9,\n    # No debug-info\n    \"No_DWARF\"=>10,\n    # Invalid debug-info\n    \"Invalid_DWARF\"=>11,\n    # No exported symbols\n    \"No_Exported\"=>12\n);\n\nmy $ShortUsage = \"ABI Dumper $TOOL_VERSION EE\nDump ABI of an ELF object containing DWARF debug info\nCopyright (C) 2025 Andrey Ponomarenko's ABI Laboratory\nLicense: GNU LGPL 2.1\n\nUsage: $CmdName [options] [object]\nExample:\n  $CmdName libTest.so -o ABI.dump\n  $CmdName Module.ko.debug -o ABI.dump\n\nMore info: $CmdName --help\\n\";\n\nif($#ARGV==-1)\n{\n    printMsg(\"INFO\", $ShortUsage);\n    exit(0);\n}\n\nGetOptions(\"h|help!\" => \\$Help,\n  \"v|version!\" => \\$ShowVersion,\n  \"dumpversion!\" => \\$DumpVersion,\n# general options\n  \"o|output|dump-path=s\" => \\$OutputDump,\n  \"sort!\" => \\$SortDump,\n  \"stdout!\" => \\$StdOut,\n  \"loud!\" => \\$Loud,\n  \"vnum|lver|lv=s\" => \\$TargetVersion,\n  \"extra-info=s\" => \\$ExtraInfo,\n  \"bin-only!\" => \\$BinOnly,\n  \"all-types!\" => \\$AllTypes,\n  \"all-symbols!\" => \\$AllSymbols,\n  \"symbols-list=s\" => \\$SymbolsListPath,\n  \"skip-cxx!\" => \\$SkipCxx,\n  \"all!\" => \\$FullDump,\n  \"dump-static!\" => \\$DumpStatic,\n  \"compare!\" => \\$Compare,\n  \"alt=s\" => \\$AltDebugInfoOpt,\n  \"dir!\" => \\$AddDirs,\n  \"vt-dumper=s\" => \\$VTDumperPath,\n  \"public-headers=s\" => \\$PublicHeadersPath,\n  \"ignore-tags=s\" => \\$IgnoreTagsPath,\n  \"ctags-def=s\" => \\@CtagsDef,\n  \"mixed-headers!\" => \\$MixedHeaders,\n  \"kernel-export!\" => \\$KernelExport,\n  \"search-debuginfo=s\" => \\$SearchDirDebuginfo,\n  \"keep-registers-and-offsets!\" => \\$KeepRegsAndOffsets,\n  \"all-units!\" => \\$AllUnits,\n  \"quiet!\" => \\$Quiet,\n  \"debug!\" => \\$Debug,\n# extra options\n  \"use-tu-dump!\" => \\$UseTU,\n  \"include-preamble=s\" => \\$IncludePreamble,\n  \"include-paths=s\" => \\$IncludePaths,\n  \"include-defines=s\" => \\$IncludeDefines,\n  \"cache-headers=s\" => \\$CacheHeaders,\n  \"lambda!\" => \\$LambdaSupport,\n  \"ld-library-path=s\" => \\$LdLibraryPath,\n# internal options\n  \"addr2name!\" => \\$AddrToName,\n  \"extra-dump!\" => \\$ExtraDump,\n# obsolete\n  \"reimplement-std!\" => \\$ReimplementStd\n) or errMsg();\n\nsub errMsg()\n{\n    printMsg(\"INFO\", \"\\n\".$ShortUsage);\n    exit($ERROR_CODE{\"Error\"});\n}\n\nmy $HelpMessage=\"\nNAME:\n  ABI Dumper EE ($CmdName)\n  Dump ABI of an ELF object containing DWARF debug info\n\nDESCRIPTION:\n  ABI Dumper is a tool for dumping ABI information of an ELF object\n  containing DWARF debug info.\n  \n  The tool is intended to be used with ABI Viewer or ABICC tool for\n  tracking ABI changes of a C/C++ library or kernel module.\n\n  This tool is free software: you can redistribute it and/or modify it\n  under the terms of the GNU LGPL 2.1.\n\nUSAGE:\n  $CmdName [options] [object]\n\nEXAMPLES:\n  $CmdName libTest.so -o ABI.dump\n  $CmdName Module.ko.debug -o ABI.dump\n\nINFORMATION OPTIONS:\n  -h|-help\n      Print this help.\n\n  -v|-version\n      Print version information.\n\n  -dumpversion\n      Print the tool version ($TOOL_VERSION) and don't do anything else.\n\nGENERAL OPTIONS:\n  -o|-output PATH\n      Path to the output ABI dump file.\n      Default: ./ABI.dump\n      \n  -sort\n      Sort data in ABI dump.\n      \n  -stdout\n      Print ABI dump to stdout.\n      \n  -loud\n      Print all warnings.\n      \n  -vnum NUM\n      Set version of the library to NUM.\n      \n  -extra-info DIR\n      Dump extra analysis info to DIR.\n      \n  -bin-only\n      Do not dump information about inline functions,\n      pure virtual functions and non-exported global data.\n      \n  -all-types\n      Dump unused data types.\n      \n  -all-symbols\n      Dump symbols not exported by the object.\n      \n  -symbols-list PATH\n      Specify a file with a list of symbols that should be dumped.\n      \n  -skip-cxx\n      Do not dump stdc++ and gnu c++ symbols.\n      \n  -all\n      Equal to: -all-types -all-symbols.\n      \n  -dump-static\n      Dump static (local) symbols.\n      \n  -compare OLD.dump NEW.dump\n      Show added/removed symbols between two ABI dumps.\n      \n  -alt PATH\n      Path to the alternate debug info (Fedora). It is\n      detected automatically from gnu_debugaltlink section\n      of the input object if not specified.\n      \n  -dir\n      Show full paths of source files.\n  \n  -vt-dumper PATH\n      Path to the vtable-dumper executable if it is installed\n      to non-default location (not in PATH).\n  \n  -public-headers PATH\n      Path to directory with public header files or to file with\n      the list of header files. This option allows to filter out\n      private symbols from the ABI dump.\n  \n  -ignore-tags PATH\n      Path to ignore.tags file to help ctags tool to read\n      symbols in header files.\n  \n  -ctags-def DEF\n      Add -D DEF option to the ctags call. This option may be\n      specified multiple times.\n  \n  -reimplement-std\n      Do nothing.\n  \n  -mixed-headers\n      This option should be specified if you are using\n      -public-headers option and the names of public headers\n      intersect with the internal headers.\n  \n  -kernel-export\n      Dump symbols exported by the Linux kernel and modules, i.e.\n      symbols declared in the ksymtab section of the object and\n      system calls.\n  \n  -search-debuginfo DIR\n      Search for debug-info files referenced from gnu_debuglink\n      section of the object in DIR.\n  \n  -keep-registers-and-offsets\n      Dump used registers and stack offsets even if incompatible\n      build options detected.\n  \n  -all-units\n      Extract ABI info after reading all compilation units from\n      the debug info. This may require a lot of extra RAM memory.\n      By default all compilation units are processed separately.\n  \n  -quiet\n      Do not warn about incompatible build options.\n  \n  -debug\n      Enable debug messages.\n\nEXTRA OPTIONS:\n  -use-tu-dump\n      Use g++ -fdump-translation-unit instead of ctags to\n      list symbols in headers. This may be useful if all\n      functions are declared via macros in headers and\n      ctags can't recognize them.\n  \n  -include-preamble PATHS\n      Specify header files (separated by semicolon) that\n      should be included before others to compile without\n      errors.\n  \n  -include-paths DIRS\n      Specify include directories (separated by semicolon)\n      that should be passed to the compiler by -I option\n      in order to compile headers without errors. If this\n      option is not set then the tool will try to generate\n      include paths automatically.\n  \n  -cache-headers DIR\n      Cache headers analysis results to reuse later.\n  \n  -lambda\n      Enable support for lambda and checking of lexical\n      blocks. Define it if your C++ library API functions\n      use lambda expressions.\n  \n  -ld-library-path PATHS\n      Specify paths to add to LD_LIBRARY_PATH variable before\n      executing vtable-dumper (separated by colon).\n      \n      By default lexical blocks are not analyzed to\n      improve performance.\n\";\n\nsub helpMsg() {\n    printMsg(\"INFO\", $HelpMessage);\n}\n\nmy %Cache;\n\n# Input\nmy %DWARF_Info;\nmy @IDs;\n\n# Alternate\nmy @IDs_I;\nmy $AltDebugInfo = undef;\nmy $TooBig = 0;\n\nmy $Compressed = undef;\nmy $Partial = undef;\n\n# Dump\nmy %TypeUnit;\nmy %Post_Change;\n\n# Output\nmy %TypeInfo;\nmy %SymbolInfo;\n\n# Other\nmy $TargetName = undef;\nmy %NestedNameSpaces;\nmy %HeadersInfo;\nmy %SourcesInfo;\nmy %SymVer;\nmy %LexicalId;\n\n# Reader (per compile unit)\nmy %TypeMember;\nmy %ArrayCount;\nmy %FuncParam;\nmy %TmplParam;\nmy %Inheritance;\nmy %NameSpace;\nmy %SpecElem;\nmy %OrigElem;\nmy %ClassMethods;\n\n# Reader\nmy %TypeSpec;\nmy %ClassChild;\nmy %SourceFile;\nmy %SourceFile_Alt;\nmy %DebugLoc;\nmy %TName_Tid;\nmy %TName_Tids;\nmy %RegName;\n\nmy $STDCXX_TARGET = 0;\nmy $GLOBAL_ID = 0;\nmy %ANON_TYPE_WARN = ();\n\nmy %Mangled_ID;\nmy %Checked_Spec;\nmy %SelectedSymbols;\n\n# Cleaning\nmy %MergedTypes;\nmy %LocalType;\nmy %UsedType;\nmy %DeletedAnon;\nmy %CheckedType;\nmy %DuplBaseType;\n\n# Language\nmy %TypeType = (\n    \"class_type\"=>\"Class\",\n    \"structure_type\"=>\"Struct\",\n    \"union_type\"=>\"Union\",\n    \"enumeration_type\"=>\"Enum\",\n    \"subroutine_type\"=>\"Func\",\n    \"array_type\"=>\"Array\",\n    \"base_type\"=>\"Intrinsic\",\n    \"atomic_type\"=>\"Intrinsic\",\n    \"unspecified_type\"=>\"Unspecified\",\n    \"const_type\"=>\"Const\",\n    \"pointer_type\"=>\"Pointer\",\n    \"reference_type\"=>\"Ref\",\n    \"rvalue_reference_type\"=>\"RvalueRef\",\n    \"volatile_type\"=>\"Volatile\",\n    \"restrict_type\"=>\"Restrict\",\n    \"typedef\"=>\"Typedef\",\n    \"ptr_to_member_type\"=>\"FieldPtr\",\n    \"string_type\"=>\"String\"\n);\n\nmy %Qual = (\n    \"Pointer\"=>\"*\",\n    \"Ref\"=>\"&\",\n    \"RvalueRef\"=>\"&&\",\n    \"Volatile\"=>\"volatile\",\n    \"Restrict\"=>\"restrict\",\n    \"Const\"=>\"const\"\n);\n\nmy %ConstSuffix = (\n    \"unsigned int\" => \"u\",\n    \"unsigned long\" => \"ul\",\n    \"unsigned long long\" => \"ull\",\n    \"long\" => \"l\",\n    \"long long\" => \"ll\"\n);\n\nmy $HEADER_EXT = \"h|hh|hp|hxx|hpp|h\\\\+\\\\+|tcc|txx|x|inl|inc|ads|isph\";\nmy $SRC_EXT = \"c|cc|cp|cpp|cxx|c\\\\+\\\\+\";\n\n# ELF\nmy %Library_Symbol;\nmy %Library_UndefSymbol;\nmy %Library_Needed;\nmy %SymbolTable;\nmy %Symbol_Bind;\n\n# Extra Dump\nmy %SymbolAttribute;\nmy $GLOBAL_ID_T = 0;\nmy %FullLoc = ();\n\n# Kernel\nmy %KSymTab;\n\n# VTables\nmy %VirtualTable;\nmy %VTable_Symbol;\nmy %VTable_Class;\n\n# Env\nmy $SYS_ARCH;\nmy $SYS_WORD;\nmy $SYS_GCCV;\nmy $SYS_CLANGV = undef;\nmy $SYS_COMP;\nmy $LIB_LANG;\nmy $OBJ_LANG;\n\n# Errors\nmy $InvalidDebugLoc;\nmy $IncompatibleOpt = undef;\nmy $FKeepInLine = undef;\n\n# Public Headers\nmy %SymbolToHeader;\nmy %TypeToHeader;\nmy %PublicHeader;\nmy $PublicSymbols_Detected;\nmy $PublicHeadersIsDir = 1;\n\n# Filter\nmy %SymbolsList;\n\n# Dump\nmy $COMPRESS = \"tar.gz\";\n\nsub printMsg($$)\n{\n    my ($Type, $Msg) = @_;\n    if($Type!~/\\AINFO/) {\n        $Msg = $Type.\": \".$Msg;\n    }\n    if($Type!~/_C\\Z/) {\n        $Msg .= \"\\n\";\n    }\n    if($Type eq \"ERROR\"\n    or $Type eq \"WARNING\") {\n        print STDERR $Msg;\n    }\n    else {\n        print $Msg;\n    }\n}\n\nsub exitStatus($$)\n{\n    my ($Code, $Msg) = @_;\n    printMsg(\"ERROR\", $Msg);\n    exit($ERROR_CODE{$Code});\n}\n\nsub cmpVersions($$)\n{ # compare two versions in dotted-numeric format\n    my ($V1, $V2) = @_;\n    return 0 if($V1 eq $V2);\n    return undef if($V1!~/\\A\\d+[\\.\\d+]*\\Z/);\n    return undef if($V2!~/\\A\\d+[\\.\\d+]*\\Z/);\n    my @V1Parts = split(/\\./, $V1);\n    my @V2Parts = split(/\\./, $V2);\n    for (my $i = 0; $i <= $#V1Parts && $i <= $#V2Parts; $i++) {\n        return -1 if(int($V1Parts[$i]) < int($V2Parts[$i]));\n        return 1 if(int($V1Parts[$i]) > int($V2Parts[$i]));\n    }\n    return -1 if($#V1Parts < $#V2Parts);\n    return 1 if($#V1Parts > $#V2Parts);\n    return 0;\n}\n\nsub writeFile($$)\n{\n    my ($Path, $Content) = @_;\n    \n    if(my $Dir = getDirname($Path)) {\n        mkpath($Dir);\n    }\n    open(FILE, \">\", $Path) || die (\"can't open file \\'$Path\\': $!\\n\");\n    print FILE $Content;\n    close(FILE);\n}\n\nsub readFile($)\n{\n    my $Path = $_[0];\n    \n    open(FILE, $Path);\n    local $/ = undef;\n    my $Content = <FILE>;\n    close(FILE);\n    return $Content;\n}\n\nsub getFilename($)\n{ # much faster than basename() from File::Basename module\n    if($_[0] and $_[0]=~/([^\\/\\\\]+)[\\/\\\\]*\\Z/) {\n        return $1;\n    }\n    return \"\";\n}\n\nsub getDirname($)\n{ # much faster than dirname() from File::Basename module\n    if($_[0] and $_[0]=~/\\A(.*?)[\\/\\\\]+[^\\/\\\\]*[\\/\\\\]*\\Z/) {\n        return $1;\n    }\n    return \"\";\n}\n\nsub sepPath($) {\n    return (getDirname($_[0]), getFilename($_[0]));\n}\n\nsub checkCmd($)\n{\n    my $Cmd = $_[0];\n    \n    if(defined $Cache{\"checkCmd\"}{$Cmd}) {\n        return $Cache{\"checkCmd\"}{$Cmd};\n    }\n    \n    if(-x $Cmd)\n    { # relative or absolute path\n        return ($Cache{\"checkCmd\"}{$Cmd} = 1);\n    }\n    \n    foreach my $Path (sort {length($a)<=>length($b)} split(/:/, $ENV{\"PATH\"}))\n    {\n        if(-x $Path.\"/\".$Cmd) {\n            return ($Cache{\"checkCmd\"}{$Cmd} = 1);\n        }\n    }\n    return ($Cache{\"checkCmd\"}{$Cmd} = 0);\n}\n\nmy %ELF_BIND = map {$_=>1} (\n    \"WEAK\",\n    \"GLOBAL\",\n    \"LOCAL\"\n);\n\nmy %ELF_TYPE = map {$_=>1} (\n    \"FUNC\",\n    \"IFUNC\",\n    \"GNU_IFUNC\",\n    \"TLS\",\n    \"OBJECT\",\n    \"COMMON\"\n);\n\nmy %ELF_VIS = map {$_=>1} (\n    \"DEFAULT\",\n    \"PROTECTED\"\n);\n\nsub readline_ELF($)\n{ # read the line of 'eu-readelf' output corresponding to the symbol\n    my @Info = split(/\\s+/, $_[0]);\n    #  Num:   Value      Size Type   Bind   Vis       Ndx  Name\n    #  3629:  000b09c0   32   FUNC   GLOBAL DEFAULT   13   _ZNSt12__basic_fileIcED1Ev@@GLIBCXX_3.4\n    #  135:   00000000    0   FUNC   GLOBAL DEFAULT   UNDEF  av_image_fill_pointers@LIBAVUTIL_52 (3)\n    shift(@Info) if($Info[0] eq \"\"); # spaces\n    shift(@Info); # num\n    \n    if($#Info==7)\n    { # UNDEF SYMBOL (N)\n        if($Info[7]=~/\\(\\d+\\)/) {\n            pop(@Info);\n        }\n    }\n    \n    if($#Info!=6)\n    { # other lines\n        return ();\n    }\n    return () if(not defined $ELF_TYPE{$Info[2]} and $Info[5] ne \"UNDEF\");\n    return () if(not defined $ELF_BIND{$Info[3]});\n    return () if(not defined $ELF_VIS{$Info[4]});\n    if($Info[5] eq \"ABS\" and $Info[0]=~/\\A0+\\Z/)\n    { # 1272: 00000000     0 OBJECT  GLOBAL DEFAULT  ABS CXXABI_1.3\n        return ();\n    }\n    if(index($Info[2], \"0x\") == 0)\n    { # size == 0x3d158\n        $Info[2] = hex($Info[2]);\n    }\n    return @Info;\n}\n\nsub readSymbols($)\n{\n    my $Lib_Path = $_[0];\n    my $Lib_Name = getFilename($Lib_Path);\n    \n    my $Dynamic = ($Lib_Name=~/\\.so(\\.|\\Z)/);\n    my $Dbg = ($Lib_Name=~/\\.debug\\Z/);\n    \n    if(not checkCmd($EU_READELF)) {\n        exitStatus(\"Not_Found\", \"can't find \\\"eu-readelf\\\" from Elfutils\");\n    }\n    \n    my %SectionInfo;\n    my %KSect;\n    \n    my $Cmd = $EU_READELF_L.\" -S \\\"$Lib_Path\\\" 2>\\\"$TMP_DIR/error\\\"\";\n    foreach (split(/\\n/, `$Cmd`))\n    {\n        if(/\\[\\s*(\\d+)\\]\\s+([\\w\\.]+)/)\n        {\n            my ($Num, $Name) = ($1, $2);\n            \n            $SectionInfo{$Num} = $Name;\n            \n            if(defined $KernelExport)\n            {\n                if($Name=~/\\A(__ksymtab|__ksymtab_gpl)\\Z/) {\n                    $KSect{$1} = 1;\n                }\n            }\n        }\n    }\n    \n    if(defined $KernelExport)\n    {\n        if(not keys(%KSect))\n        {\n            printMsg(\"ERROR\", \"can't find __ksymtab or __ksymtab_gpl sections in the object\");\n            exit(1);\n        }\n        \n        foreach my $Name (sort keys(%KSect))\n        {\n            $Cmd = $OBJDUMP.\" --section=$Name -d \\\"$Lib_Path\\\" 2>\\\"$TMP_DIR/error\\\"\";\n            \n            foreach my $Line (split(/\\n/, qx/$Cmd/))\n            {\n                if($Line=~/<__ksymtab_(.+?)>/)\n                {\n                    $KSymTab{$1} = 1;\n                }\n            }\n        }\n    }\n    \n    if($Dynamic)\n    { # dynamic library specifics\n        $Cmd = $EU_READELF_L.\" -d \\\"$Lib_Path\\\" 2>\\\"$TMP_DIR/error\\\"\";\n        foreach (split(/\\n/, `$Cmd`))\n        {\n            if(/NEEDED.+\\[([^\\[\\]]+)\\]/)\n            { # dependencies:\n              # 0x00000001 (NEEDED) Shared library: [libc.so.6]\n                $Library_Needed{$1} = 1;\n            }\n        }\n    }\n    \n    my $ExtraPath = undef;\n    \n    if($ExtraInfo)\n    {\n        mkpath($ExtraInfo);\n        $ExtraPath = $ExtraInfo.\"/elf-info\";\n    }\n    \n    $Cmd = $EU_READELF_L.\" -s \\\"$Lib_Path\\\" 2>\\\"$TMP_DIR/error\\\"\";\n    \n    if($ExtraPath)\n    { # debug mode\n        # write to file\n        system($Cmd.\" >\\\"$ExtraPath\\\"\");\n        open(LIB, $ExtraPath);\n    }\n    else\n    { # write to pipe\n        open(LIB, $Cmd.\" |\");\n    }\n    \n    my (%Symbol_Value, %Value_Symbol) = ();\n    \n    my $symtab = undef; # indicates that we are processing 'symtab' section of 'readelf' output\n    while(<LIB>)\n    {\n        if($Dynamic and not $Dbg)\n        { # dynamic library specifics\n            if(defined $symtab)\n            {\n                if(index($_, \"'.dynsym'\")!=-1)\n                { # dynamic table\n                    $symtab = undef;\n                }\n                if(not $AllSymbols)\n                { # do nothing with symtab\n                    # next;\n                }\n            }\n            elsif(index($_, \"'.symtab'\")!=-1)\n            { # symbol table\n                $symtab = 1;\n            }\n        }\n        if(my ($Value, $Size, $Type, $Bind, $Vis, $Ndx, $Symbol) = readline_ELF($_))\n        { # read ELF entry\n            $Symbol_Bind{$Symbol} = $Bind;\n            if(index($Symbol, '@')!=-1)\n            {\n                if($Symbol=~/\\A(.+?)\\@/) {\n                    $Symbol_Bind{$1} = $Bind;\n                }\n            }\n            \n            if(not $symtab)\n            { # dynsym\n                if(skipSymbol($Symbol)) {\n                    next;\n                }\n                \n                if($Ndx eq \"UNDEF\")\n                { # ignore interfaces that are imported from somewhere else\n                    $Library_UndefSymbol{$TargetName}{$Symbol} = 0;\n                    next;\n                }\n                \n                if(defined $KernelExport)\n                {\n                    if($Bind ne \"LOCAL\")\n                    {\n                        if(index($Symbol, \"sys_\")==0\n                        or index($Symbol, \"SyS_\")==0) {\n                            $KSymTab{$Symbol} = 1;\n                        }\n                    }\n                    \n                    if(not defined $KSymTab{$Symbol}) {\n                        next;\n                    }\n                }\n                \n                if($Bind ne \"LOCAL\") {\n                    $Library_Symbol{$TargetName}{$Symbol} = ($Type eq \"OBJECT\")?-$Size:1;\n                }\n                \n                if(not defined $OBJ_LANG)\n                {\n                    if(index($Symbol, \"_Z\")==0)\n                    {\n                        $OBJ_LANG = \"C++\";\n                    }\n                }\n            }\n            \n            if($Ndx ne \"UNDEF\" and $Value!~/\\A0+\\Z/)\n            {\n                $Symbol_Value{$Symbol} = $Value;\n                $Value_Symbol{$Value}{$Symbol} = 1;\n\n                if(defined $ExtraDump)\n                {\n                    $SymbolAttribute{$Symbol} = {\n                        \"Val\" => $Value,\n                        \"Size\" => $Size,\n                        \"Kind\" => $Type,\n                        \"Bind\" => $Bind,\n                        \"Vis\" => $Vis,\n                        \"Ndx\" => $Ndx\n                    };\n                }\n            }\n            \n            if(not $symtab)\n            {\n                foreach ($SectionInfo{$Ndx}, \"\")\n                {\n                    my $Val = $Value;\n                    \n                    $SymbolTable{$_}{$Val}{$Symbol} = 1;\n                    \n                    if($Val=~s/\\A[0]+//)\n                    {\n                        if($Val eq \"\") {\n                            $Val = \"0\";\n                        }\n                        $SymbolTable{$_}{$Val}{$Symbol} = 1;\n                    }\n                }\n            }\n        }\n    }\n    close(LIB);\n    \n    if(not defined $Library_Symbol{$TargetName}) {\n        return;\n    }\n    \n    my %Found = ();\n    foreach my $Symbol (sort keys(%Symbol_Value))\n    {\n        next if(index($Symbol, '@')==-1);\n        if(my $Value = $Symbol_Value{$Symbol})\n        {\n            foreach my $Symbol_SameValue (sort keys(%{$Value_Symbol{$Value}}))\n            {\n                if($Symbol_SameValue ne $Symbol\n                and index($Symbol_SameValue, '@')==-1)\n                {\n                    $SymVer{$Symbol_SameValue} = $Symbol;\n                    $Found{$Symbol} = 1;\n                    \n                    if(index($Symbol, '@@')==-1) {\n                        last;\n                    }\n                }\n            }\n        }\n    }\n    \n    # default\n    foreach my $Symbol (sort keys(%Symbol_Value))\n    {\n        next if(defined $Found{$Symbol});\n        next if(index($Symbol, '@@')==-1);\n        \n        if($Symbol=~/\\A([^\\@]*)\\@\\@/\n        and not $SymVer{$1})\n        {\n            $SymVer{$1} = $Symbol;\n            $Found{$Symbol} = 1;\n        }\n    }\n    \n    # non-default\n    foreach my $Symbol (sort keys(%Symbol_Value))\n    {\n        next if(defined $Found{$Symbol});\n        next if(index($Symbol, '@')==-1);\n        \n        if($Symbol=~/\\A([^\\@]*)\\@([^\\@]*)/\n        and not $SymVer{$1})\n        {\n            $SymVer{$1} = $Symbol;\n            $Found{$Symbol} = 1;\n        }\n    }\n    \n    if(not defined $OBJ_LANG)\n    {\n        $OBJ_LANG = \"C\";\n    }\n}\n\nsub readAltInfo($)\n{\n    my $Path = $_[0];\n    my $Name = getFilename($Path);\n    \n    if(not checkCmd($EU_READELF)) {\n        exitStatus(\"Not_Found\", \"can't find \\\"$EU_READELF\\\" command\");\n    }\n    \n    printMsg(\"INFO\", \"Reading alternate debug-info\");\n    \n    my $ExtraPath = undef;\n    \n    # lines info\n    if($ExtraInfo)\n    {\n        $ExtraPath = $ExtraInfo.\"/alt\";\n        mkpath($ExtraPath);\n        $ExtraPath .= \"/debug_line\";\n    }\n    \n    if($ExtraPath)\n    {\n        system($EU_READELF_L.\" -N --debug-dump=line \\\"$Path\\\" 2>\\\"$TMP_DIR/error\\\" >\\\"$ExtraPath\\\"\");\n        open(SRC, $ExtraPath);\n    }\n    else {\n        open(SRC, $EU_READELF_L.\" -N --debug-dump=line \\\"$Path\\\" 2>\\\"$TMP_DIR/error\\\" |\");\n    }\n    \n    my $DirTable_Def = undef;\n    my %DirTable = ();\n    \n    while(<SRC>)\n    {\n        if(defined $AddDirs)\n        {\n            if(/Directory table/i)\n            {\n                $DirTable_Def = 1;\n                next;\n            }\n            elsif(/File name table/i)\n            {\n                $DirTable_Def = undef;\n                next;\n            }\n            \n            if(defined $DirTable_Def)\n            {\n                if(/\\A\\s*(.+?)\\Z/) {\n                    $DirTable{keys(%DirTable)+1} = $1;\n                }\n                elsif(/\\A\\s*(\\d+)\\s+(.+?)\\s+\\(\\d+\\)\\Z/)\n                { # F34\n                    $DirTable{$1} = $2;\n                }\n            }\n        }\n        \n        my ($Num, $Dir, $File) = ();\n        \n        if(/(\\d+)\\s+(\\d+)\\s+\\d+\\s+\\d+\\s+([^ ]+)/) {\n            ($Num, $Dir, $File) = ($1, $2, $3)\n        }\n        elsif(/(\\d+)\\s+([^ ]+)\\s+\\(\\d+\\)\\,\\s+(\\d+)/)\n        {  # F34\n            ($Num, $File, $Dir) = ($1, $2, $3);\n        }\n        \n        if($File)\n        {\n            chomp($File);\n            \n            if(defined $AddDirs)\n            {\n                if(my $DName = $DirTable{$Dir})\n                {\n                    $File = $DName.\"/\".$File;\n                }\n            }\n            \n            $SourceFile_Alt{0}{$Num} = $File;\n        }\n    }\n    close(SRC);\n    \n    # debug info\n    if($ExtraInfo)\n    {\n        $ExtraPath = $ExtraInfo.\"/alt\";\n        mkpath($ExtraPath);\n        $ExtraPath .= \"/debug_info\";\n    }\n    \n    my $INFO_fh;\n    \n    if($ExtraPath)\n    {\n        system($EU_READELF_L.\" -N --debug-dump=info \\\"$Path\\\" 2>\\\"$TMP_DIR/error\\\" >\\\"$ExtraPath\\\"\");\n        open($INFO_fh, $ExtraPath);\n    }\n    else {\n        open($INFO_fh, $EU_READELF_L.\" -N --debug-dump=info \\\"$Path\\\" 2>\\\"$TMP_DIR/error\\\" |\");\n    }\n    \n    readDWARFDump($INFO_fh, 0);\n}\n\nsub readDWARFInfo($)\n{\n    my $Path = $_[0];\n    \n    my $Dir = getDirname($Path);\n    my $Name = getFilename($Path);\n    \n    if(not checkCmd($EU_READELF)) {\n        exitStatus(\"Not_Found\", \"can't find \\\"$EU_READELF\\\" command\");\n    }\n    \n    if(-s $Path > 1024*1024*100) {\n        $TooBig = 1;\n    }\n    \n    my $AddOpt = \"\";\n    if(not defined $AddrToName)\n    { # disable search of symbol names\n        $AddOpt .= \" -N\";\n    }\n    \n    my $Sect = `$EU_READELF_L -S \\\"$Path\\\" 2>\\\"$TMP_DIR/error\\\"`;\n    \n    if($Sect!~/\\.z?debug_info/)\n    { # No DWARF info\n        if(my $DebugFile = getDebugFile($Path, \"gnu_debuglink\"))\n        {\n            my $DPath = $DebugFile;\n            my $DName = getFilename($DPath);\n            \n            printMsg(\"INFO\", \"Found link to $DName (gnu_debuglink)\");\n            \n            if(my $DDir = getDirname($Path))\n            {\n                $DPath = $DDir.\"/\".$DPath;\n            }\n            \n            my $Found = undef;\n            \n            if(defined $SearchDirDebuginfo)\n            {\n                if(-f $SearchDirDebuginfo.\"/\".$DName) {\n                    $Found = $SearchDirDebuginfo.\"/\".$DName;\n                }\n                else\n                {\n                    my @Files = findFiles($SearchDirDebuginfo, \"f\");\n                    \n                    foreach my $F (@Files)\n                    {\n                        if(getFilename($F) eq $DName)\n                        {\n                            $Found = $F;\n                            last;\n                        }\n                    }\n                }\n            }\n            elsif(-f $DPath\n            and $DPath ne $Path) {\n                $Found = $DPath;\n            }\n            \n            if($Found and $Found ne $Path)\n            {\n                printMsg(\"INFO\", \"Reading debug-info file $DName linked from gnu_debuglink\");\n                return readDWARFInfo($Found);\n            }\n            else\n            {\n                printMsg(\"ERROR\", \"missed debug-info file $DName linked from gnu_debuglink (try --search-debuginfo=DIR option)\");\n                return 0;\n            }\n        }\n        return 0;\n    }\n    elsif(not defined $AltDebugInfoOpt)\n    {\n        if($Sect=~/\\.gnu_debugaltlink/)\n        {\n            if(my $AltObj = getDebugAltLink($Path))\n            {\n                $AltDebugInfo = $AltObj;\n                readAltInfo($AltObj);\n            }\n            else {\n                exitStatus(\"Error\", \"can't read gnu_debugaltlink\");\n            }\n        }\n    }\n    \n    if($AltDebugInfo)\n    {\n        if($TooBig) {\n            printMsg(\"WARNING\", \"input object is compressed and large, may require a lot of RAM memory to process\");\n        }\n    }\n    \n    printMsg(\"INFO\", \"Reading debug-info\");\n    \n    my $ExtraPath = undef;\n    \n    # ELF header\n    if($ExtraInfo)\n    {\n        mkpath($ExtraInfo);\n        $ExtraPath = $ExtraInfo.\"/elf-header\";\n    }\n    \n    if($ExtraPath)\n    {\n        system($EU_READELF_L.\" -h \\\"$Path\\\" 2>\\\"$TMP_DIR/error\\\" >\\\"$ExtraPath\\\"\");\n        open(HEADER, $ExtraPath);\n    }\n    else {\n        open(HEADER, $EU_READELF_L.\" -h \\\"$Path\\\" 2>\\\"$TMP_DIR/error\\\" |\");\n    }\n    \n    my %Header = ();\n    while(<HEADER>)\n    {\n        if(/\\A\\s*([\\w ]+?)\\:\\s*(.+?)\\Z/) {\n            $Header{$1} = $2;\n        }\n    }\n    close(HEADER);\n    \n    $SYS_ARCH = $Header{\"Machine\"};\n    \n    if($SYS_ARCH=~/80\\d86/\n    or $SYS_ARCH=~/i\\d86/)\n    { # i386, i586, etc.\n        $SYS_ARCH = \"x86\";\n    }\n    \n    if($SYS_ARCH=~/amd64/i\n    or $SYS_ARCH=~/x86\\-64/i)\n    { # amd64\n        $SYS_ARCH = \"x86_64\";\n    }\n    \n    initRegs();\n    \n    # ELF sections\n    if($ExtraInfo)\n    {\n        mkpath($ExtraInfo);\n        $ExtraPath = $ExtraInfo.\"/elf-sections\";\n    }\n    \n    if($ExtraPath)\n    {\n        system($EU_READELF_L.\" -S \\\"$Path\\\" 2>\\\"$TMP_DIR/error\\\" >\\\"$ExtraPath\\\"\");\n        open(HEADER, $ExtraPath);\n    }\n    \n    # source info\n    if($ExtraInfo)\n    {\n        mkpath($ExtraInfo);\n        $ExtraPath = $ExtraInfo.\"/debug_line\";\n    }\n    \n    if($ExtraPath)\n    {\n        system($EU_READELF_L.\" $AddOpt --debug-dump=line \\\"$Path\\\" 2>\\\"$TMP_DIR/error\\\" >\\\"$ExtraPath\\\"\");\n        open(SRC, $ExtraPath);\n    }\n    else {\n        open(SRC, $EU_READELF_L.\" $AddOpt --debug-dump=line \\\"$Path\\\" 2>\\\"$TMP_DIR/error\\\" |\");\n    }\n    \n    my $Offset = undef;\n    my $DirTable_Def = undef;\n    my %DirTable = ();\n    \n    while(<SRC>)\n    {\n        if(defined $AddDirs)\n        {\n            if(/Directory table/i)\n            {\n                $DirTable_Def = 1;\n                %DirTable = ();\n                next;\n            }\n            elsif(/File name table/i)\n            {\n                $DirTable_Def = undef;\n                next;\n            }\n            \n            if(defined $DirTable_Def)\n            {\n                if(/\\A\\s*([^\\[\\]\\(\\)]+?)\\Z/) {\n                    $DirTable{keys(%DirTable)+1} = $1;\n                }\n                elsif(/\\A\\s*(\\d+)\\s+(.+?)\\s+\\(\\d+\\)\\Z/)\n                { # F34\n                    $DirTable{$1} = $2;\n                }\n            }\n        }\n        \n        if(index($_, \"Table\")!=-1\n        and /Table at offset (\\w+)/) {\n            $Offset = $1;\n        }\n        elsif(defined $Offset)\n        {\n            my ($Num, $Dir, $File) = ();\n            \n            if(/(\\d+)\\s+(\\d+)\\s+\\d+\\s+\\d+\\s+([^ ]+)/) {\n                ($Num, $Dir, $File) = ($1, $2, $3);\n            }\n            elsif(/(\\d+)\\s+([^ ]+)\\s+\\(\\d+\\)\\,\\s+(\\d+)/)\n            { # F34\n                ($Num, $File, $Dir) = ($1, $2, $3);\n            }\n            \n            if($File)\n            {\n                chomp($File);\n                \n                if(defined $AddDirs)\n                {\n                    if(my $DName = $DirTable{$Dir})\n                    {\n                        $File = $DName.\"/\".$File;\n                    }\n                }\n                \n                $SourceFile{$Offset}{$Num} = $File;\n            }\n        }\n    }\n    close(SRC);\n    \n    # debug_loc\n    if($ExtraInfo)\n    {\n        mkpath($ExtraInfo);\n        $ExtraPath = $ExtraInfo.\"/debug_loc\";\n    }\n    \n    if($ExtraPath)\n    {\n        system($EU_READELF_L.\" $AddOpt --debug-dump=loc \\\"$Path\\\" 2>\\\"$TMP_DIR/error\\\" >\\\"$ExtraPath\\\"\");\n        open(LOC, $ExtraPath);\n    }\n    else {\n        open(LOC, $EU_READELF_L.\" $AddOpt --debug-dump=loc \\\"$Path\\\" 2>\\\"$TMP_DIR/error\\\" |\");\n    }\n    \n    my $Offset = undef;\n    \n    while(<LOC>)\n    {\n        if(/\\A \\[\\s*(\\w+)\\].*\\[\\s*\\w+\\]\\s*(.+)\\Z/) {\n            $DebugLoc{$1} = $2;\n        }\n        elsif(/\\A \\[\\s*(\\w+)\\]/) {\n            $DebugLoc{$1} = \"\";\n        }\n        elsif(/Offset:\\s+(.+?),/)\n        { # F34\n            $Offset = $1;\n        }\n        elsif($Offset and /\\A\\s+\\[\\s*\\w+\\]\\s*(.+)\\Z/)\n        { # F34\n            $DebugLoc{$Offset} = $1;\n        }\n    }\n    close(LOC);\n    \n    # dwarf\n    if($ExtraInfo)\n    {\n        mkpath($ExtraInfo);\n        $ExtraPath = $ExtraInfo.\"/debug_info\";\n    }\n    \n    my $INFO_fh;\n    \n    if($Dir)\n    { # to find \".dwz\" directory (Fedora)\n        chdir($Dir);\n    }\n    if($ExtraPath)\n    {\n        system($EU_READELF_L.\" $AddOpt --debug-dump=info \\\"$Name\\\" 2>\\\"$TMP_DIR/error\\\" >\\\"$ExtraPath\\\"\");\n        open($INFO_fh, $ExtraPath);\n    }\n    else {\n        open($INFO_fh, $EU_READELF_L.\" $AddOpt --debug-dump=info \\\"$Name\\\" 2>\\\"$TMP_DIR/error\\\" |\");\n    }\n    chdir($ORIG_DIR);\n    \n    readDWARFDump($INFO_fh, 1);\n    \n    if(my $Err = readFile(\"$TMP_DIR/error\"))\n    { # eu-readelf: cannot get next DIE: invalid DWARF\n        if($Err=~/invalid DWARF/i)\n        {\n            if($Loud) {\n                printMsg(\"ERROR\", $Err);\n            }\n            exitStatus(\"Invalid_DWARF\", \"invalid DWARF info\");\n        }\n    }\n    \n    return 1;\n}\n\nsub getSource($)\n{\n    my $ID = $_[0];\n    \n    if(defined $DWARF_Info{$ID}{\"file\"})\n    {\n        my $File = $DWARF_Info{$ID}{\"file\"};\n        my $Unit = $DWARF_Info{$ID}{\"unit\"};\n        \n        my $Name = undef;\n        \n        if($ID>=0) {\n            $Name = $SourceFile{$Unit}{$File};\n        }\n        else\n        { # imported\n            $Name = $SourceFile_Alt{0}{$File};\n        }\n        \n        return $Name;\n    }\n    \n    return undef;\n}\n\nsub readDWARFDump($$)\n{\n    my ($FH, $Primary) = @_;\n    \n    my $TypeUnit_Sign = undef;\n    my $TypeUnit_Offset = undef;\n    my $Type_Offset = undef;\n    \n    my $Shift_Enabled = 1;\n    my $ID_Shift = undef;\n    \n    my $CUnit = undef;\n    \n    if($AltDebugInfo) {\n        $Compressed = 1;\n    }\n    \n    my $ID = undef;\n    my $Kind = undef;\n    my $NS = undef;\n    \n    my $MAX_ID = undef;\n    \n    my %Shift = map {$_=>1} (\n        \"specification\",\n        \"spec\",\n        \"type\",\n        \"sibling\",\n        \"object_pointer\",\n        \"objptr\",\n        \"containing_type\",\n        \"container\",\n        \"abstract_origin\",\n        \"orig\",\n        \"import\",\n        \"signature\"\n    );\n    \n    my %SkipNode = (\n        \"imported_declaration\" => 1,\n        \"imported_module\" => 1\n    );\n    \n    my %SkipAttr = (\n        \"high_pc\" => 1,\n        \"frame_base\" => 1,\n        \"encoding\" => 1,\n        \"Compilation\" => 1,\n        \"comp_dir\" => 1,\n        \"declaration\" => 1,\n        \"prototyped\" => 1,\n        \"GNU_vector\" => 1,\n        \"GNU_all_call_sites\" => 1,\n        \"explicit\" => 1\n    );\n    \n    my %RenameAttr = (\n        \"data_member_location\" => \"mloc\",\n        \"decl_file\" => \"file\",\n        \"decl_line\" => \"line\",\n        \"linkage_name\" => \"linkage\",\n        \"object_pointer\" => \"objptr\",\n        \"artificial\" => \"art\",\n        \"external\" => \"ext\",\n        \"specification\" => \"spec\",\n        \"byte_size\" => \"size\",\n        \"accessibility\" => \"access\",\n        \"const_value\" => \"cval\",\n        \"containing_type\" => \"container\",\n        \"abstract_origin\" => \"orig\",\n        \"virtuality\" => \"virt\",\n        \"vtable_elem_location\" => \"vloc\"\n    );\n    \n    my %RenameKind = (\n        \"formal_parameter\" => \"param\",\n        \"subprogram\" => \"prog\",\n        \"unspecified_parameters\" => \"unspec_params\",\n        \"template_type_parameter\" => \"tmpl_param\"\n    );\n    \n    my %MarkByUnit = (\n        \"member\" => 1,\n        \"subprogram\" => 1,\n        \"prog\" => 1,\n        \"variable\" => 1\n    );\n    \n    my $Lexical_Block = undef;\n    my $Inlined_Block = undef;\n    my $Subprogram_Block = undef;\n    my $Skip_Block = undef;\n    \n    while(my $Line = <$FH>)\n    {\n        if(defined $ID and $Line=~/\\A\\s*(\\w+)\\s+(.+?)\\s*\\Z/)\n        {\n            if(defined $Skip_Block) {\n                next;\n            }\n            \n            my $Attr = $1;\n            my $Val = $2;\n            \n            if(defined $RenameAttr{$Attr}) {\n                $Attr = $RenameAttr{$Attr};\n            }\n            \n            if(index($Val, \"(flag\")==0)\n            { # artificial, external (on Fedora)\n              # flag_present\n                $Val = 1;\n            }\n            \n            if(defined $Compressed)\n            {\n                if($Kind eq \"imported_unit\") {\n                    next;\n                }\n            }\n            \n            if($Kind eq \"member\")\n            {\n                if($Attr eq \"mloc\") {\n                    delete($DWARF_Info{$ID}{\"unit\"});\n                }\n            }\n            \n            if($Attr eq \"sibling\")\n            {\n                if($Kind ne \"structure_type\") {\n                    next;\n                }\n            }\n            elsif($Attr eq \"Type\")\n            {\n                if($Line=~/Type\\s+signature:\\s*0x(\\w+)/) {\n                    $TypeUnit_Sign = $1;\n                }\n                if($Line=~/Type\\s+offset:\\s*0x(\\w+)/) {\n                    $Type_Offset = hex($1);\n                }\n                if($Line=~/Type\\s+unit\\s+at\\s+offset\\s+(\\d+)/) {\n                    $TypeUnit_Offset = $1;\n                }\n                next;\n            }\n            elsif(defined $SkipAttr{$Attr})\n            { # unused\n                next;\n            }\n            \n            if($Val=~/\\A\\s*\\(([^()]*)\\)\\s*\\[\\s*(\\w+)\\]\\s*\\Z/)\n            { # ref4, ref_udata, ref_addr, etc.\n                $Val = hex($2);\n                \n                if($1 eq \"GNU_ref_alt\") {\n                    $Val = -$Val;\n                }\n            }\n            elsif($Attr eq \"name\")\n            {\n                $Val=~s/\\A\\([^()]*\\)\\s*\\\"(.*)\\\"\\Z/$1/;\n                \n                if(defined $LambdaSupport)\n                {\n                    if(index($Val, \"<lambda(\")==0)\n                    {\n                        $Val=~s/\\A</{/;\n                        $Val=~s/>\\Z/}/;\n                    }\n                }\n            }\n            elsif(index($Attr, \"linkage_name\")!=-1 or $Attr eq \"linkage\")\n            {\n                $Val=~s/\\A\\([^()]*\\)\\s*\\\"(.*)\\\"\\Z/$1/;\n                $Attr = \"linkage\";\n            }\n            elsif(index($Attr, \"location\")!=-1 or $Attr eq \"mloc\" or $Attr eq \"vloc\")\n            {\n                if($Val=~/\\)\\s*\\Z/)\n                { # value on the next line\n                    my $NL = <$FH>;\n                    $Val .= $NL;\n\n                    if(defined $ExtraDump)\n                    {\n                        if($NL=~/\\A\\s{4,}\\[\\s*(\\w+)\\]\\s*(piece \\d+|\\w+)/)\n                        {\n                            $FullLoc{$ID}{$1} = $2;\n                        }\n                    }\n                    \n                    if(index($Val, \"GNU_entry_value\")!=-1)\n                    { # value on the next line\n                        $NL = <$FH>;\n                        $Val .= $NL;\n                    }\n                }\n                \n                if($Val=~/\\A\\(\\w+\\)\\s*(-?)(\\w+)\\Z/)\n                { # (data1) 1c\n                    if ($2 != 0xFFFFFFFFFFFFFFFF) {\n                        $Val = hex($2);\n                        if($1) {\n                            $Val = -$Val;\n                       }\n                    }\n                }\n                else\n                {\n                    if($Val=~/ (-?\\d+)\\Z/) {\n                        $Val = $1;\n                    }\n                    else\n                    {\n                        if($Attr eq \"location\"\n                        and $Kind eq \"param\")\n                        {\n                            if($Val=~/location list\\s+\\[\\s*(\\w+)\\]\\Z/)\n                            {\n                                $Attr = \"location_list\";\n                                $Val = $1;\n                            }\n                            elsif($Val=~/ reg(\\d+)\\Z/)\n                            {\n                                $Attr = \"register\";\n                                $Val = $1;\n                            }\n                        }\n                    }\n                }\n            }\n            elsif($Attr eq \"access\")\n            {\n                $Val=~s/\\A\\(.+?\\)\\s*//;\n                $Val=~s/\\s*\\(.+?\\)\\Z//;\n                \n                # NOTE: members: private by default\n            }\n            else\n            {\n                $Val=~s/\\A\\(\\w+\\)\\s*//;\n                \n                if(substr($Val, 0, 1) eq \"{\"\n                and $Val=~/{(.+)}/)\n                { # {ID}\n                    $Val = $1;\n                    $Post_Change{$ID} = 1;\n                }\n            }\n            \n            if($Val eq \"\")\n            {\n                if($Attr eq \"ext\") {\n                    next;\n                }\n            }\n            \n            if(defined $Shift_Enabled and $ID_Shift)\n            {\n                if(defined $Shift{$Attr}\n                and not $Post_Change{$ID}) {\n                    $Val += $ID_Shift;\n                }\n                \n                # $DWARF_Info{$ID}{\"rID\"} = $ID-$ID_Shift;\n            }\n            \n            if(not $Primary)\n            {\n                if(defined $Shift{$Attr}) {\n                    $Val = -$Val;\n                }\n            }\n            \n            if($Kind ne \"partial_unit\"\n            and $Kind ne \"imported_unit\")\n            {\n                if($Attr ne \"stmt_list\") {\n                    $DWARF_Info{$ID}{$Attr} = \"$Val\";\n                }\n            }\n            \n            if($Kind eq \"compile_unit\")\n            {\n                if($Attr eq \"stmt_list\")\n                {\n                    $CUnit = $Val;\n                    $Partial = undef\n                }\n                \n                if(not defined $LIB_LANG)\n                {\n                    if($Attr eq \"language\")\n                    {\n                        if(index($Val, \"Assembler\")==-1)\n                        {\n                            $Val=~s/\\s*\\(.+?\\)\\Z//;\n                            \n                            if($Val=~/C\\d/i) {\n                                $LIB_LANG = \"C\";\n                            }\n                            elsif($Val=~/C\\+\\+|C_plus_plus/i) {\n                                $LIB_LANG = \"C++\";\n                            }\n                            else {\n                                $LIB_LANG = $Val;\n                            }\n                        }\n                    }\n                }\n                \n                if(not defined $SYS_COMP and not defined $SYS_GCCV)\n                {\n                    if($Attr eq \"producer\")\n                    {\n                        if(index($Val, \"GNU AS\")==-1)\n                        {\n                            $Val=~s/\\A\\\"//;\n                            $Val=~s/\\\"\\Z//;\n                            \n                            if($Val=~/GNU\\s+(C\\d*|C\\+\\+\\d*|GIMPLE)\\s+(.+)\\Z/)\n                            {\n                                $SYS_GCCV = $2;\n                                if($SYS_GCCV=~/\\A(\\d+\\.\\d+)(\\.\\d+|)/)\n                                { # 4.6.1 20110627 (Mandriva)\n                                    $SYS_GCCV = $1.$2;\n                                }\n                            }\n                            elsif($Val=~/clang\\s+version\\s+([^\\s\\(]+)/) {\n                                $SYS_CLANGV = $1;\n                            }\n                            else {\n                                $SYS_COMP = $Val;\n                            }\n                            \n                            if(not defined $KeepRegsAndOffsets)\n                            {\n                                my %Opts = ();\n                                while($Val=~s/(\\A| )(\\-O([0-3]|g))( |\\Z)/ /) {\n                                    $Opts{keys(%Opts)} = $2;\n                                }\n                                \n                                if(keys(%Opts))\n                                {\n                                    if($Opts{keys(%Opts)-1} ne \"-Og\")\n                                    {\n                                        if(not defined $Quiet) {\n                                            printMsg(\"WARNING\", \"incompatible build option detected: \".$Opts{keys(%Opts)-1}.\" (required -Og for better analysis)\");\n                                        }\n                                        $IncompatibleOpt = 1;\n                                    }\n                                }\n                                else\n                                {\n                                    if(not defined $Quiet) {\n                                        printMsg(\"WARNING\", \"the object should be compiled with -Og option for better analysis\");\n                                    }\n                                    $IncompatibleOpt = 1;\n                                }\n                            }\n                            \n                            if(index($Val, \"-fkeep-inline-functions\")!=-1) {\n                                $FKeepInLine = 1;\n                            }\n                        }\n                    }\n                }\n            }\n            elsif($Kind eq \"type_unit\")\n            {\n                if($Attr eq \"stmt_list\")\n                {\n                    $CUnit = $Val;\n                    $Partial = 1;\n                }\n            }\n            elsif($Kind eq \"partial_unit\")\n            { # support for dwz\n                if($Attr eq \"stmt_list\")\n                {\n                    $CUnit = $Val;\n                    $Partial = 1;\n                }\n            }\n        }\n        elsif(defined $ExtraDump and $Line=~/\\A\\s{4,}\\[\\s*(\\w+)\\]\\s*(piece \\d+|\\w+)/)\n        {\n            $FullLoc{$ID}{$1} = $2;\n        }\n        elsif($Line=~/\\A \\[\\s*(\\w+)\\](\\s*)(\\w+)/)\n        {\n            $ID = hex($1);\n            $NS = length($2);\n            $Kind = $3;\n            \n            if(defined $RenameKind{$Kind}) {\n                $Kind = $RenameKind{$Kind};\n            }\n            \n            if(not defined $Compressed)\n            {\n                if($Kind eq \"partial_unit\" or $Kind eq \"type_unit\")\n                { # compressed debug_info\n                    $Compressed = 1;\n                    \n                    if($TooBig) {\n                        printMsg(\"WARNING\", \"input object is compressed and large, may require a lot of RAM memory to process\");\n                    }\n                }\n            }\n            \n            if($Kind eq \"compile_unit\" and $CUnit\n            and not defined $AllUnits)\n            { # read the previous compile unit\n                completeDump($Primary);\n                \n                if($Primary) {\n                    readABI();\n                }\n            }\n            \n            $Skip_Block = undef;\n            \n            if(defined $SkipNode{$Kind})\n            {\n                $Skip_Block = 1;\n                next;\n            }\n            \n            if($Kind eq \"lexical_block\")\n            {\n                if(defined $Lexical_Block)\n                {\n                    if(length($NS)<=length($Lexical_Block)) {\n                        $Lexical_Block = $NS;\n                    }\n                }\n                else {\n                    $Lexical_Block = $NS;\n                }\n                $Skip_Block = 1;\n                next;\n            }\n            else\n            {\n                if(defined $Lexical_Block)\n                {\n                    if($NS>$Lexical_Block)\n                    {\n                        $LexicalId{$ID} = 1;\n                        if(not $LambdaSupport)\n                        {\n                            $Skip_Block = 1;\n                            next;\n                        }\n                    }\n                    else\n                    { # end of lexical block\n                        $Lexical_Block = undef;\n                    }\n                }\n            }\n            \n            if($Kind eq \"inlined_subroutine\")\n            {\n                $Inlined_Block = $NS;\n                $Skip_Block = 1;\n                next;\n            }\n            else\n            {\n                if(defined $Inlined_Block)\n                {\n                    if($NS>$Inlined_Block)\n                    {\n                        $Skip_Block = 1;\n                        next;\n                    }\n                    else\n                    { # end of inlined subroutine\n                        $Inlined_Block = undef;\n                    }\n                }\n            }\n            \n            if($Kind eq \"prog\")\n            {\n                $Subprogram_Block = $NS;\n            }\n            else\n            {\n                if(defined $Subprogram_Block)\n                {\n                    if($NS>$Subprogram_Block)\n                    {\n                        if($Kind eq \"variable\")\n                        { # temp variables\n                            $Skip_Block = 1;\n                            next;\n                        }\n                    }\n                    else\n                    { # end of subprogram block\n                        $Subprogram_Block = undef;\n                    }\n                }\n            }\n            \n            if(not $Primary) {\n                $ID = -$ID;\n            }\n            \n            if(defined $Shift_Enabled)\n            {\n                if($Kind eq \"type_unit\")\n                {\n                    if(not defined $ID_Shift)\n                    {\n                        if($ID_Shift<=$MAX_ID) {\n                            $ID_Shift = $MAX_ID;\n                        }\n                        else {\n                            $ID_Shift = 0;\n                        }\n                    }\n                }\n                \n                if($ID_Shift) {\n                    $ID += $ID_Shift;\n                }\n            }\n            \n            if(defined $TypeUnit_Sign)\n            {\n                if($Kind ne \"type_unit\"\n                and $Kind ne \"namespace\")\n                {\n                    if($TypeUnit_Offset+$Type_Offset+$ID_Shift==$ID)\n                    {\n                        $TypeUnit{$TypeUnit_Sign} = \"$ID\";\n                        $TypeUnit_Sign = undef;\n                    }\n                }\n            }\n            \n            if($Kind ne \"partial_unit\"\n            and $Kind ne \"imported_unit\")\n            {\n                $DWARF_Info{$ID} = {};\n                $DWARF_Info{$ID}{\"kind\"} = $Kind;\n                $DWARF_Info{$ID}{\"ns\"} = $NS;\n                \n                if(defined $CUnit)\n                {\n                    if(defined $MarkByUnit{$Kind}\n                    or defined $TypeType{$Kind}) {\n                        $DWARF_Info{$ID}{\"unit\"} = $CUnit;\n                    }\n                }\n                \n                if($ID>0) {\n                    push(@IDs, $ID);\n                }\n                else {\n                    push(@IDs_I, $ID);\n                }\n            }\n            \n            if(not defined $ID_Shift) {\n                $MAX_ID = $ID;\n            }\n        }\n        elsif(not defined $SYS_WORD\n        and $Line=~/Address\\s*size:\\s*(\\d+)/i)\n        {\n            $SYS_WORD = $1;\n        }\n    }\n    \n    close($FH);\n    \n    if($Primary and not defined $ID) {\n        printMsg(\"ERROR\", \"the debuginfo looks empty or corrupted\");\n    }\n    \n    # read the last compile unit\n    completeDump($Primary);\n    \n    if($Primary) {\n        readABI();\n    }\n}\n\nsub readVtables($)\n{\n    my $Path = $_[0];\n    \n    $Path = abs_path($Path);\n    \n    my $Dir = getDirname($Path);\n    \n    if(index($LIB_LANG, \"C++\")!=-1\n    or $OBJ_LANG eq \"C++\")\n    {\n        printMsg(\"INFO\", \"Reading v-tables\");\n        \n        if(checkCmd($VTABLE_DUMPER))\n        {\n            if(my $Version = `$VTABLE_DUMPER -dumpversion`)\n            {\n                if(cmpVersions($Version, $VTABLE_DUMPER_VERSION)<0)\n                {\n                    printMsg(\"ERROR\", \"the version of Vtable-Dumper should be $VTABLE_DUMPER_VERSION or newer\");\n                    return;\n                }\n            }\n        }\n        else\n        {\n            printMsg(\"ERROR\", \"cannot find \\'$VTABLE_DUMPER\\'\");\n            return;\n        }\n        \n        my $ExtraPath = $TMP_DIR.\"/v-tables\";\n        \n        if($ExtraInfo)\n        {\n            mkpath($ExtraInfo);\n            $ExtraPath = $ExtraInfo.\"/v-tables\";\n        }\n        \n        my $LdPaths = $Dir;\n        \n        if(defined $LdLibraryPath) {\n            $LdPaths .= \":\".$LdLibraryPath;\n        }\n        \n        system(\"LD_LIBRARY_PATH=\\\"$LdPaths\\\" $VTABLE_DUMPER -mangled -demangled \\\"$Path\\\" >\\\"$ExtraPath\\\"\");\n        \n        my $Content = readFile($ExtraPath);\n        foreach my $ClassInfo (split(/\\n\\n\\n/, $Content))\n        {\n            if($ClassInfo=~/\\AVtable\\s+for\\s+(.+)\\n((.|\\n)+)\\Z/i)\n            {\n                my ($CName, $VTable) = ($1, $2);\n                my @Entries = split(/\\n/, $VTable);\n                \n                foreach (1 .. $#Entries)\n                {\n                    my $Entry = $Entries[$_];\n                    if($Entry=~/\\A(\\d+)\\s+(.+)\\Z/) {\n                        $VirtualTable{$CName}{$1} = $2;\n                    }\n                }\n\n                if(defined $ExtraDump)\n                {\n                    if($Entries[0]=~/\\A(\\w+)\\:/)\n                    {\n                        $VTable_Symbol{$CName} = $1;\n                        $VTable_Class{$1} = $CName;\n                    }\n                }\n            }\n        }\n    }\n    \n    if(keys(%VirtualTable))\n    {\n        foreach my $Tid (sort keys(%TypeInfo))\n        {\n            if($TypeInfo{$Tid}{\"Type\"}=~/\\A(Struct|Class)\\Z/)\n            {\n                my $TName = $TypeInfo{$Tid}{\"Name\"};\n                $TName=~s/\\bstruct //g;\n                if(defined $VirtualTable{$TName})\n                {\n                    $TypeInfo{$Tid}{\"VTable\"} = $VirtualTable{$TName};\n\n                    if(defined $ExtraDump)\n                    {\n                        $TypeInfo{$Tid}{\"VTable_Sym\"} = $VTable_Symbol{$TName};\n                    }\n                    $TypeInfo{$Tid}{\"VTable\"} = $VirtualTable{$TName};\n                }\n            }\n        }\n    }\n}\n\nsub createArchive($$)\n{\n    my ($Path, $To) = @_;\n    if(not $To) {\n        $To = \".\";\n    }\n    \n    if(not checkCmd(\"tar\")) {\n        exitStatus(\"Not_Found\", \"can't find \\\"tar\\\"\");\n    }\n    if(not checkCmd(\"gzip\")) {\n        exitStatus(\"Not_Found\", \"can't find \\\"gzip\\\"\");\n    }\n    \n    my ($From, $Name) = sepPath($Path);\n    my $Pkg = abs_path($To).\"/\".$Name.\".\".$COMPRESS;\n    if(-e $Pkg) {\n        unlink($Pkg);\n    }\n    system(\"tar\", \"-C\", $From, \"-czf\", $Pkg, $Name);\n    if($?)\n    { # cannot allocate memory (or other problems with \"tar\")\n        exitStatus(\"Error\", \"can't pack the ABI dump: \".$!);\n    }\n    unlink($Path);\n    return $To.\"/\".$Name.\".\".$COMPRESS;\n}\n\nsub createABIFile()\n{\n    printMsg(\"INFO\", \"Creating ABI dump\");\n    \n    my %ABI = (\n        \"TypeInfo\" => \\%TypeInfo,\n        \"SymbolInfo\" => \\%SymbolInfo,\n        \"Symbols\" => \\%Library_Symbol,\n        \"UndefinedSymbols\" => \\%Library_UndefSymbol,\n        \"Needed\" => \\%Library_Needed,\n        \"SymbolVersion\" => \\%SymVer,\n        \"LibraryVersion\" => $TargetVersion,\n        \"LibraryName\" => $TargetName,\n        \"Language\" => $LIB_LANG,\n        \"Headers\" => \\%HeadersInfo,\n        \"Sources\" => \\%SourcesInfo,\n        \"NameSpaces\" => \\%NestedNameSpaces,\n        \"Target\" => \"unix\",\n        \"Arch\" => $SYS_ARCH,\n        \"WordSize\" => $SYS_WORD,\n        \"ABI_DUMP_VERSION\" => $ABI_DUMP_VERSION,\n        \"ABI_DUMPER_VERSION\" => $TOOL_VERSION,\n    );\n    \n    if($SYS_GCCV) {\n        $ABI{\"GccVersion\"} = $SYS_GCCV;\n    }\n    elsif($SYS_CLANGV) {\n        $ABI{\"ClangVersion\"} = $SYS_CLANGV;\n    }\n    else {\n        $ABI{\"Compiler\"} = $SYS_COMP;\n    }\n\n    if(defined $ExtraDump) {\n        $ABI{\"ExtraDump\"} = \"On\";\n    }\n\n    if(defined $PublicHeadersPath) {\n        $ABI{\"PublicABI\"} = \"1\";\n    }\n    \n    if(defined $IncompatibleOpt)\n    {\n        $ABI{\"MissedOffsets\"} = \"1\";\n        $ABI{\"MissedRegs\"} = \"1\";\n    }\n    \n    if($StdOut)\n    { # --stdout option\n        print STDOUT Dumper(\\%ABI);\n    }\n    else\n    {\n        my $DumpPath = \"ABI.dump\";\n        if($OutputDump)\n        { # user defined path\n            $DumpPath = $OutputDump;\n        }\n        my $Archive = ($DumpPath=~s/\\Q.$COMPRESS\\E\\Z//g);\n        my ($DDir, $DName) = sepPath($DumpPath);\n        \n        my $DPath = $TMP_DIR.\"/\".$DName;\n        if(not $Archive) {\n            $DPath = $DumpPath;\n        }\n        \n        mkpath($DDir);\n        \n        open(DUMP, \">\", $DPath) || die (\"can't open file \\'$DumpPath\\': $!\\n\");\n        print DUMP Dumper(\\%ABI);\n        close(DUMP);\n        \n        if(not -s $DPath) {\n            exitStatus(\"Error\", \"can't create ABI dump because something is going wrong with the Data::Dumper module\");\n        }\n        if($Archive) {\n            $DumpPath = createArchive($DPath, $DDir);\n        }\n        \n        printMsg(\"INFO\", \"\\nThe object ABI has been dumped to:\\n  $DumpPath\");\n    }\n}\n\nsub unmangleString($)\n{\n    my $Str = $_[0];\n    \n    $Str=~s/\\AN(.+)E\\Z/$1/;\n    while($Str=~s/\\A(\\d+)//)\n    {\n        if(length($Str)==$1) {\n            last;\n        }\n        \n        $Str = substr($Str, $1, length($Str) - $1);\n    }\n    \n    return $Str;\n}\n\nsub initABI()\n{\n    # register \"void\" type\n    %{$TypeInfo{\"1\"}} = (\n        \"Name\"=>\"void\",\n        \"Type\"=>\"Intrinsic\"\n    );\n    $TName_Tid{\"Intrinsic\"}{\"void\"} = \"1\";\n    $TName_Tids{\"Intrinsic\"}{\"void\"}{\"1\"} = 1;\n    $Cache{\"getTypeInfo\"}{\"1\"} = 1;\n    \n    # register \"...\" type\n    %{$TypeInfo{\"-1\"}} = (\n        \"Name\"=>\"...\",\n        \"Type\"=>\"Intrinsic\"\n    );\n    $TName_Tid{\"Intrinsic\"}{\"...\"} = \"-1\";\n    $TName_Tids{\"Intrinsic\"}{\"...\"}{\"-1\"} = 1;\n    $Cache{\"getTypeInfo\"}{\"-1\"} = 1;\n}\n\nsub completeDump($)\n{\n    my $Primary = $_[0];\n    \n    foreach my $ID (keys(%Post_Change))\n    {\n        if(my $Type = $DWARF_Info{$ID}{\"type\"})\n        {\n            if(my $To = $TypeUnit{$Type}) {\n                $DWARF_Info{$ID}{\"type\"} = $To;\n            }\n        }\n        if(my $Signature = $DWARF_Info{$ID}{\"signature\"})\n        {\n            if(my $To = $TypeUnit{$Signature}) {\n                $DWARF_Info{$ID}{\"signature\"} = $To;\n            }\n        }\n    }\n    \n    %Post_Change = ();\n    %TypeUnit = ();\n}\n\nmy %IsType = map {$_=>1} (\n    \"struct_type\",\n    \"structure_type\",\n    \"class_type\",\n    \"union_type\",\n    \"enumeration_type\",\n    \"subroutine_type\",\n    \"array_type\"\n);\n\nmy %MainKind = map {$_=>1} (\n    \"typedef\",\n    \"subprogram\",\n    \"prog\",\n    \"variable\",\n    \"namespace\"\n);\n\nsub readABI()\n{\n    my %CurID = ();\n    \n    if(@IDs_I) {\n        @IDs = (@IDs_I, @IDs);\n    }\n    \n    my $TPack = undef;\n    my $PPack = undef;\n    my $NS_Pre = undef;\n    \n    foreach my $ID (@IDs)\n    {\n        $ID = \"$ID\";\n        \n        my $Kind = $DWARF_Info{$ID}{\"kind\"};\n        my $NS = $DWARF_Info{$ID}{\"ns\"};\n        my $Scope = $CurID{$NS-2};\n        \n        if(defined $NS_Pre and $NS<=$NS_Pre)\n        {\n            foreach (0 .. $NS_Pre-$NS) {\n                delete($CurID{$NS+$_});\n            }\n        }\n        \n        $NS_Pre = $NS;\n        \n        if($Kind eq \"typedef\")\n        {\n            if($DWARF_Info{$Scope}{\"kind\"} eq \"prog\")\n            {\n                $NS = $DWARF_Info{$Scope}{\"ns\"};\n                $Scope = $CurID{$NS-2};\n            }\n        }\n        \n        if($Kind ne \"prog\") {\n            delete($DWARF_Info{$ID}{\"ns\"});\n        }\n        \n        if(defined $IsType{$Kind}\n        or defined $MainKind{$Kind})\n        {\n            if($Kind ne \"variable\"\n            and $Kind ne \"typedef\")\n            {\n                $CurID{$NS} = $ID;\n            }\n            \n            if($Scope)\n            {\n                $NameSpace{$ID} = $Scope;\n                if($Kind eq \"prog\"\n                or $Kind eq \"variable\")\n                {\n                    if($DWARF_Info{$Scope}{\"kind\"}=~/class|struct/)\n                    {\n                        $ClassMethods{$Scope} = 1;\n                        if(my $Sp = $DWARF_Info{$Scope}{\"spec\"}) {\n                            $ClassMethods{$Sp} = 1;\n                        }\n                    }\n                }\n            }\n            \n            if(my $Spec = $DWARF_Info{$ID}{\"spec\"}) {\n                $SpecElem{$Spec} = $ID;\n            }\n            \n            if(my $Orig = $DWARF_Info{$ID}{\"orig\"}) {\n                $OrigElem{$Orig} = $ID;\n            }\n            \n            if(defined $IsType{$Kind})\n            {\n                if(not $DWARF_Info{$ID}{\"name\"}\n                and $DWARF_Info{$ID}{\"linkage\"})\n                {\n                    $DWARF_Info{$ID}{\"name\"} = unmangleString($DWARF_Info{$ID}{\"linkage\"});\n                    \n                    # free memory\n                    delete($DWARF_Info{$ID}{\"linkage\"});\n                }\n            }\n        }\n        elsif($Kind eq \"member\")\n        {\n            if($Scope)\n            {\n                $NameSpace{$ID} = $Scope;\n                \n                if(not defined $DWARF_Info{$ID}{\"mloc\"}\n                and $DWARF_Info{$Scope}{\"kind\"}=~/class|struct/)\n                { # variable (global data)\n                    next;\n                }\n            }\n            \n            $TypeMember{$Scope}{keys(%{$TypeMember{$Scope}})} = $ID;\n        }\n        elsif($Kind eq \"enumerator\")\n        {\n            $TypeMember{$Scope}{keys(%{$TypeMember{$Scope}})} = $ID;\n        }\n        elsif($Kind eq \"inheritance\")\n        {\n            my %In = ();\n            $In{\"id\"} = $DWARF_Info{$ID}{\"type\"};\n            \n            if(my $Access = $DWARF_Info{$ID}{\"access\"})\n            {\n                if($Access ne \"public\")\n                { # default inheritance access in ABI dump is \"public\"\n                    $In{\"access\"} = $Access;\n                }\n            }\n            \n            if(defined $DWARF_Info{$ID}{\"virt\"}) {\n                $In{\"virtual\"} = 1;\n            }\n            $Inheritance{$Scope}{keys(%{$Inheritance{$Scope}})} = \\%In;\n            \n            # free memory\n            delete($DWARF_Info{$ID});\n        }\n        elsif($Kind eq \"param\")\n        {\n            if(defined $PPack) {\n                $FuncParam{$PPack}{keys(%{$FuncParam{$PPack}})} = $ID;\n            }\n            else {\n                $FuncParam{$Scope}{keys(%{$FuncParam{$Scope}})} = $ID;\n            }\n        }\n        elsif($Kind eq \"unspec_params\")\n        {\n            $FuncParam{$Scope}{keys(%{$FuncParam{$Scope}})} = $ID;\n            $DWARF_Info{$ID}{\"type\"} = \"-1\"; # \"...\"\n        }\n        elsif($Kind eq \"subrange_type\")\n        {\n            if((my $Bound = $DWARF_Info{$ID}{\"upper_bound\"}) ne \"\") {\n                $ArrayCount{$Scope} = $Bound + 1;\n            }\n            \n            # free memory\n            delete($DWARF_Info{$ID});\n        }\n        elsif($Kind eq \"tmpl_param\"\n        or $Kind eq \"template_value_parameter\")\n        {\n            my %Info = (\"key\"=>$DWARF_Info{$ID}{\"name\"});\n            \n            if(defined $DWARF_Info{$ID}{\"type\"}) {\n                $Info{\"type\"} = $DWARF_Info{$ID}{\"type\"};\n            }\n            else { # void\n                $Info{\"type\"} = \"1\";\n            }\n            \n            if(defined $DWARF_Info{$ID}{\"cval\"}) {\n                $Info{\"value\"} = $DWARF_Info{$ID}{\"cval\"};\n            }\n            \n            if(defined $DWARF_Info{$ID}{\"default_value\"}) {\n                $Info{\"default\"} = 1;\n            }\n            \n            if(defined $TPack) {\n                $TmplParam{$TPack}{keys(%{$TmplParam{$TPack}})} = \\%Info;\n            }\n            else {\n                $TmplParam{$Scope}{keys(%{$TmplParam{$Scope}})} = \\%Info;\n            }\n        }\n        elsif($Kind eq \"GNU_template_parameter_pack\") {\n            $TPack = $Scope;\n        }\n        elsif($Kind eq \"GNU_formal_parameter_pack\") {\n            $PPack = $Scope;\n        }\n        \n        if($Kind ne \"GNU_template_parameter_pack\")\n        {\n            if(index($Kind, \"template_\")==-1) {\n                $TPack = undef;\n            }\n        }\n        \n        if($Kind ne \"GNU_formal_parameter_pack\")\n        {\n            if($Kind ne \"param\") {\n                $PPack = undef;\n            }\n        }\n    }\n    \n    # free memory\n    %CurID = ();\n    \n    foreach my $ID (@IDs)\n    {\n        if(not defined $DWARF_Info{$ID}) {\n            next;\n        }\n        \n        if(my $Kind = $DWARF_Info{$ID}{\"kind\"})\n        {\n            if(defined $TypeType{$Kind}\n            and not defined $Cache{\"getTypeInfo\"}{$ID})\n            {\n                getTypeInfo($ID);\n            }\n        }\n    }\n    \n    foreach my $Tid (@IDs)\n    {\n        if(defined $DWARF_Info{$Tid}\n        and defined $TypeInfo{$Tid})\n        {\n            my $Type = $TypeInfo{$Tid}{\"Type\"};\n            \n            if(not defined $TypeInfo{$Tid}{\"Memb\"})\n            {\n                if($Type=~/Struct|Class|Union|Enum/)\n                {\n                    if(my $Signature = $DWARF_Info{$Tid}{\"signature\"})\n                    {\n                        if(defined $TypeInfo{$Signature})\n                        {\n                            foreach my $Attr (keys(%{$TypeInfo{$Signature}}))\n                            {\n                                if(not defined $TypeInfo{$Tid}{$Attr}) {\n                                    $TypeInfo{$Tid}{$Attr} = $TypeInfo{$Signature}{$Attr};\n                                }\n                            }\n                        }\n                    }\n                }\n            }\n        }\n    }\n    \n    # delete types info\n    foreach my $ID (@IDs)\n    {\n        if(not defined $DWARF_Info{$ID}) {\n            next;\n        }\n        \n        if(my $Kind = $DWARF_Info{$ID}{\"kind\"})\n        {\n            if(defined $TypeType{$Kind}) {\n                delete($DWARF_Info{$ID});\n            }\n        }\n    }\n    \n    foreach my $ID (@IDs)\n    {\n        if(not defined $DWARF_Info{$ID}) {\n            next;\n        }\n        \n        if($ID<0)\n        { # imported\n            next;\n        }\n        \n        if($DWARF_Info{$ID}{\"kind\"} eq \"prog\"\n        or $DWARF_Info{$ID}{\"kind\"} eq \"variable\")\n        {\n            getSymbolInfo($ID);\n        }\n    }\n    \n    if(defined $Compressed\n    and not defined $AllUnits)\n    {\n        if(not $Partial)\n        {\n            foreach my $ID (@IDs)\n            {\n                if($DWARF_Info{$ID}{\"kind\"} ne \"base_type\") {\n                    delete($DWARF_Info{$ID});\n                }\n            }\n        }\n        \n        # free memory\n        %TypeMember = ();\n        %ArrayCount = ();\n        %FuncParam = ();\n        %TmplParam = ();\n    }\n    else\n    {\n        %DWARF_Info = ();\n        \n        # free memory\n        %TypeMember = ();\n        %ArrayCount = ();\n        %FuncParam = ();\n        %TmplParam = ();\n        \n        %Inheritance = ();\n        %NameSpace = ();\n        %SpecElem = ();\n        %OrigElem = ();\n        %ClassMethods = ();\n        \n        %LexicalId = ();\n        \n        $Cache{\"getTypeInfo\"} = {\"1\"=>1, \"-1\"=>1};\n    }\n    \n    @IDs = ();\n    @IDs_I = ();\n}\n\nsub selectSymbols()\n{\n    foreach my $ID (sort {$a<=>$b} keys(%SymbolInfo))\n    {\n        my $Symbol = $SymbolInfo{$ID}{\"MnglName\"};\n        \n        if(not $Symbol) {\n            $Symbol = $SymbolInfo{$ID}{\"ShortName\"};\n        }\n        \n        if(not $Symbol)\n        {\n            delete($SymbolInfo{$ID});\n            next;\n        }\n        \n        my $S = selectSymbol($SymbolInfo{$ID});\n        \n        if($S==0)\n        {\n            if(defined $AllSymbols)\n            {\n                if($SymbolInfo{$ID}{\"External\"})\n                {\n                    $S = 1;\n                }\n                else\n                { # local\n                    if(defined $DumpStatic) {\n                        $S = 1;\n                    }\n                }\n            }\n        }\n        \n        if($S==0)\n        {\n            delete($SymbolInfo{$ID});\n            next;\n        }\n        elsif(defined $PublicHeadersPath)\n        {\n            if(not selectPublic($Symbol, $ID)\n            and (not defined $SymbolInfo{$ID}{\"Alias\"} or not selectPublic($SymbolInfo{$ID}{\"Alias\"}, $ID)))\n            {\n                delete($SymbolInfo{$ID});\n                next;\n            }\n        }\n        elsif(defined $KernelExport)\n        {\n            if(not defined $KSymTab{$Symbol})\n            {\n                delete($SymbolInfo{$ID});\n                next;\n            }\n        }\n        \n        $SelectedSymbols{$ID} = $S;\n        \n        delete($SymbolInfo{$ID}{\"External\"});\n\n        # add attributes\n        if(defined $ExtraDump)\n        {\n            foreach my $Attr (keys(%{$SymbolAttribute{$Symbol}})) {\n                $SymbolInfo{$ID}{$Attr} = $SymbolAttribute{$Symbol}{$Attr};\n            }\n        }\n    }\n}\n\nsub completeTypes($)\n{\n    my $Name = $_[0];\n    \n    while($Name=~/T#(\\d+)/)\n    {\n        my $Tid = $1;\n        \n        if(defined $TypeInfo{$Tid}\n        and my $TName = $TypeInfo{$Tid}{\"Name\"})\n        {\n            $Name=~s/T#$Tid\\b/$TName/g;\n        }\n        else\n        {\n            last;\n        }\n    }\n    \n    return formatName($Name, \"T\");\n}\n\nsub completeABI()\n{\n    # types\n    my %Incomplete = ();\n    my %Incomplete_TN = ();\n    \n    my @TIDs = sort {$a<=>$b} keys(%TypeInfo);\n    \n    if($AltDebugInfo) {\n        @TIDs = sort {$b>0<=>$a>0} sort {abs($a)<=>abs($b)} @TIDs;\n    }\n    \n    if(defined $Compressed\n    and not defined $AllUnits)\n    {\n        foreach my $Tid (@TIDs)\n        {\n            my $TName = $TypeInfo{$Tid}{\"Name\"};\n            if(index($TName, \"#\")!=-1)\n            {\n                $TypeInfo{$Tid}{\"Name\"} = completeTypes($TName);\n                registerTName($Tid, $TypeInfo{$Tid}{\"Name\"}, $TypeInfo{$Tid}{\"Type\"});\n            }\n        }\n    }\n    \n    foreach my $Tid (@TIDs)\n    {\n        my $Name = $TypeInfo{$Tid}{\"Name\"};\n        my $Type = $TypeInfo{$Tid}{\"Type\"};\n        \n        if(not defined $SpecElem{$Tid}\n        and not defined $Incomplete_TN{$Type}{$Name})\n        {\n            if(not defined $TypeInfo{$Tid}{\"Size\"})\n            {\n                if($Type=~/Struct|Class|Union|Enum/)\n                {\n                    $Incomplete{$Tid} = 1;\n                }\n            }\n        }\n        \n        $Incomplete_TN{$Type}{$Name} = 1;\n    }\n    \n    # free memory\n    %Incomplete_TN = ();\n    \n    foreach my $Tid (sort {$a<=>$b} keys(%Incomplete))\n    {\n        my $Name = $TypeInfo{$Tid}{\"Name\"};\n        my $Type = $TypeInfo{$Tid}{\"Type\"};\n        \n        my @Adv_TIDs = sort {$a<=>$b} keys(%{$TName_Tids{$Type}{$Name}});\n    \n        if($AltDebugInfo) {\n            @Adv_TIDs = sort {$b>0<=>$a>0} sort {abs($a)<=>abs($b)} @Adv_TIDs;\n        }\n        \n        foreach my $Tid_Adv (@Adv_TIDs)\n        {\n            if($Tid_Adv!=$Tid)\n            {\n                if(defined $SpecElem{$Tid_Adv}\n                or defined $TypeInfo{$Tid_Adv}{\"Size\"})\n                {\n                    foreach my $Attr (keys(%{$TypeInfo{$Tid_Adv}}))\n                    {\n                        if(not defined $TypeInfo{$Tid}{$Attr})\n                        {\n                            if(ref($TypeInfo{$Tid_Adv}{$Attr}) eq \"HASH\") {\n                                $TypeInfo{$Tid}{$Attr} = dclone($TypeInfo{$Tid_Adv}{$Attr});\n                            }\n                            else {\n                                $TypeInfo{$Tid}{$Attr} = $TypeInfo{$Tid_Adv}{$Attr};\n                            }\n                            \n                        }\n                    }\n                    last;\n                }\n            }\n        }\n    }\n    \n    # free memory\n    %Incomplete = ();\n    \n    my %ReplacedAnon = ();\n    \n    foreach my $Tid (sort {$a<=>$b} keys(%TypeInfo))\n    {\n        if($TypeInfo{$Tid}{\"Type\"} eq \"Typedef\")\n        {\n            my $TN = $TypeInfo{$Tid}{\"Name\"};\n            my $TL = $TypeInfo{$Tid}{\"Line\"};\n            my $NS = $TypeInfo{$Tid}{\"NameSpace\"};\n            \n            if(my $BTid = $TypeInfo{$Tid}{\"BaseType\"})\n            {\n                my $BName = $TypeInfo{$BTid}{\"Name\"};\n                my $BType = $TypeInfo{$BTid}{\"Type\"};\n                \n                if(defined $TypeInfo{$BTid}\n                and $BName=~/\\Aanon\\-(\\w+)\\-/\n                and $BType=~/Enum|Struct|Union/)\n                {\n                    $TypeInfo{$Tid} = dclone($TypeInfo{$BTid});\n                    $TypeInfo{$Tid}{\"Name\"} = lc($TypeInfo{$BTid}{\"Type\"}).\" \".$TN;\n                    $TypeInfo{$Tid}{\"Line\"} = $TL;\n                    \n                    my $Name = $TypeInfo{$Tid}{\"Name\"};\n                    my $Type = $TypeInfo{$Tid}{\"Type\"};\n                    \n                    registerTName($Tid, $Name, $Type);\n                    \n                    if($NS) {\n                        $TypeInfo{$Tid}{\"NameSpace\"} = $NS;\n                    }\n                    \n                    $DeletedAnon{$BTid} = $Tid;\n                    foreach my $BTid_S (keys(%{$TName_Tids{$BType}{$BName}})) {\n                        $DeletedAnon{$BTid_S} = $Tid;\n                    }\n                }\n            }\n        }\n        elsif($TypeInfo{$Tid}{\"Type\"} eq \"Pointer\")\n        {\n            if(my $BTid = $TypeInfo{$Tid}{\"BaseType\"})\n            {\n                my $To = undef;\n                \n                if(defined $DeletedAnon{$BTid}) {\n                    $To = $DeletedAnon{$BTid};\n                }\n                elsif(defined $ReplacedAnon{$BTid}) {\n                    $To = $BTid;\n                }\n                \n                if($To)\n                {\n                    $TypeInfo{$Tid}{\"BaseType\"} = $To;\n                    $TypeInfo{$Tid}{\"Name\"} = $TypeInfo{$To}{\"Name\"}.\"*\";\n                    \n                    my $Name = $TypeInfo{$Tid}{\"Name\"};\n                    my $Type = $TypeInfo{$Tid}{\"Type\"};\n                    \n                    $TName_Tid{$Type}{$Name} = $Tid;\n                    $TName_Tids{$Type}{$Name}{$Tid} = 1;\n                    \n                    $ReplacedAnon{$Tid} = 1;\n                }\n            }\n        }\n        elsif($TypeInfo{$Tid}{\"Type\"} eq \"Const\")\n        {\n            if(my $BTid = $TypeInfo{$Tid}{\"BaseType\"})\n            {\n                my $To = undef;\n                \n                if(defined $DeletedAnon{$BTid}) {\n                    $To = $DeletedAnon{$BTid};\n                }\n                elsif(defined $ReplacedAnon{$BTid}) {\n                    $To = $BTid;\n                }\n                \n                if($To)\n                {\n                    $TypeInfo{$Tid}{\"BaseType\"} = $To;\n                    $TypeInfo{$Tid}{\"Name\"} = formatName($TypeInfo{$To}{\"Name\"}.\" const\", \"T\");\n                    \n                    my $Name = $TypeInfo{$Tid}{\"Name\"};\n                    my $Type = $TypeInfo{$Tid}{\"Type\"};\n                    \n                    $TName_Tid{$Type}{$Name} = $Tid;\n                    $TName_Tids{$Type}{$Name}{$Tid} = 1;\n                    \n                    $ReplacedAnon{$Tid} = 1;\n                }\n            }\n        }\n    }\n    \n    foreach my $Tid (keys(%DeletedAnon))\n    {\n        my $TN = $TypeInfo{$Tid}{\"Name\"};\n        my $TT = $TypeInfo{$Tid}{\"Type\"};\n        \n        delete($TName_Tid{$TT}{$TN});\n        delete($TName_Tids{$TT}{$TN}{$Tid});\n        \n        if(my @TIDs = sort {$a<=>$b} keys(%{$TName_Tids{$TT}{$TN}}))\n        { # minimal ID\n            $TName_Tid{$TT}{$TN} = $TIDs[0];\n        }\n        \n        delete($TypeInfo{$Tid});\n    }\n    \n    # symbols\n    foreach my $ID (sort {$a<=>$b} keys(%SymbolInfo))\n    {\n        if(defined $Compressed\n        and not defined $AllUnits)\n        { # replace late template arguments\n            my $ShortName = $SymbolInfo{$ID}{\"ShortName\"};\n            \n            if(index($ShortName, \"#\")!=-1) {\n                $SymbolInfo{$ID}{\"ShortName\"} = completeTypes($ShortName);\n            }\n        }\n        \n        # add missed c-tors\n        if($SymbolInfo{$ID}{\"Constructor\"})\n        {\n            if($SymbolInfo{$ID}{\"MnglName\"}=~/(C[1-2])([EI]).+/)\n            {\n                my ($K1, $K2) = ($1, $2);\n                foreach (\"C1\", \"C2\")\n                {\n                    if($K1 ne $_)\n                    {\n                        my $Name = $SymbolInfo{$ID}{\"MnglName\"};\n                        $Name=~s/$K1$K2/$_$K2/;\n                        \n                        if(not defined $Mangled_ID{$Name}) {\n                            $Mangled_ID{$Name} = cloneSymbol($ID, $Name);\n                        }\n                    }\n                }\n            }\n        }\n        \n        # add missed d-tors\n        if($SymbolInfo{$ID}{\"Destructor\"})\n        {\n            if($SymbolInfo{$ID}{\"MnglName\"}=~/(D[0-2])([EI]).+/)\n            {\n                my ($K1, $K2) = ($1, $2);\n                foreach (\"D0\", \"D1\", \"D2\")\n                {\n                    if($K1 ne $_)\n                    {\n                        my $Name = $SymbolInfo{$ID}{\"MnglName\"};\n                        $Name=~s/$K1$K2/$_$K2/;\n                        \n                        if(not defined $Mangled_ID{$Name}) {\n                            $Mangled_ID{$Name} = cloneSymbol($ID, $Name);\n                        }\n                    }\n                }\n            }\n        }\n    }\n    \n    foreach my $ID (sort {$a<=>$b} keys(%SymbolInfo))\n    {\n        my $SInfo = $SymbolInfo{$ID};\n        my $Symbol = $SInfo->{\"MnglName\"};\n        my $Short = $SInfo->{\"ShortName\"};\n        \n        if(not $Symbol) {\n            $Symbol = $Short;\n        }\n        \n        if($LIB_LANG eq \"C++\")\n        {\n            if(not $SInfo->{\"MnglName\"})\n            {\n                if($SInfo->{\"Artificial\"}\n                or index($Short, \"~\")==0)\n                {\n                    delete($SymbolInfo{$ID});\n                    next;\n                }\n            }\n        }\n        \n        if($SInfo->{\"Class\"}\n        and not $SInfo->{\"Data\"}\n        and not $SInfo->{\"Constructor\"}\n        and not $SInfo->{\"Destructor\"}\n        and not $SInfo->{\"Virt\"}\n        and not $SInfo->{\"PureVirt\"})\n        {\n            if(not defined $SInfo->{\"Param\"}\n            or $SInfo->{\"Param\"}{0}{\"name\"} ne \"this\")\n            {\n                if(not $ExtraDump or index($Symbol, \"_ZTV\")!=0)\n                {\n                    $SInfo->{\"Static\"} = 1;\n                }\n            }\n        }\n        \n        if(not $SInfo->{\"Return\"})\n        { # void\n            if(not $SInfo->{\"Constructor\"}\n            and not $SInfo->{\"Destructor\"})\n            {\n                $SInfo->{\"Return\"} = \"1\";\n            }\n        }\n        \n        if(not $SInfo->{\"Header\"})\n        {\n            if($SInfo->{\"Class\"})\n            { # detect missed header by class\n                if(defined $TypeInfo{$SInfo->{\"Class\"}}{\"Header\"}) {\n                    $SInfo->{\"Header\"} = $TypeInfo{$SInfo->{\"Class\"}}{\"Header\"};\n                }\n            }\n        }\n        \n        if(defined $PublicHeadersPath) {\n            fixHeader($SInfo);\n        }\n        \n        my $Header = $SInfo->{\"Header\"};\n        \n        if(defined $SInfo->{\"Source\"} and defined $SInfo->{\"SourceLine\"})\n        {\n            if(not defined $Header and not defined $SInfo->{\"Line\"})\n            {\n                $SInfo->{\"Line\"} = $SInfo->{\"SourceLine\"};\n                delete($SInfo->{\"SourceLine\"});\n            }\n        }\n        \n        if(not $SInfo->{\"Constructor\"}\n        and not $SInfo->{\"Destructor\"})\n        {\n            my $InLineDecl = delete($SInfo->{\"DeclaredInlined\"});\n            \n            my $Bind = undef;\n            \n            if(defined $Symbol_Bind{$Symbol}) {\n                $Bind = $Symbol_Bind{$Symbol};\n            }\n            elsif(my $SVer = $SymVer{$Symbol})\n            {\n                if(defined $Symbol_Bind{$SVer}) {\n                    $Bind = $Symbol_Bind{$SVer};\n                }\n            }\n            \n            if($Bind ne \"GLOBAL\" and $Bind ne \"LOCAL\")\n            {\n                # Not enough info in the DWARF dump\n                if($Bind eq \"WEAK\")\n                {\n                    if($InLineDecl) {\n                        $SInfo->{\"InLine\"} = 1;\n                    }\n                    else {\n                        $SInfo->{\"InLine\"} = 2;\n                    }\n                }\n                \n                #if(not $SInfo->{\"InLine\"})\n                #{\n                #    if(defined $PublicHeadersPath)\n                #    {\n                #        if($Short and defined $Header\n                #        and defined $PublicHeader{$Header})\n                #        {\n                #            if(defined $SymbolToHeader{$Short}\n                #            and defined $SymbolToHeader{$Short}{$Header})\n                #            {\n                #                if($SymbolToHeader{$Short}{$Header} eq \"function\") {\n                #                    $SInfo->{\"InLine\"} = 2;\n                #                }\n                #            }\n                #        }\n                #    }\n                #}\n            }\n        }\n        \n        if(defined $SInfo->{\"PureVirt\"}) {\n            delete($SInfo->{\"InLine\"});\n        }\n    }\n}\n\nsub warnPrivateType($$)\n{\n    my ($Name, $Note) = @_;\n    \n    if($Name=~/Private|Opaque/i)\n    { # _GstClockPrivate\n      # _Eo_Opaque\n        return;\n    }\n    \n    if($Name=~/(\\A| )_/i)\n    { # _GstBufferList\n        return;\n    }\n    \n    if($Name=~/_\\Z/i)\n    { # FT_RasterRec_\n        return;\n    }\n    \n    printMsg(\"WARNING\", \"Private data type \\'\".$Name.\"\\' ($Note)\");\n}\n\nsub warnPrivateSymbol($$)\n{\n    my ($Name, $Note) = @_;\n    printMsg(\"WARNING\", \"Private symbol \\'\".$Name.\"\\' ($Note)\");\n}\n\nsub selectPublicType($)\n{\n    my $Tid = $_[0];\n    \n    if($TypeInfo{$Tid}{\"Type\"}!~/\\A(Struct|Class|Union|Enum|Typedef)\\Z/) {\n        return 1;\n    }\n    \n    my $TName = $TypeInfo{$Tid}{\"Name\"};\n    $TName=~s/\\A(struct|class|union|enum) //g;\n    \n    my $Header = getFilename($TypeInfo{$Tid}{\"Header\"});\n    \n    if($OBJ_LANG eq \"C++\"\n    or index($TName, \"anon-\")==0) {\n        return ($Header and defined $PublicHeader{$Header});\n    }\n    \n    if($Header)\n    {\n        if(not defined $PublicHeader{$Header})\n        {\n            if(not defined $TypeToHeader{$TName}) {\n                return 0;\n            }\n        }\n        elsif($MixedHeaders)\n        {\n            if(not defined $TypeToHeader{$TName})\n            {\n                if(defined $Debug) {\n                    warnPrivateType($TypeInfo{$Tid}{\"Name\"}, \"NOT_FOUND\");\n                }\n                return 0;\n            }\n        }\n    }\n    else\n    {\n        if(not defined $TypeToHeader{$TName})\n        {\n            # if(defined $Debug) {\n            #     warnPrivateType($TypeInfo{$Tid}{\"Name\"}, \"NO_HEADER\");\n            # }\n            return 0;\n        }\n    }\n    \n    return 1;\n}\n\nsub selectPublic($$)\n{\n    my ($Symbol, $ID) = @_;\n\n    if($ExtraDump)\n    {\n        if(index($Symbol, \"_ZTV\")==0)\n        {\n            return 1;\n        }\n    }\n\n    my $Header = getFilename($SymbolInfo{$ID}{\"Header\"});\n    \n    if($OBJ_LANG eq \"C++\") {\n        return ($Header and defined $PublicHeader{$Header});\n    }\n    \n    if($Header)\n    {\n        if(not defined $PublicHeader{$Header})\n        {\n            if(not defined $SymbolToHeader{$Symbol}) {\n                return 0;\n            }\n        }\n        elsif($MixedHeaders)\n        {\n            if(not defined $SymbolToHeader{$Symbol})\n            {\n                if(defined $Debug) {\n                    warnPrivateSymbol($Symbol, \"NOT_FOUND\");\n                }\n                return 0;\n            }\n        }\n    }\n    else\n    {\n        if(not defined $SymbolToHeader{$Symbol})\n        {\n            # if(defined $Debug) {\n            #     warnPrivateSymbol($Symbol, \"NO_HEADER\");\n            # }\n            return 0;\n        }\n    }\n    \n    return 1;\n}\n\nsub add_VtableSymbols()\n{\n    foreach my $Symbol (sort {lc($a) cmp lc($b)} keys(%VTable_Class))\n    {\n        my $CName = $VTable_Class{$Symbol};\n        my $ID = ++$GLOBAL_ID;\n\n        $SymbolInfo{$ID}{\"MnglName\"} = $Symbol;\n\n        # TODO: move VTable attr from TypeInfo to SymbolInfo\n\n        if(not defined $TName_Tid{\"Class\"}{$CName}\n        and not defined $TName_Tid{\"Struct\"}{$CName})\n        { # create class\n            my $ID_T = ++$GLOBAL_ID_T;\n\n            $TName_Tid{\"Class\"}{$CName} = $ID_T;\n\n            $TypeInfo{$ID_T}{\"Type\"} = \"Class\";\n            $TypeInfo{$ID_T}{\"Name\"} = $CName;\n\n            if($CName=~/\\A([\\w\\:]+)\\:\\:/) {\n                $TypeInfo{$ID_T}{\"NameSpace\"} = $1;\n            }\n\n            if(defined $VirtualTable{$CName}) {\n                %{$TypeInfo{$ID_T}{\"VTable\"}} = %{$VirtualTable{$CName}};\n            }\n        }\n\n        if(defined $TName_Tid{\"Class\"}{$CName}) {\n            $SymbolInfo{$ID}{\"Class\"} = $TName_Tid{\"Class\"}{$CName};\n        }\n        elsif(defined $TName_Tid{\"Struct\"}{$CName}) {\n            $SymbolInfo{$ID}{\"Class\"} = $TName_Tid{\"Struct\"}{$CName};\n        }\n\n        foreach my $Attr (keys(%{$SymbolAttribute{$Symbol}})) {\n            $SymbolInfo{$ID}{$Attr} = $SymbolAttribute{$Symbol}{$Attr};\n        }\n    }\n}\n\nsub cloneSymbol($$)\n{\n    my ($ID, $Symbol) = @_;\n    \n    my $nID = undef;\n    if(not defined $SymbolInfo{$ID + 1}) {\n        $nID = $ID + 1;\n    }\n    else {\n        $nID = ++$GLOBAL_ID;\n    }\n    foreach my $Attr (keys(%{$SymbolInfo{$ID}}))\n    {\n        if(ref($SymbolInfo{$ID}{$Attr}) eq \"HASH\") {\n            $SymbolInfo{$nID}{$Attr} = dclone($SymbolInfo{$ID}{$Attr});\n        }\n        else {\n            $SymbolInfo{$nID}{$Attr} = $SymbolInfo{$ID}{$Attr};\n        }\n    }\n    $SymbolInfo{$nID}{\"MnglName\"} = $Symbol;\n    return $nID;\n}\n\nsub selectSymbol($)\n{\n    my $SInfo = $_[0];\n    \n    my $MnglName = $SInfo->{\"MnglName\"};\n    \n    if(not $MnglName) {\n        $MnglName = $SInfo->{\"ShortName\"};\n    }\n    \n    if($SymbolsListPath\n    and not $SymbolsList{$MnglName})\n    {\n        next;\n    }\n    \n    my $Exp = 0;\n    \n    if($Library_Symbol{$TargetName}{$MnglName}\n    or $Library_Symbol{$TargetName}{$SymVer{$MnglName}})\n    {\n        $Exp = 1;\n    }\n    \n    if(my $Alias = $SInfo->{\"Alias\"})\n    {\n        if($Library_Symbol{$TargetName}{$Alias}\n        or $Library_Symbol{$TargetName}{$SymVer{$Alias}})\n        {\n            $Exp = 1;\n        }\n    }\n    \n    if(not $Exp)\n    {\n        if(defined $Library_UndefSymbol{$TargetName}{$MnglName}\n        or defined $Library_UndefSymbol{$TargetName}{$SymVer{$MnglName}})\n        {\n            return 0;\n        }\n        \n        if($SInfo->{\"Data\"}\n        or $SInfo->{\"InLine\"}\n        or $SInfo->{\"PureVirt\"})\n        {\n            if(not $SInfo->{\"External\"})\n            { # skip static\n                return 0;\n            }\n            \n            if(defined $BinOnly)\n            { # data, inline, pure\n                return 0;\n            }\n            elsif(not defined $SInfo->{\"Header\"})\n            { # defined in source files\n                return 0;\n            }\n            else {\n                return 2;\n            }\n        }\n        else {\n            return 0;\n        }\n    }\n    \n    return 1;\n}\n\nsub formatName($$)\n{ # type name correction\n    if(defined $Cache{\"formatName\"}{$_[1]}{$_[0]}) {\n        return $Cache{\"formatName\"}{$_[1]}{$_[0]};\n    }\n    \n    my $N = $_[0];\n    \n    if($_[1] ne \"S\")\n    {\n        $N=~s/\\A[ ]+//g;\n        $N=~s/[ ]+\\Z//g;\n        $N=~s/[ ]{2,}/ /g;\n    }\n    \n    $N=~s/[ ]*(\\W)[ ]*/$1/g; # std::basic_string<char> const\n    \n    $N=~s/\\b(const|volatile) ([\\w\\:]+)([\\*&,>]|\\Z)/$2 $1$3/g; # \"const void\" to \"void const\"\n    \n    $N=~s/\\bvolatile const\\b/const volatile/g;\n    \n    $N=~s/\\b(long long|short|long) unsigned\\b/unsigned $1/g;\n    $N=~s/\\b(short|long) int\\b/$1/g;\n    \n    $N=~s/([\\)\\]])(const|volatile)\\b/$1 $2/g;\n    \n    while($N=~s/>>/> >/g) {};\n    \n    if($_[1] eq \"S\")\n    {\n        if(index($N, \"operator\")!=-1) {\n            $N=~s/\\b(operator[ ]*)> >/$1>>/;\n        }\n    }\n    \n    $N=~s/,/, /g;\n    \n    if(defined $LambdaSupport)\n    { # struct {lambda()}\n        $N=~s/(\\w)\\{/$1 \\{/g;\n    }\n    \n    return ($Cache{\"formatName\"}{$_[1]}{$_[0]} = $N);\n}\n\nsub sepParams($)\n{\n    my $Str = $_[0];\n    my @Parts = ();\n    my %B = ( \"(\"=>0, \"<\"=>0, \")\"=>0, \">\"=>0 );\n    my $Part = 0;\n    foreach my $Pos (0 .. length($Str) - 1)\n    {\n        my $S = substr($Str, $Pos, 1);\n        if(defined $B{$S}) {\n            $B{$S} += 1;\n        }\n        if($S eq \",\" and\n        $B{\"(\"}==$B{\")\"} and $B{\"<\"}==$B{\">\"}) {\n            $Part += 1;\n        }\n        else {\n            $Parts[$Part] .= $S;\n        }\n    }\n    # remove spaces\n    foreach (@Parts)\n    {\n        s/\\A //g;\n        s/ \\Z//g;\n    }\n    return @Parts;\n}\n\nsub initFuncType($$$)\n{\n    my ($TInfo, $FTid, $Type) = @_;\n    \n    $TInfo->{\"Type\"} = $Type;\n    \n    if($TInfo->{\"Return\"} = $DWARF_Info{$FTid}{\"type\"}) {\n        getTypeInfo($TInfo->{\"Return\"});\n    }\n    else\n    { # void\n        $TInfo->{\"Return\"} = \"1\";\n    }\n    delete($TInfo->{\"BaseType\"});\n    \n    my @Prms = ();\n    my $PPos = 0;\n    foreach my $Pos (sort {$a<=>$b} keys(%{$FuncParam{$FTid}}))\n    {\n        my $ParamId = $FuncParam{$FTid}{$Pos};\n        my %PInfo = %{$DWARF_Info{$ParamId}};\n        \n        if(defined $PInfo{\"art\"})\n        { # this\n            next;\n        }\n        \n        if(my $PTypeId = $PInfo{\"type\"})\n        {\n            $TInfo->{\"Param\"}{$PPos}{\"type\"} = $PTypeId;\n            getTypeInfo($PTypeId);\n            push(@Prms, $TypeInfo{$PTypeId}{\"Name\"});\n        }\n        \n        $PPos += 1;\n    }\n    \n    $TInfo->{\"Name\"} = $TypeInfo{$TInfo->{\"Return\"}}{\"Name\"};\n    if($Type eq \"FuncPtr\") {\n        $TInfo->{\"Name\"} .= \"(*)\";\n    }\n    $TInfo->{\"Name\"} .= \"(\".join(\",\", @Prms).\")\";\n}\n\nsub getShortName($)\n{\n    my $Name = $_[0];\n    \n    if(my $C = findCenter($Name, \"<\"))\n    {\n        return substr($Name, 0, $C);\n    }\n    \n    return $Name;\n}\n\nsub getTKeys($)\n{\n    my @TParams = @{$_[0]};\n    \n    my @TKeys = ();\n    \n    foreach my $Pos (0 .. $#TParams)\n    {\n        my $TRef = $TParams[$Pos];\n        \n        if(defined $Compressed\n        and not defined $AllUnits)\n        { # not all types are available in the current compile unit\n          # so handling them later\n            my $Key = undef;\n            \n            if(defined $TRef->{\"val\"}) {\n                $Key = computeValue($TRef);\n            }\n            elsif(defined $TRef->{\"name\"}) {\n                $Key = $TRef->{\"name\"};\n            }\n            elsif(my $KeyT = $TRef->{\"type\"})\n            {\n                if(defined $TypeInfo{$KeyT}\n                and my $TN = $TypeInfo{$KeyT}{\"Name\"})\n                {\n                    if(index($TN, \"#\")==-1) {\n                        $Key = simpleName($TN);\n                    }\n                    else {\n                        $Key = \"T#\".$KeyT;\n                    }\n                }\n                else {\n                    $Key = \"T#\".$KeyT;\n                }\n            }\n            \n            push(@TKeys, $Key);\n        }\n        else\n        {\n            my $Key = undef;\n            \n            if(defined $TRef->{\"val\"}) {\n                $Key = computeValue($TRef);\n            }\n            elsif(my $KeyT = $TRef->{\"type\"}) {\n                $Key = simpleName($TypeInfo{$KeyT}{\"Name\"});\n            }\n            else {\n                $Key = $TRef->{\"name\"};\n            }\n            \n            push(@TKeys, $Key);\n        }\n    }\n    \n    return @TKeys;\n}\n\nsub getTParams($$)\n{\n    my ($ID, $Name) = @_;\n    \n    my ($Short, $TParams) = ();\n    \n    if(defined $TmplParam{$ID})\n    {\n        $Short = getShortName($Name);\n        $TParams = getTParams_I($ID);\n        \n        my ($AddShort, $AddParam) = ();\n        \n        foreach my $Pos (0 .. $#{$TParams})\n        {\n            my $P = $TParams->[$Pos];\n            if(not defined $P->{\"val\"}\n            and defined $P->{\"type\"})\n            {\n                my $TTid = $P->{\"type\"};\n                if(not defined $TypeInfo{$TTid}\n                or not $TypeInfo{$TTid}{\"Name\"})\n                {\n                    if(not $AddParam) {\n                        ($AddShort, $AddParam) = parseTParams($Name);\n                    }\n                    \n                    if($Pos<=$#{$AddParam}) {\n                        $P->{\"name\"} = $AddParam->[$Pos]{\"name\"};\n                    }\n                }\n            }\n        }\n    }\n    else {\n        ($Short, $TParams) = parseTParams($Name);\n    }\n    \n    if(not $TParams) {\n        return ();\n    }\n    \n    return ($Short, $TParams);\n}\n\nsub getTParams_I($)\n{\n    my $ID = $_[0];\n    \n    my @TParams = ();\n    \n    foreach my $Pos (sort {$a<=>$b} keys(%{$TmplParam{$ID}}))\n    {\n        my $TTid = $TmplParam{$ID}{$Pos}{\"type\"};\n        \n        if($DWARF_Info{$TTid}{\"kind\"} eq \"typedef\") {\n            $TTid = $DWARF_Info{$TTid}{\"type\"};\n        }\n        \n        my $Val = undef;\n        my $Key = undef;\n        \n        if(defined $TmplParam{$ID}{$Pos}{\"value\"}) {\n            $Val = $TmplParam{$ID}{$Pos}{\"value\"};\n        }\n        \n        if(defined $TmplParam{$ID}{$Pos}{\"key\"}) {\n            $Key = $TmplParam{$ID}{$Pos}{\"key\"};\n        }\n        \n        if($Pos>0)\n        {\n            if(defined $TmplParam{$ID}{$Pos}{\"default\"})\n            {\n                if($Key=~/\\A(_Alloc|_Traits|_Compare)\\Z/)\n                {\n                    next;\n                }\n            }\n        }\n        \n        getTypeInfo($TTid);\n        \n        my %PInfo = (\n            \"type\"=>$TTid,\n            \"key\"=>$Key\n        );\n        \n        if(defined $Val) {\n            $PInfo{\"val\"} = $Val;\n        }\n        \n        push(@TParams, \\%PInfo);\n    }\n    \n    return \\@TParams;\n}\n\nsub parseTParams($)\n{\n    my $Name = $_[0];\n    \n    if(my $Cent = findCenter($Name, \"<\"))\n    {\n        my $TParams = substr($Name, $Cent);\n        my $Short = substr($Name, 0, $Cent);\n        \n        $TParams=~s/\\A<|>\\Z//g;\n        $TParams = simpleName($TParams);\n        \n        my @Params = sepParams($TParams);\n        @Params = shortTParams($Short, \\@Params);\n        \n        my @TParams = ();\n        foreach my $Pos (0 .. $#Params)\n        {\n            my $Param = $Params[$Pos];\n            if($Param=~/\\A(.+>)(.*?)\\Z/)\n            {\n                my ($Tm, $Suf) = ($1, $2);\n                my ($Sh, $Prm) = parseTParams($Tm);\n                \n                if($Prm)\n                {\n                    my @Keys = ();\n                    foreach my $P (@{$Prm}) {\n                        push(@Keys, $P->{\"name\"});\n                    }\n                    \n                    $Param = $Sh.\"<\".join(\", \", @Keys).\">\".$Suf;\n                }\n            }\n            my %PInfo = (\n                \"name\"=>formatName($Param, \"T\")\n            );\n            push(@TParams, \\%PInfo);\n        }\n        \n        return ($Short, \\@TParams);\n    }\n    \n    return (); # error\n}\n\nsub shortTParams($$)\n{\n    my $Short = $_[0];\n    my @Params = @{$_[1]};\n    \n    # default arguments\n    if($Short eq \"std::vector\")\n    {\n        if($#Params==1)\n        {\n            if($Params[1] eq \"std::allocator<\".$Params[0].\">\")\n            { # std::vector<T, std::allocator<T> >\n                splice(@Params, 1, 1);\n            }\n        }\n    }\n    elsif($Short eq \"std::set\")\n    {\n        if($#Params==2)\n        {\n            if($Params[1] eq \"std::less<\".$Params[0].\">\"\n            and $Params[2] eq \"std::allocator<\".$Params[0].\">\")\n            { # std::set<T, std::less<T>, std::allocator<T> >\n                splice(@Params, 1, 2);\n            }\n        }\n    }\n    elsif($Short eq \"std::basic_string\")\n    {\n        if($#Params==2)\n        {\n            if($Params[1] eq \"std::char_traits<\".$Params[0].\">\"\n            and $Params[2] eq \"std::allocator<\".$Params[0].\">\")\n            { # std::basic_string<T, std::char_traits<T>, std::allocator<T> >\n                splice(@Params, 1, 2);\n            }\n        }\n    }\n    elsif($Short eq \"std::basic_ostream\")\n    {\n        if($#Params==1)\n        {\n            if($Params[1] eq \"std::char_traits<\".$Params[0].\">\")\n            { # std::basic_ostream<T, std::char_traits<T> >\n                splice(@Params, 1, 1);\n            }\n        }\n    }\n    \n    return @Params;\n}\n\nsub getTypeInfo($)\n{\n    my $ID = $_[0];\n    \n    if(not defined $DWARF_Info{$ID}) {\n        return;\n    }\n    \n    if(not keys(%{$DWARF_Info{$ID}}))\n    {\n        delete($DWARF_Info{$ID});\n        return;\n    }\n    \n    my $Kind = $DWARF_Info{$ID}{\"kind\"};\n    \n    if(defined $Cache{\"getTypeInfo\"}{$ID}) {\n        return;\n    }\n    \n    if(my $N = $NameSpace{$ID})\n    {\n        if($DWARF_Info{$N}{\"kind\"} eq \"prog\")\n        { # local code\n          # template instances are declared in the subprogram (constructor)\n            my $Tmpl = 0;\n            if(my $ObjP = $DWARF_Info{$N}{\"objptr\"})\n            {\n                while($DWARF_Info{$ObjP}{\"type\"}) {\n                    $ObjP = $DWARF_Info{$ObjP}{\"type\"};\n                }\n                my $CName = $DWARF_Info{$ObjP}{\"name\"};\n                $CName=~s/<.*//g;\n                if($CName eq $DWARF_Info{$N}{\"name\"}) {\n                    $Tmpl = 1;\n                }\n            }\n            if(not $Tmpl)\n            { # local types\n                $LocalType{$ID} = 1;\n            }\n        }\n        elsif($DWARF_Info{$N}{\"kind\"} eq \"lexical_block\")\n        { # local code\n            return;\n        }\n    }\n    \n    $Cache{\"getTypeInfo\"}{$ID} = 1;\n    \n    my %TInfo = ();\n    \n    $TInfo{\"Type\"} = $TypeType{$Kind};\n    \n    if(not $TInfo{\"Type\"})\n    {\n        if($DWARF_Info{$ID}{\"kind\"} eq \"subroutine_type\") {\n            $TInfo{\"Type\"} = \"Func\";\n        }\n    }\n    \n    if($DWARF_Info{$ID}{\"name\"} eq \"__unknown__\")\n    { # size of such type may vary\n        delete($DWARF_Info{$ID}{\"size\"});\n    }\n    \n    if(defined $SYS_CLANGV\n    and $TInfo{\"Type\"} eq \"FieldPtr\")\n    { # support for Clang\n        if(my $T = $DWARF_Info{$ID}{\"type\"})\n        {\n            if($DWARF_Info{$T}{\"kind\"} eq \"subroutine_type\")\n            {\n                $TInfo{\"Type\"} = \"MethodPtr\";\n                $DWARF_Info{$ID}{\"pfn\"} = $T;\n                $DWARF_Info{$T}{\"objptr\"} = $DWARF_Info{$ID}{\"container\"};\n            }\n        }\n    }\n    \n    my $RealType = $TInfo{\"Type\"};\n    \n    if(defined $ClassMethods{$ID})\n    {\n        if($TInfo{\"Type\"} eq \"Struct\") {\n            $RealType = \"Class\";\n        }\n    }\n    \n    if($TInfo{\"Type\"} ne \"Enum\"\n    and my $BaseType = $DWARF_Info{$ID}{\"type\"})\n    {\n        $TInfo{\"BaseType\"} = \"$BaseType\";\n        \n        if(defined $TypeType{$DWARF_Info{$BaseType}{\"kind\"}})\n        {\n            getTypeInfo($TInfo{\"BaseType\"});\n            \n            if(not defined $TypeInfo{$TInfo{\"BaseType\"}}\n            or not $TypeInfo{$TInfo{\"BaseType\"}}{\"Name\"})\n            { # local code\n                delete($TypeInfo{$ID});\n                return;\n            }\n        }\n    }\n    \n    if($RealType eq \"Class\") {\n        $TInfo{\"Copied\"} = 1; # will be changed in getSymbolInfo()\n    }\n    \n    if(defined $TypeMember{$ID})\n    {\n        my $Unnamed = 0;\n        foreach my $Pos (sort {$a<=>$b} keys(%{$TypeMember{$ID}}))\n        {\n            my $MemId = $TypeMember{$ID}{$Pos};\n            my $MInfo = $DWARF_Info{$MemId};\n            \n            if(my $Name = $MInfo->{\"name\"})\n            {\n                if(index($Name, \"_vptr.\")==0)\n                { # v-table pointer\n                    $Name=\"_vptr\";\n                }\n                $TInfo{\"Memb\"}{$Pos}{\"name\"} = $Name;\n            }\n            else\n            {\n                $TInfo{\"Memb\"}{$Pos}{\"name\"} = \"unnamed\".$Unnamed;\n                $Unnamed += 1;\n            }\n            if($TInfo{\"Type\"} eq \"Enum\") {\n                $TInfo{\"Memb\"}{$Pos}{\"value\"} = $MInfo->{\"cval\"};\n            }\n            else\n            {\n                $TInfo{\"Memb\"}{$Pos}{\"type\"} = $MInfo->{\"type\"};\n                if(my $Access = $MInfo->{\"access\"})\n                {\n                    if($Access ne \"public\")\n                    { # NOTE: default access of members in the ABI dump is \"public\"\n                        $TInfo{\"Memb\"}{$Pos}{\"access\"} = $Access;\n                    }\n                }\n                else\n                { \n                    if($DWARF_Info{$ID}{\"kind\"} eq \"class_type\")\n                    { # NOTE: default access of class members in the debug info is \"private\"\n                        $TInfo{\"Memb\"}{$Pos}{\"access\"} = \"private\";\n                    }\n                    else\n                    {\n                        # NOTE: default access of struct members in the debug info is \"public\"\n                    }\n                }\n                if($TInfo{\"Type\"} eq \"Union\") {\n                    $TInfo{\"Memb\"}{$Pos}{\"offset\"} = \"0\";\n                }\n                elsif(defined $MInfo->{\"mloc\"}) {\n                    $TInfo{\"Memb\"}{$Pos}{\"offset\"} = $MInfo->{\"mloc\"};\n                }\n            }\n            \n            if((my $BitSize = $MInfo->{\"bit_size\"}) ne \"\") {\n                $TInfo{\"Memb\"}{$Pos}{\"bitfield\"} = $BitSize;\n            }\n        }\n    }\n    \n    my $NS = $NameSpace{$ID};\n    if(not $NS)\n    {\n        if(my $Sp = $DWARF_Info{$ID}{\"spec\"}) {\n            $NS = $NameSpace{$Sp};\n        }\n    }\n    \n    if($NS and $DWARF_Info{$NS}{\"kind\"}=~/\\A(class_type|structure_type)\\Z/)\n    { # member class\n        if(my $Access = $DWARF_Info{$ID}{\"access\"})\n        {\n            if($Access ne \"public\")\n            { # NOTE: default access of member classes in the ABI dump is \"public\"\n                $TInfo{ucfirst($Access)} = 1;\n            }\n        }\n        else\n        {\n            if($DWARF_Info{$NS}{\"kind\"} eq \"class_type\")\n            {\n                # NOTE: default access of member classes in the debug info is \"private\"\n                $TInfo{\"Private\"} = 1;\n            }\n            else\n            {\n                # NOTE: default access to struct member classes in the debug info is \"public\"\n            }\n        }\n    }\n    else\n    {\n        if(my $Access = $DWARF_Info{$ID}{\"access\"})\n        {\n            if($Access ne \"public\")\n            { # NOTE: default access of classes in the ABI dump is \"public\"\n                $TInfo{ucfirst($Access)} = 1;\n            }\n        }\n    }\n    \n    my $Size = $DWARF_Info{$ID}{\"size\"};\n    if($Size ne \"\") {\n        $TInfo{\"Size\"} = $Size;\n    }\n    \n    setSource(\\%TInfo, $ID);\n    \n    if(not $DWARF_Info{$ID}{\"name\"}\n    and my $Spec = $DWARF_Info{$ID}{\"spec\"}) {\n        $DWARF_Info{$ID}{\"name\"} = $DWARF_Info{$Spec}{\"name\"};\n    }\n    \n    if($NS)\n    {\n        if($DWARF_Info{$NS}{\"kind\"} eq \"namespace\")\n        {\n            if(my $NS_F = completeNS($ID))\n            {\n                $TInfo{\"NameSpace\"} = $NS_F;\n            }\n        }\n        elsif($DWARF_Info{$NS}{\"kind\"} eq \"class_type\"\n        or $DWARF_Info{$NS}{\"kind\"} eq \"structure_type\")\n        { # class\n            getTypeInfo($NS);\n            \n            if(my $Sp = $SpecElem{$NS}) {\n                getTypeInfo($Sp);\n            }\n            \n            if($TypeInfo{$NS}{\"Name\"})\n            {\n                $TInfo{\"NameSpace\"} = $TypeInfo{$NS}{\"Name\"};\n                $TInfo{\"NameSpace\"}=~s/\\Astruct //;\n            }\n        }\n    }\n    \n    if(my $Name = $DWARF_Info{$ID}{\"name\"})\n    {\n        $TInfo{\"Name\"} = $Name;\n        \n        if($TInfo{\"NameSpace\"}) {\n            $TInfo{\"Name\"} = $TInfo{\"NameSpace\"}.\"::\".$TInfo{\"Name\"};\n        }\n        \n        if($TInfo{\"Type\"}=~/\\A(Struct|Enum|Union)\\Z/) {\n            $TInfo{\"Name\"} = lc($TInfo{\"Type\"}).\" \".$TInfo{\"Name\"};\n        }\n    }\n    \n    if($TInfo{\"Type\"} eq \"Struct\")\n    {\n        if(not $TInfo{\"Name\"})\n        {\n            if(defined $TInfo{\"Memb\"}\n            and $TInfo{\"Memb\"}{0}{\"name\"} eq \"__pfn\")\n            { # __pfn and __delta\n                my $Pfn = $TInfo{\"Memb\"}{0}{\"type\"};\n                if(my $Pfn_B = $DWARF_Info{$Pfn}{\"type\"})\n                {\n                    if($DWARF_Info{$Pfn_B}{\"kind\"} eq \"subroutine_type\")\n                    {\n                        $TInfo{\"Type\"} = \"MethodPtr\";\n                    }\n                }\n            }\n        }\n    }\n    \n    if($TInfo{\"Type\"}=~/Pointer|Ptr|Ref/)\n    {\n        if(not $TInfo{\"Size\"}) {\n            $TInfo{\"Size\"} = $SYS_WORD;\n        }\n    }\n    \n    if($TInfo{\"Type\"} eq \"Pointer\")\n    {\n        if($DWARF_Info{$TInfo{\"BaseType\"}}{\"kind\"} eq \"subroutine_type\")\n        {\n            initFuncType(\\%TInfo, $TInfo{\"BaseType\"}, \"FuncPtr\");\n        }\n    }\n    elsif($TInfo{\"Type\"}=~/Typedef|Const|Volatile/)\n    {\n        if($DWARF_Info{$TInfo{\"BaseType\"}}{\"kind\"} eq \"subroutine_type\")\n        {\n            getTypeInfo($TInfo{\"BaseType\"});\n        }\n    }\n    elsif($TInfo{\"Type\"} eq \"Func\")\n    {\n        initFuncType(\\%TInfo, $ID, \"Func\");\n    }\n    elsif($TInfo{\"Type\"} eq \"MethodPtr\")\n    {\n        my $Pfn_B = undef;\n        \n        if(defined $TInfo{\"Memb\"}\n        and $TInfo{\"Memb\"}{0}{\"name\"} eq \"__pfn\")\n        {\n            if(my $Pfn = $TInfo{\"Memb\"}{0}{\"type\"}) {\n                $Pfn_B = $DWARF_Info{$Pfn}{\"type\"};\n            }\n        }\n        else\n        { # support for Clang\n            $Pfn_B = $DWARF_Info{$ID}{\"pfn\"};\n        }\n        \n        if($Pfn_B)\n        {\n            my @Prms = ();\n            my $PPos = 0;\n            foreach my $Pos (sort {$a<=>$b} keys(%{$FuncParam{$Pfn_B}}))\n            {\n                my $ParamId = $FuncParam{$Pfn_B}{$Pos};\n                my %PInfo = %{$DWARF_Info{$ParamId}};\n                \n                if(defined $PInfo{\"art\"})\n                { # this\n                    next;\n                }\n                \n                if(my $PTypeId = $PInfo{\"type\"})\n                {\n                    $TInfo{\"Param\"}{$PPos}{\"type\"} = $PTypeId;\n                    getTypeInfo($PTypeId);\n                    push(@Prms, $TypeInfo{$PTypeId}{\"Name\"});\n                }\n                \n                $PPos += 1;\n            }\n            \n            if(my $ClassId = $DWARF_Info{$Pfn_B}{\"objptr\"})\n            {\n                while($DWARF_Info{$ClassId}{\"type\"}) {\n                    $ClassId = $DWARF_Info{$ClassId}{\"type\"};\n                }\n                $TInfo{\"Class\"} = $ClassId;\n                getTypeInfo($TInfo{\"Class\"});\n            }\n            \n            if($TInfo{\"Return\"} = $DWARF_Info{$Pfn_B}{\"type\"}) {\n                getTypeInfo($TInfo{\"Return\"});\n            }\n            else\n            { # void\n                $TInfo{\"Return\"} = \"1\";\n            }\n            \n            $TInfo{\"Name\"} = createMethodPtrName(\\%TInfo);\n            \n            delete($TInfo{\"BaseType\"});\n        }\n    }\n    elsif($TInfo{\"Type\"} eq \"FieldPtr\")\n    {\n        $TInfo{\"Return\"} = $TInfo{\"BaseType\"};\n        delete($TInfo{\"BaseType\"});\n        \n        if(my $Class = $DWARF_Info{$ID}{\"container\"})\n        {\n            $TInfo{\"Class\"} = $Class;\n            getTypeInfo($TInfo{\"Class\"});\n            \n            $TInfo{\"Name\"} = createFieldPtrName(\\%TInfo);\n        }\n        \n        $TInfo{\"Size\"} = $SYS_WORD;\n    }\n    elsif($TInfo{\"Type\"} eq \"String\")\n    {\n        $TInfo{\"Type\"} = \"Pointer\";\n        $TInfo{\"Name\"} = \"char*\";\n        $TInfo{\"BaseType\"} = $TName_Tid{\"Intrinsic\"}{\"char\"};\n    }\n    \n    if(defined $Inheritance{$ID})\n    {\n        foreach my $Pos (sort {$a<=>$b} keys(%{$Inheritance{$ID}}))\n        {\n            if(my $BaseId = $Inheritance{$ID}{$Pos}{\"id\"})\n            {\n                if(my $E = $SpecElem{$BaseId}) {\n                    $BaseId = $E;\n                }\n                \n                $TInfo{\"Base\"}{$BaseId}{\"pos\"} = \"$Pos\";\n                if(my $Access = $Inheritance{$ID}{$Pos}{\"access\"}) {\n                    $TInfo{\"Base\"}{$BaseId}{\"access\"} = $Access;\n                }\n                if($Inheritance{$ID}{$Pos}{\"virtual\"}) {\n                    $TInfo{\"Base\"}{$BaseId}{\"virtual\"} = 1;\n                }\n                \n                $ClassChild{$BaseId}{$ID} = 1;\n            }\n        }\n    }\n    \n    if(not $TInfo{\"BaseType\"})\n    {\n        if($TInfo{\"Type\"} eq \"Pointer\")\n        {\n            $TInfo{\"Name\"} = \"void*\";\n            $TInfo{\"BaseType\"} = \"1\";\n        }\n        elsif($TInfo{\"Type\"} eq \"Const\")\n        {\n            $TInfo{\"Name\"} = \"const void\";\n            $TInfo{\"BaseType\"} = \"1\";\n        }\n        elsif($TInfo{\"Type\"} eq \"Volatile\")\n        {\n            $TInfo{\"Name\"} = \"volatile void\";\n            $TInfo{\"BaseType\"} = \"1\";\n        }\n        elsif($TInfo{\"Type\"} eq \"Typedef\")\n        {\n            $TInfo{\"BaseType\"} = \"1\";\n        }\n    }\n    \n    if(not $TInfo{\"Name\"}\n    and $TInfo{\"Type\"} ne \"Enum\")\n    {\n        my $ID_ = $ID;\n        my $BaseID = undef;\n        my $Name = \"\";\n        \n        while($BaseID = $DWARF_Info{$ID_}{\"type\"})\n        {\n            my $Kind = $DWARF_Info{$ID_}{\"kind\"};\n            if(my $Q = $Qual{$TypeType{$Kind}})\n            {\n                $Name = $Q.$Name;\n                if($Q=~/\\A\\w/) {\n                    $Name = \" \".$Name;\n                }\n            }\n            if(defined $TypeInfo{$BaseID}\n            and $TypeInfo{$BaseID}{\"Name\"})\n            {\n                $Name = $TypeInfo{$BaseID}{\"Name\"}.$Name;\n                last;\n            }\n            elsif(defined $DWARF_Info{$BaseID}\n            and $DWARF_Info{$BaseID}{\"name\"})\n            {\n                $Name = $DWARF_Info{$BaseID}{\"name\"}.$Name;\n                $ID_ = $BaseID;\n            }\n            elsif(defined $Compressed\n            and not defined $AllUnits)\n            {\n                $Name = \"T#\".$BaseID.$Name;\n                last;\n            }\n            else\n            { # error\n                last;\n            }\n        }\n        \n        if($Name) {\n            $TInfo{\"Name\"} = $Name;\n        }\n        \n        if($TInfo{\"Type\"} eq \"Array\")\n        {\n            if(my $Count = $ArrayCount{$ID})\n            {\n                $TInfo{\"Name\"} .= \"[\".$Count.\"]\";\n                if(my $BType = $TInfo{\"BaseType\"})\n                {\n                    if(my $BSize = $TypeInfo{$BType}{\"Size\"})\n                    {\n                        if(my $Size = $Count*$BSize)\n                        {\n                            $TInfo{\"Size\"} = \"$Size\";\n                        }\n                    }\n                }\n            }\n            else\n            {\n                $TInfo{\"Name\"} .= \"[]\";\n                $TInfo{\"Size\"} = $SYS_WORD;\n            }\n        }\n        elsif($TInfo{\"Type\"} eq \"Pointer\")\n        {\n            if(my $BType = $TInfo{\"BaseType\"})\n            {\n                if($TypeInfo{$BType}{\"Type\"}=~/MethodPtr|FuncPtr/)\n                { # void(GTestSuite::**)()\n                  # int(**)(...)\n                    if($TInfo{\"Name\"}=~s/\\*\\Z//) {\n                        $TInfo{\"Name\"}=~s/\\*(\\))/\\*\\*$1/;\n                    }\n                }\n            }\n        }\n    }\n    \n    if(my $Bid = $TInfo{\"BaseType\"})\n    {\n        if(not $TInfo{\"Size\"}\n        and $TypeInfo{$Bid}{\"Size\"}) {\n            $TInfo{\"Size\"} = $TypeInfo{$Bid}{\"Size\"};\n        }\n    }\n    if($TInfo{\"Name\"}) {\n        $TInfo{\"Name\"} = formatName($TInfo{\"Name\"}, \"T\");\n    }\n    \n    if($TInfo{\"Name\"}=~/>\\Z/)\n    {\n        my ($Short, $TParams) = getTParams($ID, $TInfo{\"Name\"});\n        \n        if($TParams)\n        {\n            delete($TInfo{\"TParam\"});\n            \n            foreach my $Pos (0 .. $#{$TParams}) {\n                $TInfo{\"TParam\"}{$Pos} = $TParams->[$Pos];\n            }\n            \n            my @TKeys = getTKeys($TParams);\n            @TKeys = shortTParams($Short, \\@TKeys);\n            \n            $TInfo{\"Name\"} = formatName($Short.\"<\".join(\", \", @TKeys).\">\", \"T\");\n        }\n    }\n    \n    if(not $TInfo{\"Name\"})\n    {\n        if($TInfo{\"Type\"}=~/\\A(Class|Struct|Enum|Union)\\Z/)\n        {\n            if($TInfo{\"Header\"}) {\n                $TInfo{\"Name\"} = \"anon-\".lc($TInfo{\"Type\"}).\"-\".$TInfo{\"Header\"}.\"-\".$TInfo{\"Line\"};\n            }\n            elsif($TInfo{\"Source\"}) {\n                $TInfo{\"Name\"} = \"anon-\".lc($TInfo{\"Type\"}).\"-\".$TInfo{\"Source\"}.\"-\".$TInfo{\"SourceLine\"};\n            }\n            else\n            {\n                if(not defined $TypeMember{$ID})\n                {\n                    if(not defined $ANON_TYPE_WARN{$TInfo{\"Type\"}})\n                    {\n                        printMsg(\"WARNING\", \"a \\\"\".$TInfo{\"Type\"}.\"\\\" type with no attributes detected in the DWARF dump ($ID)\");\n                        $ANON_TYPE_WARN{$TInfo{\"Type\"}} = 1;\n                    }\n                    $TInfo{\"Name\"} = \"anon-\".lc($TInfo{\"Type\"});\n                }\n            }\n            \n            if($TInfo{\"Name\"} and $TInfo{\"NameSpace\"}) {\n                $TInfo{\"Name\"} = $TInfo{\"NameSpace\"}.\"::\".$TInfo{\"Name\"};\n            }\n        }\n    }\n    \n    if($TInfo{\"Name\"}) {\n        registerTName($ID, $TInfo{\"Name\"}, $TInfo{\"Type\"});\n    }\n    \n    if(defined $TInfo{\"Source\"})\n    {\n        if(not defined $TInfo{\"Header\"})\n        {\n            $TInfo{\"Line\"} = $TInfo{\"SourceLine\"};\n            delete($TInfo{\"SourceLine\"});\n        }\n    }\n    \n    foreach my $Attr (keys(%TInfo)) {\n        $TypeInfo{$ID}{$Attr} = $TInfo{$Attr};\n    }\n    \n    if(my $BASE_ID = $DWARF_Info{$ID}{\"spec\"})\n    {\n        foreach my $Attr (keys(%{$TypeInfo{$BASE_ID}}))\n        {\n            if($Attr ne \"Type\") {\n                $TypeInfo{$ID}{$Attr} = $TypeInfo{$BASE_ID}{$Attr};\n            }\n        }\n        \n        foreach my $Attr (keys(%{$TypeInfo{$ID}})) {\n            $TypeInfo{$BASE_ID}{$Attr} = $TypeInfo{$ID}{$Attr};\n        }\n        \n        $TypeSpec{$ID} = $BASE_ID;\n    }\n\n    if(defined $ExtraDump)\n    {\n        if($ID>$GLOBAL_ID_T) {\n            $GLOBAL_ID_T = $ID;\n        }\n    }\n\n    # remove duplicates\n    my $DId = undef;\n    \n    if(defined $DuplBaseType{$TInfo{\"Name\"}}) {\n        $DId = $DuplBaseType{$TInfo{\"Name\"}};\n    }\n    else\n    {\n        my @DIds = sort {$a<=>$b} keys(%{$TName_Tids{$TInfo{\"Type\"}}{$TInfo{\"Name\"}}});\n        \n        if($#DIds>0)\n        {\n            foreach (@DIds)\n            {\n                if($_>0)\n                {\n                    $DId = $_;\n                    last;\n                }\n            }\n        }\n    }\n    \n    if($DId and $DId ne $ID)\n    {\n        my $TInfo_D = $TypeInfo{$DId};\n        if(keys(%{$TInfo_D})==keys(%{$TypeInfo{$ID}}))\n        {\n            $TypeInfo{$ID} = $TInfo_D;\n            $DuplBaseType{$TInfo{\"Name\"}} = $DId;\n        }\n    }\n}\n\nsub registerTName($$$)\n{\n    my ($ID, $Name, $Type) = @_;\n    \n    if(not defined $TName_Tid{$Type}{$Name}\n    or ($ID>0 and $ID<$TName_Tid{$Type}{$Name})\n    or ($ID>0 and $TName_Tid{$Type}{$Name}<0))\n    {\n        $TName_Tid{$Type}{$Name} = \"$ID\";\n    }\n    $TName_Tids{$Type}{$Name}{$ID} = 1;\n}\n\nsub createMethodPtrName($)\n{\n    my $TInfo = $_[0];\n    \n    my @Prms = ();\n    \n    if($TInfo->{\"Param\"})\n    {\n        foreach my $Pos (sort {$a<=>$b} keys(%{$TInfo->{\"Param\"}})) {\n            push(@Prms, $TypeInfo{$TInfo->{\"Param\"}{$Pos}{\"type\"}}{\"Name\"});\n        }\n    }\n    \n    my $TName = $TypeInfo{$TInfo->{\"Return\"}}{\"Name\"};\n    $TName .= \"(\".$TypeInfo{$TInfo->{\"Class\"}}{\"Name\"}.\"::*)\";\n    $TName .= \"(\".join(\",\", @Prms).\")\";\n    \n    return $TName;\n}\n\nsub createFieldPtrName($)\n{\n    my $TInfo = $_[0];\n    \n    return $TypeInfo{$TInfo->{\"Return\"}}{\"Name\"}.\"(\".$TypeInfo{$TInfo->{\"Class\"}}{\"Name\"}.\"::*)\";\n}\n\nsub computeValue($)\n{\n    my $Ref = $_[0];\n    \n    my $TTid = $Ref->{\"type\"};\n    my $TTName = $TypeInfo{$TTid}{\"Name\"};\n    \n    my $Val = $Ref->{\"val\"};\n    \n    if($TTName eq \"bool\")\n    {\n        if($Val eq \"1\") {\n            $Val = \"true\";\n        }\n        elsif($Val eq \"0\") {\n            $Val = \"false\";\n        }\n    }\n    else\n    {\n        if($Val=~/\\A\\d+\\Z/)\n        {\n            if(my $S = $ConstSuffix{$TTName}) {\n                $Val .= $S;\n            }\n        }\n    }\n    \n    return $Val;\n}\n\nsub setSource(@)\n{\n    my $R = shift(@_);\n    my $ID = shift(@_);\n    my $Target = undef;\n    \n    if(@_) {\n        $Target = shift(@_);\n    }\n    \n    my $File = $DWARF_Info{$ID}{\"file\"};\n    my $Line = $DWARF_Info{$ID}{\"line\"};\n    \n    if(defined $File)\n    {\n        my $InfoName = undef;\n        if(index($File, \"(\")!=-1)\n        { # Support for new elfutils (Fedora 30)\n            if($File=~s/\\A(.+?)\\s+\\((\\d+)\\)/$1/) {\n                $InfoName = $1;\n            }\n        }\n        \n        my $Name = undef;\n        \n        if($ID>=0) {\n            $Name = $SourceFile{$DWARF_Info{$ID}{\"unit\"}}{$File};\n        }\n        else\n        { # imported\n            $Name = $SourceFile_Alt{0}{$File};\n        }\n\n        if(not $Name) {\n            $Name = $InfoName;\n        }\n        \n        if($Name=~/\\.($HEADER_EXT)\\Z/i\n        or index($Name, \".\")==-1)\n        { # header\n            if(not defined $Target or $Target eq \"Header\")\n            {\n                $R->{\"Header\"} = $Name;\n                if(defined $Line) {\n                    $R->{\"Line\"} = $Line;\n                }\n            }\n            elsif($Target eq \"Line\")\n            {\n                if(defined $Line and $R->{\"Header\"} eq $Name) {\n                    $R->{\"Line\"} = $Line;\n                }\n            }\n        }\n        elsif(index($Name, \"<built-in>\")==-1)\n        { # source\n            if(not defined $Target or $Target eq \"Source\")\n            {\n                $R->{\"Source\"} = $Name;\n                if(defined $Line) {\n                    $R->{\"SourceLine\"} = $Line;\n                }\n            }\n        }\n    }\n}\n\nsub skipSymbol($)\n{\n    if($SkipCxx and not $STDCXX_TARGET)\n    {\n        if($_[0]=~/\\A(_ZS|_ZNS|_ZNKS|_ZN9__gnu_cxx|_ZNK9__gnu_cxx|_ZTIS|_ZTSS|_Zd|_Zn)/)\n        { # stdc++ symbols\n            return 1;\n        }\n    }\n    return 0;\n}\n\nsub findCenter($$)\n{\n    my ($Name, $Target) = @_;\n    my %B = ( \"(\"=>0, \"<\"=>0, \")\"=>0, \">\"=>0 );\n    foreach my $Pos (0 .. length($Name)-1)\n    {\n        my $S = substr($Name, length($Name)-1-$Pos, 1);\n        if(defined $B{$S}) {\n            $B{$S}+=1;\n        }\n        if($S eq $Target)\n        {\n            if($B{\"(\"}==$B{\")\"}\n            and $B{\"<\"}==$B{\">\"}) {\n                return length($Name)-1-$Pos;\n            }\n        }\n    }\n    return 0;\n}\n\nsub isExternal($)\n{\n    my $ID = $_[0];\n    \n    if($DWARF_Info{$ID}{\"ext\"}) {\n        return 1;\n    }\n    elsif(my $Spec = $DWARF_Info{$ID}{\"spec\"})\n    {\n        if($DWARF_Info{$Spec}{\"ext\"}) {\n            return 1;\n        }\n    }\n    \n    return 0;\n}\n\nsub symByAddr($)\n{\n    my $Loc = $_[0];\n    \n    my ($Addr, $Sect) = (\"\", \"\");\n    if($Loc=~/\\+(.+)/)\n    {\n        $Addr = $1;\n        if(not $Addr=~s/\\A0x//)\n        {\n            $Addr=~s/\\A00//;\n        }\n    }\n    if($Loc=~/([\\w\\.]+)\\+/) {\n        $Sect = $1;\n    }\n    \n    if($Addr ne \"\")\n    {\n        foreach ($Sect, \"\")\n        {\n            if(defined $SymbolTable{$_}{$Addr})\n            {\n                if(my @Symbols = sort keys(%{$SymbolTable{$_}{$Addr}})) {\n                    return $Symbols[0];\n                }\n            }\n        }\n    }\n    \n    return undef;\n}\n\nsub getMangled($)\n{\n    my $ID = $_[0];\n    \n    if(not defined $AddrToName)\n    {\n        if(my $Link = $DWARF_Info{$ID}{\"linkage\"})\n        {\n            return $Link;\n        }\n    }\n    \n    if(my $Low_Pc = $DWARF_Info{$ID}{\"low_pc\"})\n    {\n        if($Low_Pc=~/<([\\w\\@\\.]+)>/) {\n            return $1;\n        }\n        else\n        {\n            if(my $Symbol = symByAddr($Low_Pc)) {\n                return $Symbol;\n            }\n        }\n    }\n    \n    if(my $Loc = $DWARF_Info{$ID}{\"location\"})\n    {\n        if($Loc=~/<([\\w\\@\\.]+)>/) {\n            return $1;\n        }\n        else\n        {\n            if(my $Symbol = symByAddr($Loc)) {\n                return $Symbol;\n            }\n        }\n    }\n    \n    if(my $Link = $DWARF_Info{$ID}{\"linkage\"})\n    {\n        return $Link;\n    }\n    \n    return undef;\n}\n\nsub completeNS($)\n{\n    my $ID = $_[0];\n    \n    my $NS = undef;\n    my $ID_ = $ID;\n    my @NSs = ();\n    \n    while($NS = $NameSpace{$ID_}\n    or $NS = $NameSpace{$DWARF_Info{$ID_}{\"spec\"}})\n    {\n        if(my $N = $DWARF_Info{$NS}{\"name\"}) {\n            push(@NSs, $N);\n        }\n        $ID_ = $NS;\n    }\n    \n    if(@NSs)\n    {\n        my $N = join(\"::\", reverse(@NSs));\n        $NestedNameSpaces{$N} = 1;\n        return $N;\n    }\n    \n    return undef;\n}\n\nsub getSymbolInfo($)\n{\n    my $ID = $_[0];\n    \n    if(my $N = $NameSpace{$ID})\n    {\n        if($DWARF_Info{$N}{\"kind\"} eq \"lexical_block\"\n        or $DWARF_Info{$N}{\"kind\"} eq \"prog\")\n        { # local variables\n            return;\n        }\n    }\n    \n    my $Orig = $DWARF_Info{$ID}{\"orig\"};\n    my $Container = undef;\n    \n    if(defined $DWARF_Info{$ID}{\"container\"}) {\n        $Container = $DWARF_Info{$ID}{\"container\"};\n    }\n    elsif(defined $DWARF_Info{$Orig}{\"container\"}) {\n        $Container = $DWARF_Info{$Orig}{\"container\"};\n    }\n    \n    if(defined $Container\n    and defined $LexicalId{$Container})\n    { # local functions\n        return;\n    }\n    \n    if(my $Loc = $DWARF_Info{$ID}{\"location\"})\n    {\n        if($Loc=~/ reg\\d+\\Z/)\n        { # local variables\n            return;\n        }\n    }\n    \n    my $ShortName = $DWARF_Info{$ID}{\"name\"};\n    my $MnglName = getMangled($ID);\n    \n    if(not $MnglName)\n    {\n        if(my $Sp = $SpecElem{$ID})\n        {\n            $MnglName = getMangled($Sp);\n            \n            if(not $MnglName)\n            {\n                if(my $OrigSp = $OrigElem{$Sp})\n                {\n                    $MnglName = getMangled($OrigSp);\n                }\n            }\n        }\n    }\n    \n    if(not $MnglName)\n    {\n        if($ShortName!~/\\W/)\n        { # C-func\n            $MnglName = $ShortName;\n        }\n    }\n    \n    if(defined $Compressed\n    and not defined $AllUnits)\n    {\n        if(not $MnglName)\n        {\n            if(not $Partial) {\n                return;\n            }\n        }\n    }\n    else\n    {\n        if(not $MnglName) {\n            return;\n        }\n    }\n    \n    if(index($MnglName, \"\\@\")!=-1) {\n        $MnglName=~s/([\\@]+.*?)\\Z//;\n    }\n    \n    if($MnglName=~/\\W/)\n    { # unmangled operators, etc.\n      # foo.part.14\n      # bar.isra.15\n        return;\n    }\n    \n    if(skipSymbol($MnglName)) {\n        return;\n    }\n    \n    my %SInfo = ();\n    \n    if($DWARF_Info{$ID}{\"kind\"} eq \"variable\")\n    { # global data\n        $SInfo{\"Data\"} = 1;\n    }\n    \n    if($ShortName) {\n        $SInfo{\"ShortName\"} = $ShortName;\n    }\n    $SInfo{\"MnglName\"} = $MnglName;\n    \n    if($MnglName and my $OLD_ID = $Mangled_ID{$MnglName})\n    { # duplicates\n        if(not defined $SymbolInfo{$OLD_ID}{\"Header\"}) {\n            setSource($SymbolInfo{$OLD_ID}, $ID, \"Header\");\n        }\n        \n        if(not defined $SymbolInfo{$OLD_ID}{\"Line\"}) {\n            setSource($SymbolInfo{$OLD_ID}, $ID, \"Line\");\n        }\n        \n        if(not defined $SymbolInfo{$OLD_ID}{\"Source\"}) {\n            setSource($SymbolInfo{$OLD_ID}, $ID, \"Source\");\n        }\n        \n        if(not defined $SymbolInfo{$OLD_ID}{\"ShortName\"}\n        and $ShortName) {\n            $SymbolInfo{$OLD_ID}{\"ShortName\"} = $ShortName;\n        }\n        \n        if(defined $DWARF_Info{$OLD_ID}{\"low_pc\"}\n        or not defined $DWARF_Info{$ID}{\"low_pc\"})\n        {\n            if(defined $Checked_Spec{$MnglName}\n            or not $DWARF_Info{$ID}{\"spec\"})\n            {\n                if(defined $SymbolInfo{$OLD_ID}{\"Param\"}\n                or not defined $FuncParam{$ID})\n                {\n                    if(defined $SymbolInfo{$OLD_ID}{\"Return\"}\n                    or not defined $DWARF_Info{$ID}{\"type\"})\n                    {\n                        if(not defined $SpecElem{$ID}\n                        and not defined $OrigElem{$ID}) {\n                            delete($DWARF_Info{$ID});\n                        }\n                        return;\n                    }\n                }\n            }\n        }\n    }\n    \n    if($ShortName)\n    {\n        if($MnglName eq $ShortName)\n        {\n            delete($SInfo{\"MnglName\"});\n            $MnglName = $ShortName;\n        }\n        elsif($MnglName\n        and index($MnglName, \"_Z\")!=0)\n        {\n            if($SInfo{\"ShortName\"})\n            {\n                if(index($SInfo{\"ShortName\"}, \".\")==-1) {\n                    $SInfo{\"Alias\"} = $SInfo{\"ShortName\"};\n                }\n                $SInfo{\"ShortName\"} = $SInfo{\"MnglName\"};\n            }\n            \n            delete($SInfo{\"MnglName\"});\n            $MnglName = $ShortName;\n        }\n    }\n    else\n    {\n        if(index($MnglName, \"_Z\")!=0)\n        {\n            $SInfo{\"ShortName\"} = $SInfo{\"MnglName\"};\n            delete($SInfo{\"MnglName\"});\n        }\n    }\n    \n    if(isExternal($ID)) {\n        $SInfo{\"External\"} = 1;\n    }\n    \n    if($Orig)\n    {\n        if(isExternal($Orig)) {\n            $SInfo{\"External\"} = 1;\n        }\n    }\n    \n    if(index($MnglName, \"_ZNVK\")==0)\n    {\n        $SInfo{\"Const\"} = 1;\n        $SInfo{\"Volatile\"} = 1;\n    }\n    elsif(index($MnglName, \"_ZNV\")==0) {\n        $SInfo{\"Volatile\"} = 1;\n    }\n    elsif(index($MnglName, \"_ZNK\")==0) {\n        $SInfo{\"Const\"} = 1;\n    }\n    \n    if($DWARF_Info{$ID}{\"art\"}) {\n        $SInfo{\"Artificial\"} = 1;\n    }\n    \n    my ($C, $D) = ();\n    \n    if($MnglName=~/(C[1-4])[EI].+/)\n    {\n        $C = $1;\n        $SInfo{\"Constructor\"} = 1;\n    }\n    \n    if($MnglName=~/(D[0-4])[EI].+/)\n    {\n        $D = $1;\n        $SInfo{\"Destructor\"} = 1;\n    }\n    \n    if($C or $D)\n    {\n        if($Orig)\n        {\n            if(my $InLine = $DWARF_Info{$Orig}{\"inline\"})\n            {\n                if(index($InLine, \"declared_not_inlined\")==0)\n                {\n                    $SInfo{\"InLine\"} = 1;\n                    $SInfo{\"Artificial\"} = 1;\n                }\n            }\n            \n            setSource(\\%SInfo, $Orig);\n            \n            if(my $Spec = $DWARF_Info{$Orig}{\"spec\"})\n            {\n                setSource(\\%SInfo, $Spec);\n                \n                $SInfo{\"ShortName\"} = $DWARF_Info{$Spec}{\"name\"};\n                if($D) {\n                    $SInfo{\"ShortName\"}=~s/\\A\\~//g;\n                }\n                \n                if(my $Class = $NameSpace{$Spec}) {\n                    $SInfo{\"Class\"} = $Class;\n                }\n                \n                if(my $Virt = $DWARF_Info{$Spec}{\"virt\"})\n                {\n                    if(index($Virt, \"virtual\")!=-1) {\n                        $SInfo{\"Virt\"} = 1;\n                    }\n                }\n                \n                if(my $Access = $DWARF_Info{$Spec}{\"access\"})\n                {\n                    if($Access ne \"public\")\n                    { # default access of methods in the ABI dump is \"public\"\n                        $SInfo{ucfirst($Access)} = 1;\n                    }\n                }\n                else\n                { # NOTE: default access of class methods in the debug info is \"private\"\n                    if($TypeInfo{$SInfo{\"Class\"}}{\"Type\"} eq \"Class\")\n                    {\n                        $SInfo{\"Private\"} = 1;\n                    }\n                }\n                \n                if(not defined $Compressed\n                or defined $AllUnits)\n                {\n                    # clean origin\n                    delete($SymbolInfo{$Spec});\n                }\n            }\n        }\n    }\n    else\n    {\n        if(my $InLine = $DWARF_Info{$ID}{\"inline\"})\n        {\n            if(index($InLine, \"declared_inlined\")==0) {\n                $SInfo{\"DeclaredInlined\"} = 1;\n            }\n        }\n    }\n    \n    if(defined $AddrToName)\n    {\n        if(not $SInfo{\"Alias\"}\n        and not $SInfo{\"Constructor\"}\n        and not $SInfo{\"Destructor\"})\n        {\n            if(my $Linkage = $DWARF_Info{$ID}{\"linkage\"})\n            {\n                if($Linkage ne $MnglName) {\n                    $SInfo{\"Alias\"} = $Linkage;\n                }\n            }\n        }\n    }\n    \n    if($SInfo{\"Data\"})\n    {\n        if(my $Spec = $DWARF_Info{$ID}{\"spec\"})\n        {\n            if($DWARF_Info{$Spec}{\"kind\"} eq \"member\")\n            {\n                setSource(\\%SInfo, $Spec);\n                $SInfo{\"ShortName\"} = $DWARF_Info{$Spec}{\"name\"};\n                \n                if(my $NSp = $NameSpace{$Spec})\n                {\n                    if($DWARF_Info{$NSp}{\"kind\"} eq \"namespace\") {\n                        $SInfo{\"NameSpace\"} = completeNS($Spec);\n                    }\n                    else {\n                        $SInfo{\"Class\"} = $NSp;\n                    }\n                }\n            }\n        }\n    }\n    \n    if(my $Access = $DWARF_Info{$ID}{\"access\"})\n    {\n        if($Access ne \"public\")\n        { # default access of methods in the ABI dump is \"public\"\n            $SInfo{ucfirst($Access)} = 1;\n        }\n    }\n    elsif(not $DWARF_Info{$ID}{\"spec\"}\n    and not $Orig)\n    {\n        if(my $NS = $NameSpace{$ID})\n        {\n            if(defined $TypeInfo{$NS})\n            { # NOTE: default access of class methods in the debug info is \"private\"\n                if($TypeInfo{$NS}{\"Type\"} eq \"Class\")\n                {\n                    $SInfo{\"Private\"} = 1;\n                }\n            }\n        }\n    }\n    \n    if(my $Class = $DWARF_Info{$ID}{\"container\"})\n    {\n        $SInfo{\"Class\"} = $Class;\n    }\n    \n    if(my $NS = $NameSpace{$ID})\n    {\n        if($DWARF_Info{$NS}{\"kind\"} eq \"namespace\") {\n            $SInfo{\"NameSpace\"} = completeNS($ID);\n        }\n        else {\n            $SInfo{\"Class\"} = $NS;\n        }\n    }\n    \n    if($SInfo{\"Class\"} and $MnglName\n    and index($MnglName, \"_Z\")!=0) {\n        return;\n    }\n    \n    if(my $Return = $DWARF_Info{$ID}{\"type\"})\n    {\n        $SInfo{\"Return\"} = $Return;\n    }\n    if(my $Spec = $DWARF_Info{$ID}{\"spec\"})\n    {\n        if(not $DWARF_Info{$ID}{\"type\"})\n        {\n            if(my $SpRet = $DWARF_Info{$Spec}{\"type\"}) {\n                $SInfo{\"Return\"} = $SpRet;\n            }\n        }\n        if(my $Value = $DWARF_Info{$Spec}{\"cval\"})\n        {\n            if($Value=~/ block:\\s*(.*?)\\Z/) {\n                $Value = $1;\n            }\n            $SInfo{\"Value\"} = $Value;\n        }\n    }\n    \n    if($SInfo{\"ShortName\"}=~/>\\Z/)\n    { # foo<T1, T2, ...>\n        my ($Short, $TParams) = getTParams($ID, $SInfo{\"ShortName\"});\n        \n        if($TParams)\n        {\n            foreach my $Pos (0 .. $#{$TParams}) {\n                $SInfo{\"TParam\"}{$Pos} = $TParams->[$Pos];\n            }\n            \n            my @TKeys = getTKeys($TParams);\n            \n            $SInfo{\"ShortName\"} = $Short.formatName(\"<\".join(\", \", @TKeys).\">\", \"T\");\n        }\n    }\n    elsif($SInfo{\"ShortName\"}=~/\\Aoperator (\\w.*)\\Z/)\n    { # operator type<T1>::name\n        $SInfo{\"ShortName\"} = \"operator \".simpleName($1);\n    }\n    \n    if(my $Virt = $DWARF_Info{$ID}{\"virt\"})\n    {\n        if(index($Virt, \"virtual\")!=-1)\n        {\n            if($D or defined $SpecElem{$ID}) {\n                $SInfo{\"Virt\"} = 1;\n            }\n            else {\n                $SInfo{\"PureVirt\"} = 1;\n            }\n        }\n        \n        if((my $VirtPos = $DWARF_Info{$ID}{\"vloc\"}) ne \"\")\n        {\n            $SInfo{\"VirtPos\"} = $VirtPos;\n        }\n    }\n    \n    setSource(\\%SInfo, $ID);\n    \n    if(not $SInfo{\"Header\"})\n    {\n        if($SInfo{\"Class\"})\n        { # detect missed header by class\n            if(defined $TypeInfo{$SInfo{\"Class\"}}{\"Header\"}) {\n                $SInfo{\"Header\"} = $TypeInfo{$SInfo{\"Class\"}}{\"Header\"};\n            }\n        }\n    }\n    \n    my $PPos = 0;\n    \n    foreach my $Pos (sort {$a<=>$b} keys(%{$FuncParam{$ID}}))\n    {\n        my $ParamId = $FuncParam{$ID}{$Pos};\n        my $Offset = undef;\n        my %Regs = ();\n        \n        if(my $Sp = $SpecElem{$ID})\n        {\n            if(defined $FuncParam{$Sp}) {\n                $ParamId = $FuncParam{$Sp}{$Pos};\n            }\n        }\n        \n        if((my $Loc = $DWARF_Info{$ParamId}{\"location\"}) ne \"\") {\n            $Offset = $Loc;\n        }\n        elsif((my $LL = $DWARF_Info{$ParamId}{\"location_list\"}) ne \"\")\n        {\n            if(my $L = $DebugLoc{$LL})\n            {\n                if($L=~/reg(\\d+)/) {\n                    $Regs{0} = $RegName{$1};\n                }\n                elsif($L=~/fbreg\\s+(-?\\w+)\\Z/) {\n                    $Offset = $1;\n                }\n            }\n            elsif(not defined $DebugLoc{$LL})\n            { # invalid debug_loc\n                if(not $InvalidDebugLoc)\n                {\n                    printMsg(\"ERROR\", \"invalid debug_loc section of object, please fix your elf utils\");\n                    $InvalidDebugLoc = 1;\n                }\n            }\n        }\n        elsif(defined $ExtraDump)\n        {\n            my $Piece = 0;\n            foreach my $P (sort {int($a)<=>int($b)} keys(%{$FullLoc{$ParamId}}))\n            {\n                my $L = $FullLoc{$ParamId}{$P};\n\n                if($L=~/piece (\\d+)/) {\n                    $Piece = $1;\n                }\n                elsif($L=~/stack_value/)\n                {\n                    # Nothing to do\n                }\n                elsif($L=~/reg(\\d+)/)\n                {\n                    $Regs{$Piece} = $RegName{$1};\n                }\n                else\n                {\n                    # Error\n                }\n            }\n        }\n        elsif(defined $DWARF_Info{$ParamId}{\"register\"})\n        {\n            my $R = $DWARF_Info{$ParamId}{\"register\"};\n            $Regs{0} = $RegName{$R};\n        }\n        \n        if(my $OrigP = $DWARF_Info{$ParamId}{\"orig\"}) {\n            $ParamId = $OrigP;\n        }\n        \n        if(not defined $DWARF_Info{$ParamId})\n        { # this is probably a lexical block\n            printMsg(\"ERROR\", \"incomplete info for symbol $ID\");\n            return;\n        }\n        \n        my %PInfo = %{$DWARF_Info{$ParamId}};\n        \n        if(defined $PInfo{\"name\"}\n        and ($PInfo{\"name\"} eq \"__in_chrg\" or $PInfo{\"name\"} eq \"__vtt_parm\")) {\n            next;\n        }\n        \n        if(defined $Offset\n        and not defined $IncompatibleOpt)\n        {\n            if($SYS_ARCH eq \"x86_64\")\n            {\n                if($Offset<0) { # debug-info failure\n                    $Offset = undef;\n                }\n            }\n            \n            if(defined $Offset) {\n                $SInfo{\"Param\"}{$Pos}{\"offset\"} = \"$Offset\";\n            }\n        }\n        \n        if($TypeInfo{$PInfo{\"type\"}}{\"Type\"} eq \"Const\")\n        {\n            if(my $BTid = $TypeInfo{$PInfo{\"type\"}}{\"BaseType\"})\n            {\n                if($TypeInfo{$BTid}{\"Type\"} eq \"Ref\")\n                { # const&const -> const&\n                    $PInfo{\"type\"} = $BTid;\n                }\n            }\n        }\n        \n        $SInfo{\"Param\"}{$Pos}{\"type\"} = $PInfo{\"type\"};\n        \n        if(defined $PInfo{\"name\"}) {\n            $SInfo{\"Param\"}{$Pos}{\"name\"} = $PInfo{\"name\"};\n        }\n        elsif($TypeInfo{$PInfo{\"type\"}}{\"Name\"} ne \"...\") {\n            $SInfo{\"Param\"}{$Pos}{\"name\"} = \"p\".($PPos+1);\n        }\n        \n        if(my @R = keys(%Regs)\n        and not defined $IncompatibleOpt)\n        {\n            if(defined $ExtraDump)\n            {\n                # FIXME: 0+8, 1+16, etc. (for partially distributed parameters)\n                foreach my $RP (@R)\n                {\n                    my $O = $Pos;\n                    if($RP) {\n                        $O .= \"+\".$RP;\n                    }\n\n                    $SInfo{\"Reg\"}{$O} = $Regs{$RP};\n                }\n            }\n            else\n            {\n                $SInfo{\"Reg\"}{$Pos} = $Regs{$R[0]};\n            }\n        }\n        \n        if($DWARF_Info{$ParamId}{\"art\"} and $Pos==0)\n        {\n            if($SInfo{\"Param\"}{$Pos}{\"name\"} eq \"p1\") {\n                $SInfo{\"Param\"}{$Pos}{\"name\"} = \"this\";\n            }\n        }\n        \n        if($SInfo{\"Param\"}{$Pos}{\"name\"} ne \"this\")\n        { # this, p1, p2, etc.\n            $PPos += 1;\n        }\n    }\n    \n    if($SInfo{\"Constructor\"} and not $SInfo{\"InLine\"}\n    and $SInfo{\"Class\"}) {\n        delete($TypeInfo{$SInfo{\"Class\"}}{\"Copied\"});\n    }\n    \n    my $BASE_ID = undef;\n    \n    if($MnglName) {\n        $BASE_ID = $Mangled_ID{$MnglName};\n    }\n    \n    if(defined $Compressed\n    and not defined $AllUnits)\n    {\n        if($MnglName and not $BASE_ID)\n        {\n            my $B_ID = undef;\n            if(my $Sp = $DWARF_Info{$ID}{\"spec\"}) {\n                $B_ID = $Sp;\n            }\n            elsif($Orig)\n            {\n                if(my $OrigSp = $DWARF_Info{$Orig}{\"spec\"}) {\n                    $B_ID = $OrigSp;\n                }\n            }\n            \n            if($B_ID and $B_ID>0)\n            { # negative ones are not used for symbols\n                $BASE_ID = $B_ID;\n                \n                if($MnglName) {\n                    $Mangled_ID{$MnglName} = $BASE_ID;\n                }\n                \n                # drop old mangled name\n                delete($Mangled_ID{$SymbolInfo{$BASE_ID}{\"MnglName\"}});\n            }\n        }\n    }\n    \n    if($BASE_ID)\n    {\n        if(defined $SInfo{\"Param\"})\n        {\n            if($MnglName and index($MnglName, \"_Z\")!=0)\n            {\n                my $DifferentParams = (keys(%{$SInfo{\"Param\"}})!=keys(%{$SymbolInfo{$BASE_ID}{\"Param\"}}));\n                if($DifferentParams or keys(%{$SInfo{\"Param\"}})==1)\n                { # different symbols with the same name\n                    if(defined $SInfo{\"Param\"}\n                    and $SInfo{\"Param\"}{0}{\"type\"}==\"-1\")\n                    { # missed signature (...)\n                        return;\n                    }\n                }\n                \n                if($DifferentParams)\n                { # take the last one\n                    delete($SymbolInfo{$BASE_ID});\n                }\n            }\n        }\n        \n        $ID = $BASE_ID;\n        \n        if(defined $SymbolInfo{$ID}{\"PureVirt\"})\n        { # if the specification of a symbol is located in other compile unit\n            delete($SymbolInfo{$ID}{\"PureVirt\"});\n            $SymbolInfo{$ID}{\"Virt\"} = 1;\n        }\n    }\n    \n    if($MnglName) {\n        $Mangled_ID{$MnglName} = $ID;\n    }\n    \n    if($DWARF_Info{$ID}{\"spec\"}) {\n        $Checked_Spec{$MnglName} = 1;\n    }\n    \n    my $MixedSymbols = 0;\n    \n    if(defined $SInfo{\"Param\"}\n    and defined $SymbolInfo{$ID}\n    and defined $SymbolInfo{$ID}{\"Param\"})\n    {\n        foreach my $K1 (keys(%{$SInfo{\"Param\"}}))\n        {\n            if(defined $SymbolInfo{$ID}{\"Param\"}{$K1})\n            {\n                if($SInfo{\"Param\"}{$K1}{\"type\"} eq \"-1\"\n                and $SymbolInfo{$ID}{\"Param\"}{$K1}{\"type\"} ne \"-1\")\n                {\n                    $MixedSymbols = 1;\n                    last;\n                }\n            }\n        }\n    }\n    \n    if(not $MixedSymbols)\n    {\n        foreach my $Attr (keys(%SInfo))\n        {\n            if(ref($SInfo{$Attr}) eq \"HASH\")\n            {\n                my @Prms = keys(%{$SInfo{$Attr}});\n                \n                if($Attr eq \"Param\" and @Prms\n                and defined $SymbolInfo{$ID}\n                and defined $SymbolInfo{$ID}{$Attr})\n                {\n                    my $Clear = 0;\n                    \n                    if(keys(%{$SymbolInfo{$ID}{$Attr}})!=$#Prms+1)\n                    { # do not mix parameters of different symbols\n                        $Clear = 1;\n                    }\n                    \n                    if($Clear) {\n                        $SymbolInfo{$ID}{$Attr} = {};\n                    }\n                }\n                \n                foreach my $K1 (keys(%{$SInfo{$Attr}}))\n                {\n                    if(ref($SInfo{$Attr}{$K1}) eq \"HASH\")\n                    {\n                        foreach my $K2 (keys(%{$SInfo{$Attr}{$K1}}))\n                        {\n                            $SymbolInfo{$ID}{$Attr}{$K1}{$K2} = $SInfo{$Attr}{$K1}{$K2};\n                        }\n                    }\n                    else {\n                        $SymbolInfo{$ID}{$Attr}{$K1} = $SInfo{$Attr}{$K1};\n                    }\n                }\n            }\n            else\n            {\n                $SymbolInfo{$ID}{$Attr} = $SInfo{$Attr};\n            }\n        }\n    }\n    \n    if($ID>$GLOBAL_ID) {\n        $GLOBAL_ID = $ID;\n    }\n}\n\nsub fixHeader($)\n{\n    my $SInfo = $_[0];\n    \n    if(not $SInfo->{\"Header\"}\n    or ($SInfo->{\"External\"} and not defined $PublicHeader{$SInfo->{\"Header\"}}))\n    {\n        if($SInfo->{\"MnglName\"} and defined $SymbolToHeader{$SInfo->{\"MnglName\"}})\n        {\n            $SInfo->{\"Header\"} = chooseHeader($SInfo->{\"MnglName\"}, $SInfo->{\"Source\"});\n            delete($SInfo->{\"Line\"});\n        }\n        elsif(not $SInfo->{\"Class\"}\n        and defined $SymbolToHeader{$SInfo->{\"ShortName\"}})\n        {\n            $SInfo->{\"Header\"} = chooseHeader($SInfo->{\"ShortName\"}, $SInfo->{\"Source\"});\n            delete($SInfo->{\"Line\"});\n        }\n    }\n    \n    if($SInfo->{\"Alias\"})\n    {\n        if(defined $SymbolToHeader{$SInfo->{\"Alias\"}}) {\n            $SInfo->{\"Header\"} = chooseHeader($SInfo->{\"Alias\"}, $SInfo->{\"Source\"});\n        }\n    }\n}\n\nsub chooseHeader($$)\n{\n    my ($Symbol, $Source) = @_;\n    \n    my @Headers = sort keys(%{$SymbolToHeader{$Symbol}});\n    \n    if($#Headers==0) {\n        return $Headers[0];\n    }\n    \n    @Headers = sort {length($a)<=>length($b)} sort {lc($a) cmp lc($b)} @Headers;\n    \n    $Source=~s/\\.\\w+\\Z//g;\n    \n    foreach my $Header (@Headers)\n    {\n        if($Header=~/\\A\\Q$Source\\E(|\\.[\\w\\+]+)\\Z/i) {\n            return $Header;\n        }\n    }\n    \n    my $SPrefix = undef;\n    \n    if(length($Source)>3) {\n        $SPrefix = substr($Source, 0, 3);\n    }\n    \n    if(defined $SPrefix)\n    {\n        foreach my $Header (@Headers)\n        {\n            if($Header=~/\\A\\Q$SPrefix\\E/i) {\n                return $Header;\n            }\n        }\n    }\n    \n    return $Headers[0];\n}\n\nsub getTypeIdByName($$)\n{\n    my ($Type, $Name) = @_;\n    return $TName_Tid{$Type}{formatName($Name, \"T\")};\n}\n\nsub getFirst($)\n{\n    my $Tid = $_[0];\n    if(not $Tid) {\n        return $Tid;\n    }\n    \n    if(defined $DeletedAnon{$Tid}) {\n        $Tid = $DeletedAnon{$Tid};\n    }\n    \n    if(defined $TypeSpec{$Tid}) {\n        $Tid = $TypeSpec{$Tid};\n    }\n    \n    if(my $Name = $TypeInfo{$Tid}{\"Name\"})\n    {\n        my $Type = $TypeInfo{$Tid}{\"Type\"};\n        \n        my $FTid = undef;\n        \n        if($FTid = $TName_Tid{$Type}{$Name}) {\n            return \"$FTid\";\n        }\n        \n        if($Name=~s/\\Astruct //)\n        { # search for class or derived types (const, *, etc.)\n            foreach my $Type (\"Class\", \"Const\", \"Ref\", \"RvalueRef\", \"Pointer\")\n            {\n                if($FTid = $TName_Tid{$Type}{$Name})\n                {\n                    if($FTid ne $Tid)\n                    {\n                        $MergedTypes{$Tid} = 1;\n                    }\n                    return \"$FTid\";\n                }\n            }\n            \n            $Name = \"struct \".$Name;\n        }\n        \n        if(not $FTid) {\n            $FTid = $TName_Tid{$Type}{$Name};\n        }\n        \n        if($FTid) {\n            return \"$FTid\";\n        }\n        printMsg(\"ERROR\", \"internal error (missed type id $Tid)\");\n    }\n    \n    return $Tid;\n}\n\nsub searchTypeID($)\n{\n    my $Name = $_[0];\n    \n    my %Pr = map {$_=>1} (\n        \"Struct\",\n        \"Union\",\n        \"Enum\"\n    );\n    \n    foreach my $Type (\"Class\", \"Struct\", \"Union\", \"Enum\", \"Typedef\", \"Const\",\n    \"Volatile\", \"Ref\", \"RvalueRef\", \"Pointer\", \"FuncPtr\", \"MethodPtr\", \"FieldPtr\")\n    {\n        my $Tid = $TName_Tid{$Type}{$Name};\n        \n        if(not $Tid)\n        {\n            if(defined $Pr{$Type})\n            {\n                my $NN = lc($Type).\" \".$Name;\n                if(defined $TName_Tid{$Type}{$NN}) {\n                    $Tid = $TName_Tid{$Type}{$NN};\n                }\n            }\n        }\n        if($Tid) {\n            return $Tid;\n        }\n    }\n    return undef;\n}\n\nsub removeUnused()\n{ # remove unused data types from the ABI dump\n    %HeadersInfo = ();\n    %SourcesInfo = ();\n    \n    my (%SelectedHeaders, %SelectedSources) = ();\n    \n    foreach my $ID (sort {$a<=>$b} keys(%SymbolInfo))\n    {\n        if($SelectedSymbols{$ID}==2)\n        { # data, inline, pure\n            next;\n        }\n        \n        registerSymbolUsage($ID);\n        \n        if(my $H = $SymbolInfo{$ID}{\"Header\"}) {\n            $SelectedHeaders{$H} = 1;\n        }\n        if(my $S = $SymbolInfo{$ID}{\"Source\"}) {\n            $SelectedSources{$S} = 1;\n        }\n    }\n    \n    foreach my $ID (sort {$a<=>$b} keys(%SymbolInfo))\n    {\n        if($SelectedSymbols{$ID}==2)\n        { # data, inline, pure\n            my $Save = 0;\n            if(my $Class = getFirst($SymbolInfo{$ID}{\"Class\"}))\n            {\n                if(defined $UsedType{$Class}) {\n                    $Save = 1;\n                }\n                else\n                {\n                    if(defined $ClassChild{$Class})\n                    {\n                        foreach (keys(%{$ClassChild{$Class}}))\n                        {\n                            if(defined $UsedType{getFirst($_)})\n                            {\n                                $Save = 1;\n                                last;\n                            }\n                        }\n                    }\n                }\n            }\n            if(my $Header = $SymbolInfo{$ID}{\"Header\"})\n            {\n                if(defined $SelectedHeaders{$Header}) {\n                    $Save = 1;\n                }\n            }\n            if(my $Source = $SymbolInfo{$ID}{\"Source\"})\n            {\n                if(defined $SelectedSources{$Source}) {\n                    $Save = 1;\n                }\n            }\n            if($Save) {\n                registerSymbolUsage($ID);\n            }\n            else {\n                delete($SymbolInfo{$ID});\n            }\n        }\n    }\n    \n    if(defined $AllTypes)\n    {\n        # register all data types (except anon structs and unions)\n        foreach my $Tid (keys(%TypeInfo))\n        {\n            if(defined $LocalType{$Tid})\n            { # except local code\n                next;\n            }\n            if($TypeInfo{$Tid}{\"Type\"} eq \"Enum\"\n            or index($TypeInfo{$Tid}{\"Name\"}, \"anon-\")!=0) {\n                registerTypeUsage($Tid);\n            }\n        }\n        \n        # remove unused anons (except enums)\n        foreach my $Tid (keys(%TypeInfo))\n        {\n            if(not $UsedType{$Tid})\n            {\n                if($TypeInfo{$Tid}{\"Type\"} ne \"Enum\")\n                {\n                    if(index($TypeInfo{$Tid}{\"Name\"}, \"anon-\")==0) {\n                        delete($TypeInfo{$Tid});\n                    }\n                }\n            }\n        }\n        \n        # remove duplicates\n        foreach my $Tid (keys(%TypeInfo))\n        {\n            my $Name = $TypeInfo{$Tid}{\"Name\"};\n            my $Type = $TypeInfo{$Tid}{\"Type\"};\n            \n            if($TName_Tid{$Type}{$Name} ne $Tid) {\n                delete($TypeInfo{$Tid});\n            }\n        }\n    }\n    else\n    {\n        foreach my $Tid (keys(%TypeInfo))\n        { # remove unused types\n            if(not $UsedType{$Tid}) {\n                delete($TypeInfo{$Tid});\n            }\n        }\n    }\n    \n    foreach my $Tid (keys(%MergedTypes)) {\n        delete($TypeInfo{$Tid});\n    }\n    \n    foreach my $Tid (keys(%LocalType))\n    {\n        if(not $UsedType{$Tid}) {\n            delete($TypeInfo{$Tid});\n        }\n    }\n    \n    # clean memory\n    %MergedTypes = ();\n    %LocalType = ();\n    \n    # completeness\n    foreach my $Tid (sort keys(%TypeInfo)) {\n        checkCompleteness($TypeInfo{$Tid});\n    }\n    \n    foreach my $Sid (sort keys(%SymbolInfo)) {\n        checkCompleteness($SymbolInfo{$Sid});\n    }\n    \n    # clean memory\n    %UsedType = ();\n}\n\nsub simpleName($)\n{\n    my $N = $_[0];\n    \n    $N=~s/\\A(struct|class|union|enum) //; # struct, class, union, enum\n    \n    if(index($N, \"std::basic_string\")!=-1)\n    {\n        $N=~s/std::basic_string<char, std::char_traits<char>, std::allocator<char> >/std::string /g;\n        $N=~s/std::basic_string<char, std::char_traits<char> >/std::string /g;\n        $N=~s/std::basic_string<char>/std::string /g;\n        \n        $N=~s/std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >/std::wstring /g;\n    }\n    \n    if(index($N, \"std::basic_ostream\")!=-1) {\n        $N=~s/std::basic_ostream<char, std::char_traits<char> >/std::ostream /g;\n    }\n    \n    return formatName($N, \"T\");\n}\n\nsub registerSymbolUsage($)\n{\n    my $InfoId = $_[0];\n    \n    my %FuncInfo = %{$SymbolInfo{$InfoId}};\n    \n    if(my $S = $FuncInfo{\"Source\"}) {\n        $SourcesInfo{$S} = 1;\n    }\n    if(my $H = $FuncInfo{\"Header\"}) {\n        $HeadersInfo{$H} = 1;\n    }\n    if(my $RTid = getFirst($FuncInfo{\"Return\"}))\n    {\n        registerTypeUsage($RTid);\n        $SymbolInfo{$InfoId}{\"Return\"} = $RTid;\n    }\n    if(my $FCid = getFirst($FuncInfo{\"Class\"}))\n    {\n        registerTypeUsage($FCid);\n        $SymbolInfo{$InfoId}{\"Class\"} = $FCid;\n        \n        if(my $ThisId = getTypeIdByName(\"Const\", $TypeInfo{$FCid}{\"Name\"}.\"*const\"))\n        { # register \"this\" pointer\n            registerTypeUsage($ThisId);\n        }\n        if(my $ThisId_C = getTypeIdByName(\"Const\", $TypeInfo{$FCid}{\"Name\"}.\" const*const\"))\n        { # register \"this\" pointer (const method)\n            registerTypeUsage($ThisId_C);\n        }\n    }\n    foreach my $PPos (keys(%{$FuncInfo{\"Param\"}}))\n    {\n        if(my $PTid = getFirst($FuncInfo{\"Param\"}{$PPos}{\"type\"}))\n        {\n            registerTypeUsage($PTid);\n            $SymbolInfo{$InfoId}{\"Param\"}{$PPos}{\"type\"} = $PTid;\n        }\n    }\n    foreach my $TPos (keys(%{$FuncInfo{\"TParam\"}}))\n    {\n        if(my $TTid = $FuncInfo{\"TParam\"}{$TPos}{\"type\"})\n        {\n            if($TTid = getFirst($TTid))\n            {\n                registerTypeUsage($TTid);\n                $SymbolInfo{$InfoId}{\"TParam\"}{$TPos}{\"type\"} = $TTid;\n                delete($SymbolInfo{$InfoId}{\"TParam\"}{$TPos}{\"name\"});\n            }\n        }\n        elsif(my $TPName = $FuncInfo{\"TParam\"}{$TPos}{\"name\"})\n        {\n            if(my $TTid = searchTypeID($TPName))\n            {\n                if(my $FTTid = getFirst($TTid))\n                {\n                    registerTypeUsage($FTTid);\n                    $SymbolInfo{$InfoId}{\"TParam\"}{$TPos}{\"type\"} = $TTid;\n                    delete($SymbolInfo{$InfoId}{\"TParam\"}{$TPos}{\"name\"});\n                }\n            }\n        }\n    }\n}\n\nsub registerTypeUsage($)\n{\n    my $TypeId = $_[0];\n    if(not $TypeId) {\n        return 0;\n    }\n    if($UsedType{$TypeId})\n    { # already registered\n        return 1;\n    }\n    my %TInfo = %{$TypeInfo{$TypeId}};\n    \n    if(my $S = $TInfo{\"Source\"}) {\n        $SourcesInfo{$S} = 1;\n    }\n    if(my $H = $TInfo{\"Header\"}) {\n        $HeadersInfo{$H} = 1;\n    }\n    \n    if($TInfo{\"Type\"})\n    {\n        if(my $NS = $TInfo{\"NameSpace\"})\n        {\n            if(my $NSTid = searchTypeID($NS))\n            {\n                if(my $FNSTid = getFirst($NSTid)) {\n                    registerTypeUsage($FNSTid);\n                }\n            }\n        }\n        \n        if($TInfo{\"Type\"}=~/\\A(Struct|Union|Class|FuncPtr|Func|MethodPtr|FieldPtr|Enum)\\Z/)\n        {\n            $UsedType{$TypeId} = 1;\n            if($TInfo{\"Type\"}=~/\\A(Struct|Class)\\Z/)\n            {\n                foreach my $BaseId (keys(%{$TInfo{\"Base\"}}))\n                { # register base classes\n                    if(my $FBaseId = getFirst($BaseId))\n                    {\n                        registerTypeUsage($FBaseId);\n                        if($FBaseId ne $BaseId)\n                        {\n                            %{$TypeInfo{$TypeId}{\"Base\"}{$FBaseId}} = %{$TypeInfo{$TypeId}{\"Base\"}{$BaseId}};\n                            delete($TypeInfo{$TypeId}{\"Base\"}{$BaseId});\n                        }\n                    }\n                }\n            }\n            if($TInfo{\"Type\"}=~/\\A(Struct|Class|Union)\\Z/)\n            {\n                foreach my $TPos (keys(%{$TInfo{\"TParam\"}}))\n                {\n                    if(my $TTid = $TInfo{\"TParam\"}{$TPos}{\"type\"})\n                    {\n                        if($TTid = getFirst($TTid))\n                        {\n                            registerTypeUsage($TTid);\n                            $TypeInfo{$TypeId}{\"TParam\"}{$TPos}{\"type\"} = $TTid;\n                            delete($TypeInfo{$TypeId}{\"TParam\"}{$TPos}{\"name\"});\n                        }\n                    }\n                    elsif(my $TPName = $TInfo{\"TParam\"}{$TPos}{\"name\"})\n                    {\n                        if(my $TTid = searchTypeID($TPName))\n                        {\n                            if(my $TTid = getFirst($TTid))\n                            {\n                                registerTypeUsage($TTid);\n                                $TypeInfo{$TypeId}{\"TParam\"}{$TPos}{\"type\"} = $TTid;\n                                delete($TypeInfo{$TypeId}{\"TParam\"}{$TPos}{\"name\"});\n                            }\n                        }\n                    }\n                }\n            }\n            foreach my $Memb_Pos (keys(%{$TInfo{\"Memb\"}}))\n            {\n                if(my $MTid = getFirst($TInfo{\"Memb\"}{$Memb_Pos}{\"type\"}))\n                {\n                    registerTypeUsage($MTid);\n                    $TypeInfo{$TypeId}{\"Memb\"}{$Memb_Pos}{\"type\"} = $MTid;\n                }\n            }\n            if($TInfo{\"Type\"} eq \"FuncPtr\"\n            or $TInfo{\"Type\"} eq \"MethodPtr\"\n            or $TInfo{\"Type\"} eq \"Func\")\n            {\n                if(my $RTid = getFirst($TInfo{\"Return\"}))\n                {\n                    registerTypeUsage($RTid);\n                    $TypeInfo{$TypeId}{\"Return\"} = $RTid;\n                }\n                foreach my $Memb_Pos (keys(%{$TInfo{\"Param\"}}))\n                {\n                    if(my $MTid = getFirst($TInfo{\"Param\"}{$Memb_Pos}{\"type\"}))\n                    {\n                        registerTypeUsage($MTid);\n                        $TypeInfo{$TypeId}{\"Param\"}{$Memb_Pos}{\"type\"} = $MTid;\n                    }\n                }\n            }\n            if($TInfo{\"Type\"} eq \"FieldPtr\")\n            {\n                if(my $RTid = getFirst($TInfo{\"Return\"}))\n                {\n                    registerTypeUsage($RTid);\n                    $TypeInfo{$TypeId}{\"Return\"} = $RTid;\n                }\n                if(my $CTid = getFirst($TInfo{\"Class\"}))\n                {\n                    registerTypeUsage($CTid);\n                    $TypeInfo{$TypeId}{\"Class\"} = $CTid;\n                }\n            }\n            if($TInfo{\"Type\"} eq \"MethodPtr\")\n            {\n                if(my $CTid = getFirst($TInfo{\"Class\"}))\n                {\n                    registerTypeUsage($CTid);\n                    $TypeInfo{$TypeId}{\"Class\"} = $CTid;\n                }\n            }\n            if($TInfo{\"Type\"} eq \"Enum\")\n            {\n                if(my $BTid = getFirst($TInfo{\"BaseType\"}))\n                {\n                    registerTypeUsage($BTid);\n                    $TypeInfo{$TypeId}{\"BaseType\"} = $BTid;\n                }\n            }\n            return 1;\n        }\n        elsif($TInfo{\"Type\"}=~/\\A(Const|ConstVolatile|Volatile|Pointer|Ref|RvalueRef|Restrict|Array|Typedef)\\Z/)\n        {\n            $UsedType{$TypeId} = 1;\n            if(my $BTid = getFirst($TInfo{\"BaseType\"}))\n            {\n                registerTypeUsage($BTid);\n                $TypeInfo{$TypeId}{\"BaseType\"} = $BTid;\n            }\n            return 1;\n        }\n        elsif($TInfo{\"Type\"}=~/\\A(Intrinsic|Unspecified)\\Z/)\n        {\n            $UsedType{$TypeId} = 1;\n            return 1;\n        }\n    }\n    return 0;\n}\n\nsub checkCompleteness($)\n{\n    my $Info = $_[0];\n    \n    # data types\n    if(defined $Info->{\"Memb\"})\n    {\n        foreach my $Pos (sort keys(%{$Info->{\"Memb\"}}))\n        {\n            if(defined $Info->{\"Memb\"}{$Pos}{\"type\"}) {\n                checkTypeInfo($Info->{\"Memb\"}{$Pos}{\"type\"});\n            }\n        }\n    }\n    if(defined $Info->{\"Base\"})\n    {\n        foreach my $Bid (sort keys(%{$Info->{\"Base\"}})) {\n            checkTypeInfo($Bid);\n        }\n    }\n    if(defined $Info->{\"BaseType\"}) {\n        checkTypeInfo($Info->{\"BaseType\"});\n    }\n    if(defined $Info->{\"TParam\"})\n    {\n        foreach my $Pos (sort keys(%{$Info->{\"TParam\"}}))\n        {\n            my $TRef = $Info->{\"TParam\"}{$Pos};\n            \n            if(my $Tid = $TRef->{\"type\"}) {\n                checkTypeInfo($Tid);\n            }\n            else\n            {\n                my $TName = $Info->{\"TParam\"}{$Pos}{\"name\"};\n                if($TName=~/\\A(true|false|\\d.*)\\Z/) {\n                    next;\n                }\n                \n                if(my $Tid = searchTypeID($TName)) {\n                    checkTypeInfo($Tid);\n                }\n                else\n                {\n                    if(defined $Loud) {\n                        printMsg(\"WARNING\", \"missed type $TName\");\n                    }\n                }\n            }\n        }\n    }\n    \n    # symbols\n    if(defined $Info->{\"Param\"})\n    {\n        foreach my $Pos (sort keys(%{$Info->{\"Param\"}}))\n        {\n            if(defined $Info->{\"Param\"}{$Pos}{\"type\"}) {\n                checkTypeInfo($Info->{\"Param\"}{$Pos}{\"type\"});\n            }\n        }\n    }\n    if(defined $Info->{\"Return\"}) {\n        checkTypeInfo($Info->{\"Return\"});\n    }\n    if(defined $Info->{\"Class\"}) {\n        checkTypeInfo($Info->{\"Class\"});\n    }\n}\n\nsub checkTypeInfo($)\n{\n    my $Tid = $_[0];\n    \n    if(defined $CheckedType{$Tid}) {\n        return;\n    }\n    $CheckedType{$Tid} = 1;\n    \n    if(defined $TypeInfo{$Tid})\n    {\n        if(not $TypeInfo{$Tid}{\"Name\"}) {\n            printMsg(\"ERROR\", \"missed type name ($Tid)\");\n        }\n        checkCompleteness($TypeInfo{$Tid});\n    }\n    else {\n        printMsg(\"ERROR\", \"missed type id $Tid\");\n    }\n}\n\nsub initRegs()\n{\n    if($SYS_ARCH eq \"x86\")\n    {\n        %RegName = (\n        # integer registers\n        # 32 bits\n            \"0\"=>\"eax\",\n            \"1\"=>\"ecx\",\n            \"2\"=>\"edx\",\n            \"3\"=>\"ebx\",\n            \"4\"=>\"esp\",\n            \"5\"=>\"ebp\",\n            \"6\"=>\"esi\",\n            \"7\"=>\"edi\",\n            \"8\"=>\"eip\",\n            \"9\"=>\"eflags\",\n            \"10\"=>\"trapno\",\n        # FPU-control registers\n        # 16 bits\n            \"37\"=>\"fctrl\",\n            \"38\"=>\"fstat\",\n        # 32 bits\n            \"39\"=>\"mxcsr\",\n        # MMX registers\n        # 64 bits\n            \"29\"=>\"mm0\",\n            \"30\"=>\"mm1\",\n            \"31\"=>\"mm2\",\n            \"32\"=>\"mm3\",\n            \"33\"=>\"mm4\",\n            \"34\"=>\"mm5\",\n            \"35\"=>\"mm6\",\n            \"36\"=>\"mm7\",\n        # SSE registers\n        # 128 bits\n            \"21\"=>\"xmm0\",\n            \"22\"=>\"xmm1\",\n            \"23\"=>\"xmm2\",\n            \"24\"=>\"xmm3\",\n            \"25\"=>\"xmm4\",\n            \"26\"=>\"xmm5\",\n            \"27\"=>\"xmm6\",\n            \"28\"=>\"xmm7\",\n        # segment registers\n        # 16 bits\n            \"40\"=>\"es\",\n            \"41\"=>\"cs\",\n            \"42\"=>\"ss\",\n            \"43\"=>\"ds\",\n            \"44\"=>\"fs\",\n            \"45\"=>\"gs\",\n        # x87 registers\n        # 80 bits\n            \"11\"=>\"st0\",\n            \"12\"=>\"st1\",\n            \"13\"=>\"st2\",\n            \"14\"=>\"st3\",\n            \"15\"=>\"st4\",\n            \"16\"=>\"st5\",\n            \"17\"=>\"st6\",\n            \"18\"=>\"st7\"\n        );\n    }\n    elsif($SYS_ARCH eq \"x86_64\")\n    {\n        %RegName = (\n        # integer registers\n        # 64 bits\n            \"0\"=>\"rax\",\n            \"1\"=>\"rdx\",\n            \"2\"=>\"rcx\",\n            \"3\"=>\"rbx\",\n            \"4\"=>\"rsi\",\n            \"5\"=>\"rdi\",\n            \"6\"=>\"rbp\",\n            \"7\"=>\"rsp\",\n            \"8\"=>\"r8\",\n            \"9\"=>\"r9\",\n            \"10\"=>\"r10\",\n            \"11\"=>\"r11\",\n            \"12\"=>\"r12\",\n            \"13\"=>\"r13\",\n            \"14\"=>\"r14\",\n            \"15\"=>\"r15\",\n            \"16\"=>\"rip\",\n            \"49\"=>\"rFLAGS\",\n        # MMX registers\n        # 64 bits\n            \"41\"=>\"mm0\",\n            \"42\"=>\"mm1\",\n            \"43\"=>\"mm2\",\n            \"44\"=>\"mm3\",\n            \"45\"=>\"mm4\",\n            \"46\"=>\"mm5\",\n            \"47\"=>\"mm6\",\n            \"48\"=>\"mm7\",\n        # SSE registers\n        # 128 bits\n            \"17\"=>\"xmm0\",\n            \"18\"=>\"xmm1\",\n            \"19\"=>\"xmm2\",\n            \"20\"=>\"xmm3\",\n            \"21\"=>\"xmm4\",\n            \"22\"=>\"xmm5\",\n            \"23\"=>\"xmm6\",\n            \"24\"=>\"xmm7\",\n            \"25\"=>\"xmm8\",\n            \"26\"=>\"xmm9\",\n            \"27\"=>\"xmm10\",\n            \"28\"=>\"xmm11\",\n            \"29\"=>\"xmm12\",\n            \"30\"=>\"xmm13\",\n            \"31\"=>\"xmm14\",\n            \"32\"=>\"xmm15\",\n        # control registers\n        # 64 bits\n            \"62\"=>\"tr\", \n            \"63\"=>\"ldtr\",\n            \"64\"=>\"mxcsr\",\n        # 16 bits\n            \"65\"=>\"fcw\",\n            \"66\"=>\"fsw\",\n        # segment registers\n        # 16 bits\n            \"50\"=>\"es\",\n            \"51\"=>\"cs\",\n            \"52\"=>\"ss\",\n            \"53\"=>\"ds\",\n            \"54\"=>\"fs\",\n            \"55\"=>\"gs\",\n        # 64 bits\n            \"58\"=>\"fs.base\",\n            \"59\"=>\"gs.base\",\n        # x87 registers\n        # 80 bits\n            \"33\"=>\"st0\",\n            \"34\"=>\"st1\",\n            \"35\"=>\"st2\",\n            \"36\"=>\"st3\",\n            \"37\"=>\"st4\",\n            \"38\"=>\"st5\",\n            \"39\"=>\"st6\",\n            \"40\"=>\"st7\"\n        );\n    }\n    elsif($SYS_ARCH eq \"arm\")\n    {\n        %RegName = (\n        # integer registers\n        # 32-bit\n            \"0\"=>\"r0\",\n            \"1\"=>\"r1\",\n            \"2\"=>\"r2\",\n            \"3\"=>\"r3\",\n            \"4\"=>\"r4\",\n            \"5\"=>\"r5\",\n            \"6\"=>\"r6\",\n            \"7\"=>\"r7\",\n            \"8\"=>\"r8\",\n            \"9\"=>\"r9\",\n            \"10\"=>\"r10\",\n            \"11\"=>\"r11\",\n            \"12\"=>\"r12\",\n            \"13\"=>\"r13\",\n            \"14\"=>\"r14\",\n            \"15\"=>\"r15\"\n        );\n    }\n}\n\nsub dumpSorting($)\n{\n    my $Hash = $_[0];\n    return [] if(not $Hash);\n    my @Keys = keys(%{$Hash});\n    return [] if($#Keys<0);\n    if($Keys[0]=~/\\A\\d+\\Z/)\n    { # numbers\n        return [sort {$a<=>$b} @Keys];\n    }\n    else\n    { # strings\n        return [sort {$a cmp $b} @Keys];\n    }\n}\n\nsub getDebugFile($$)\n{\n    my ($Obj, $Header) = @_;\n    \n    my $Str = `$EU_READELF_L --strings=.$Header \\\"$Obj\\\" 2>\\\"$TMP_DIR/error\\\"`;\n    if($Str=~/(\\s|\\[)0\\]\\s*(.+)/) {\n        return $2;\n    }\n    \n    return undef;\n}\n\nsub findFiles(@)\n{\n    my ($Path, $Type) = @_;\n    my $Cmd = \"find \\\"$Path\\\"\";\n    \n    if($Type) {\n        $Cmd .= \" -type \".$Type;\n    }\n    \n    my @Res = split(/\\n/, `$Cmd`);\n    return @Res;\n}\n\nsub isHeader($)\n{\n    my $Path = $_[0];\n    \n    if($Path=~/\\.($HEADER_EXT)\\Z/i) {\n        return 1;\n    }\n    \n    if(index(getFilename($Path), \".\")==-1 and -T $Path)\n    { # C++\n        return 1;\n    }\n    \n    return 0;\n}\n\nsub detectPublicSymbols($)\n{\n    my $Path = $_[0];\n    \n    if(not -e $Path) {\n        exitStatus(\"Access_Error\", \"can't access \\'$Path\\'\");\n    }\n    \n    my $Path_A = abs_path($Path);\n    \n    printMsg(\"INFO\", \"Detect public symbols\");\n    \n    if($UseTU)\n    {\n        if(not checkCmd($GPP)) {\n            exitStatus(\"Not_Found\", \"can't find \\\"$GPP\\\"\");\n        }\n    }\n    else\n    {\n        if(not checkCmd($CTAGS)) {\n            exitStatus(\"Not_Found\", \"can't find \\\"$CTAGS\\\"\");\n        }\n        \n        if(my $CtagsVer = `$CTAGS --version 2>&1`)\n        {\n            if($CtagsVer!~/Universal/i)\n            {\n                printMsg(\"ERROR\", \"requires Universal Ctags to work properly\");\n                if($CtagsVer=~/Exuberant/i) {\n                    $EXUBERANT_CTAGS = 1;\n                }\n            }\n        }\n    }\n    \n    $PublicSymbols_Detected = 1;\n    \n    my @Files = ();\n    my @Headers = ();\n    my @DefaultInc = ();\n    \n    if($PublicHeadersIsDir)\n    { # directory\n        @Files = findFiles($Path, \"f\");\n        \n        foreach my $File (@Files)\n        {\n            if(isHeader($File)) {\n                push(@Headers, $File);\n            }\n        }\n        \n        push(@DefaultInc, $Path_A);\n        \n        if(-d $Path_A.\"/include\") {\n            push(@DefaultInc, $Path_A.\"/include\");\n        }\n    }\n    else\n    { # list of headers\n        @Headers = split(/\\n/, readFile($Path));\n    }\n    \n    if(not @Headers) {\n        exitStatus(\"Error\", \"headers not found in \\'$Path\\'\");\n    }\n    \n    my $PublicHeader_F = $CacheHeaders.\"/PublicHeader.data\";\n    my $SymbolToHeader_F = $CacheHeaders.\"/SymbolToHeader.data\";\n    my $TypeToHeader_F = $CacheHeaders.\"/TypeToHeader.data\";\n    my $Path_F = $CacheHeaders.\"/PATH\";\n    \n    if($CacheHeaders\n    and -f $PublicHeader_F\n    and -f $SymbolToHeader_F\n    and -f $TypeToHeader_F\n    and -f $Path_F)\n    {\n        if(readFile($Path_F) eq $Path_A)\n        {\n            %PublicHeader = %{eval(readFile($PublicHeader_F))};\n            %SymbolToHeader = %{eval(readFile($SymbolToHeader_F))};\n            %TypeToHeader = %{eval(readFile($TypeToHeader_F))};\n            \n            return;\n        }\n    }\n    \n    foreach my $File (@Headers)\n    {\n        $PublicHeader{getFilename($File)} = 1;\n    }\n    \n    my $Is_C = ($OBJ_LANG eq \"C\");\n    \n    my @Langs = undef;\n    \n    if($EXUBERANT_CTAGS)\n    {\n        @Langs = (\"C++\");\n        if($Is_C) {\n            @Langs = (\"C\");\n        }\n    }\n    else\n    {\n        @Langs = (\"C++\", \"OldC++\");\n        if($Is_C) {\n            @Langs = (\"C\", \"OldC\");\n        }\n    }\n    \n    @Headers = sort {length($b)<=>length($a)} sort {lc($b) cmp lc($a)} @Headers;\n    \n    foreach my $File (@Headers)\n    {\n        my $HName = getFilename($File);\n        \n        if($UseTU)\n        {\n            my $TmpDir = $TMP_DIR.\"/tu\";\n            if(not -d $TmpDir) {\n                mkpath($TmpDir);\n            }\n            \n            my $File_A = abs_path($File);\n            \n            my $IncDir = getDirname($File_A);\n            my $IncDir_O = getDirname($IncDir);\n            \n            my $TmpInc = $TmpDir.\"/tmp-inc.h\";\n            my $TmpContent = \"\";\n            if($IncludeDefines)\n            {\n                foreach my $D (split(/;/, $IncludeDefines)) {\n                    $TmpContent = \"#define $D\\n\";\n                }\n            }\n            if($IncludePreamble)\n            {\n                foreach my $P (split(/;/, $IncludePreamble))\n                {\n                    if($P=~/\\A\\//) {\n                        $TmpContent = \"#include \\\"\".$P.\"\\\"\\n\";\n                    }\n                    else {\n                        $TmpContent = \"#include <\".$P.\">\\n\";\n                    }\n                }\n            }\n            $TmpContent .= \"#include \\\"$File_A\\\"\\n\";\n            writeFile($TmpInc, $TmpContent);\n            \n            my $Cmd = $GPP.\" -w -fpermissive -fdump-translation-unit -fkeep-inline-functions -c \\\"$TmpInc\\\"\";\n            \n            if(defined $IncludePaths)\n            {\n                foreach my $P (split(/;/, $IncludePaths))\n                {\n                    if($P!~/\\A\\//) {\n                        $P = $Path_A.\"/\".$P;\n                    }\n                    \n                    $Cmd .= \" -I\\\"\".$P.\"\\\"\";\n                }\n            }\n            else\n            { # automatic\n                $Cmd .= \" -I\\\"$IncDir\\\" -I\\\"$IncDir_O\\\"\";\n            }\n            \n            foreach my $P (@DefaultInc) {\n                $Cmd .= \" -I\\\"$P\\\"\";\n            }\n            \n            $Cmd .= \" -o ./a.out >OUT 2>&1\";\n            \n            chdir($TmpDir);\n            system($Cmd);\n            chdir($ORIG_DIR);\n            \n            my $TuDump = $TmpDir.\"/tmp-inc.h.001t.tu\";\n            my $Errors = $TmpDir.\"/OUT\";\n            \n            if(not -e $TuDump)\n            {\n                printMsg(\"ERROR\", \"failed to list symbols in the header \\'$HName\\'\");\n                if($Debug) {\n                    printMsg(\"ERROR\", readFile($Errors));\n                }\n                next;\n            }\n            elsif($?)\n            {\n                printMsg(\"ERROR\", \"some errors occured when compiling header \\'$HName\\'\");\n                if($Debug) {\n                    printMsg(\"ERROR\", readFile($Errors));\n                }\n            }\n            \n            my (%Fdecl, %Tdecl, %Tname, %Ident, %NotDecl) = ();\n            my $Content = readFile($TuDump);\n            $Content=~s/\\n[ ]+/ /g;\n            \n            my @Lines = split(/\\n/, $Content);\n            foreach my $N (0 .. $#Lines)\n            {\n                my $Line = $Lines[$N];\n                if(index($Line, \"function_decl\")!=-1\n                or index($Line, \"var_decl\")!=-1)\n                {\n                    if($Line=~/name: \\@(\\d+)/)\n                    {\n                        my $Id = $1;\n                        \n                        if($Line=~/srcp: ([^:]+)\\:\\d/)\n                        {\n                            if(defined $PublicHeader{$1}) {\n                                $Fdecl{$Id} = $1;\n                            }\n                        }\n                    }\n                }\n                elsif($Line=~/\\@(\\d+)\\s+identifier_node\\s+strg:\\s+(\\w+)/)\n                {\n                    $Ident{$1} = $2;\n                }\n                elsif($Is_C)\n                {\n                    if(index($Line, \"type_decl\")!=-1)\n                    {\n                        if($Line=~/\\A\\@(\\d+)/)\n                        {\n                            my $Id = $1;\n                            if($Line=~/name: \\@(\\d+)/)\n                            {\n                                my $NId = $1;\n                                \n                                if($Line=~/srcp: ([^:]+)\\:\\d/)\n                                {\n                                    if(defined $PublicHeader{$1})\n                                    {\n                                        $Tdecl{$Id} = $1;\n                                        $Tname{$Id} = $NId;\n                                    }\n                                }\n                            }\n                        }\n                    }\n                    elsif(index($Line, \"record_type\")!=-1\n                    or index($Line, \"union_type\")!=-1)\n                    {\n                        if($Line!~/ flds:/)\n                        {\n                            if($Line=~/name: \\@(\\d+)/)\n                            {\n                                $NotDecl{$1} = 1;\n                            }\n                        }\n                    }\n                    elsif(index($Line, \"enumeral_type\")!=-1)\n                    {\n                        if($Line!~/ csts:/)\n                        {\n                            if($Line=~/name: \\@(\\d+)/)\n                            {\n                                $NotDecl{$1} = 1;\n                            }\n                        }\n                    }\n                    elsif(index($Line, \"integer_type\")!=-1)\n                    {\n                        if($Line=~/name: \\@(\\d+)/)\n                        {\n                            $NotDecl{$1} = 1;\n                        }\n                    }\n                }\n            }\n            \n            foreach my $Id (keys(%Fdecl))\n            {\n                if(my $Name = $Ident{$Id}) {\n                    $SymbolToHeader{$Name}{$Fdecl{$Id}} = 1;\n                }\n            }\n            \n            if($Is_C)\n            {\n                foreach my $Id (keys(%Tdecl))\n                {\n                    if(defined $NotDecl{$Id}) {\n                        next;\n                    }\n                    \n                    if(my $Name = $Ident{$Tname{$Id}}) {\n                        $TypeToHeader{$Name} = $Tdecl{$Id};\n                    }\n                }\n            }\n            \n            unlink($TuDump);\n        }\n        else\n        { # using Ctags\n            my $IgnoreTags = \"\";\n            \n            if(defined $IgnoreTagsPath) {\n                $IgnoreTags .= \" -I \\@\".$IgnoreTagsPath;\n            }\n            \n            if(@CtagsDef)\n            {\n                foreach my $Def (@CtagsDef) {\n                    $IgnoreTags .= \" -D '\".$Def.\"'\";\n                }\n            }\n            \n            foreach my $Lang (@Langs)\n            {\n                my $List_S = `$CTAGS -x --$Lang-kinds=fpvxd --languages=+$Lang --language-force=$Lang $IgnoreTags \\\"$File\\\"`;\n                foreach my $Line (split(/\\n/, $List_S))\n                {\n                    if($Line=~/\\A(\\w+)\\s+(\\w+)/) {\n                        $SymbolToHeader{$1}{$HName} = $2;\n                    }\n                    \n                    if(index($Line, \" macro \")!=-1)\n                    {\n                        if($Line=~/#define\\s+(\\w+)\\s+(\\w+)\\Z/) {\n                            $SymbolToHeader{$2}{$HName} = \"prototype\";\n                        }\n                    }\n                    \n                    if(not $Is_C)\n                    {\n                        if(index($Line, \"operator \")==0)\n                        {\n                            if($Line=~/\\A(operator) (\\w.*?)\\s+(prototype|function)/) {\n                                $SymbolToHeader{$1.\" \".$2}{$HName} = $3;\n                            }\n                            elsif($Line=~/\\A(operator) (\\W.*?)\\s+(prototype|function)/) {\n                                $SymbolToHeader{$1.$2}{$HName} = $3;\n                            }\n                        }\n                    }\n                }\n                \n                if($Is_C)\n                {\n                    my $List_T = `$CTAGS -x --$Lang-kinds=gstu --languages=+$Lang --language-force=$Lang $IgnoreTags \\\"$File\\\"`;\n                    foreach my $Line (split(/\\n/, $List_T))\n                    {\n                        if($Line=~/\\A(\\w+)/)\n                        {\n                            my $N = $1;\n                            \n                            if($Line!~/\\b$N\\s+$N\\b/) {\n                                $TypeToHeader{$N} = $HName;\n                            }\n                        }\n                    }\n                }\n            }\n        }\n    }\n    \n    # We can't fully rely on the output of Ctags because it may\n    # miss some symbols intentionally (due to branches of code)\n    # or occasionally (due to complex macros).\n    if(not $UseTU)\n    {\n        foreach my $File (@Headers)\n        {\n            my $HName = getFilename($File);\n            my $Content = readFile($File);\n            \n            $Content=~s&/\\*.+?\\*/&&sg;\n            $Content=~s&(//|#define).*\\n&\\n&g;\n            \n            # Functions\n            my @Func = ($Content=~/([a-zA-Z]\\w+)\\s*\\(/g);\n            foreach (@Func)\n            {\n                if(not defined $SymbolToHeader{$_} or not defined $SymbolToHeader{$_}{$HName}) {\n                    $SymbolToHeader{$_}{$HName} = \"prototype\";\n                }\n            }\n            \n            # Data\n            my @Data = ($Content=~/([a-zA-Z_]\\w+)\\s*;/gi);\n            foreach (@Data)\n            {\n                if(not defined $SymbolToHeader{$_} or not defined $SymbolToHeader{$_}{$HName}) {\n                    $SymbolToHeader{$_}{$HName} = \"prototype\";\n                }\n            }\n            \n            # Types\n            if($Is_C)\n            {\n                my @Type1 = ($Content=~/}\\s*([a-zA-Z]\\w+)\\s*;/g);\n                my @Type2 = ($Content=~/([a-zA-Z]\\w+)\\s*{/g);\n                foreach (@Type1, @Type2)\n                {\n                    if(not defined $TypeToHeader{$_} or not defined $TypeToHeader{$_}{$HName}) {\n                        $TypeToHeader{$_}{$HName} = 1;\n                    }\n                }\n            }\n        }\n    }\n    \n    if($CacheHeaders)\n    {\n        writeFile($PublicHeader_F, Dumper(\\%PublicHeader));\n        writeFile($SymbolToHeader_F, Dumper(\\%SymbolToHeader));\n        writeFile($TypeToHeader_F, Dumper(\\%TypeToHeader));\n        writeFile($Path_F, $Path_A);\n    }\n}\n\nsub getDebugAltLink($)\n{\n    my $Obj = $_[0];\n    \n    my $AltDebugFile = getDebugFile($Obj, \"gnu_debugaltlink\");\n    \n    if(not $AltDebugFile) {\n        return undef;\n    }\n    \n    my $Dir = getDirname($Obj);\n    \n    my $AltObj_R = $AltDebugFile;\n    if($Dir and $Dir ne \".\") {\n        $AltObj_R = $Dir.\"/\".$AltObj_R;\n    }\n    \n    if(-e $AltObj_R)\n    {\n        printMsg(\"INFO\", \"Set alternate debug-info file to \\'$AltObj_R\\' (use -alt option to change it)\");\n        return $AltObj_R;\n    }\n    \n    printMsg(\"WARNING\", \"can't access \\'$AltObj_R\\'\");\n    return undef;\n}\n\nsub scenario()\n{\n    if($Help)\n    {\n        helpMsg();\n        exit(0);\n    }\n    if($ShowVersion)\n    {\n        printMsg(\"INFO\", \"ABI Dumper $TOOL_VERSION EE\");\n        printMsg(\"INFO\", \"Copyright (C) 2025 Andrey Ponomarenko's ABI Laboratory\");\n        printMsg(\"INFO\", \"License: GNU LGPL 2.1 <http://www.gnu.org/licenses/>\");\n        printMsg(\"INFO\", \"This program is free software: you can redistribute it and/or modify it.\\n\");\n        printMsg(\"INFO\", \"Written by Andrey Ponomarenko.\");\n        exit(0);\n    }\n    if($DumpVersion)\n    {\n        printMsg(\"INFO\", $TOOL_VERSION);\n        exit(0);\n    }\n    \n    $Data::Dumper::Sortkeys = 1;\n    \n    if($SortDump) {\n        $Data::Dumper::Sortkeys = \\&dumpSorting;\n    }\n    \n    if($SearchDirDebuginfo)\n    {\n        if(not -d $SearchDirDebuginfo) {\n            exitStatus(\"Access_Error\", \"can't access directory \\'$SearchDirDebuginfo\\'\");\n        }\n    }\n    \n    if($PublicHeadersPath)\n    {\n        if(not -e $PublicHeadersPath) {\n            exitStatus(\"Access_Error\", \"can't access \\'$PublicHeadersPath\\'\");\n        }\n        \n        $PublicHeadersIsDir = (-d $PublicHeadersPath);\n        \n        foreach my $P (split(/;/, $IncludePaths))\n        {\n            if($PublicHeadersIsDir and $P!~/\\A\\//) {\n                $P = $PublicHeadersPath.\"/\".$P;\n            }\n            \n            if(not -e $P) {\n                exitStatus(\"Access_Error\", \"can't access \\'$P\\'\");\n            }\n        }\n    }\n    \n    if($SymbolsListPath)\n    {\n        if(not -f $SymbolsListPath) {\n            exitStatus(\"Access_Error\", \"can't access file \\'$SymbolsListPath\\'\");\n        }\n        foreach my $S (split(/\\s*\\n\\s*/, readFile($SymbolsListPath))) {\n            $SymbolsList{$S} = 1;\n        }\n    }\n    \n    if($VTDumperPath)\n    {\n        if(not -x $VTDumperPath) {\n            exitStatus(\"Access_Error\", \"can't access \\'$VTDumperPath\\'\");\n        }\n        \n        $VTABLE_DUMPER = $VTDumperPath;\n    }\n    \n    if(defined $Compare)\n    {\n        my $P1 = $ARGV[0];\n        my $P2 = $ARGV[1];\n        \n        if(not $P1) {\n            exitStatus(\"Error\", \"arguments are not specified\");\n        }\n        elsif(not -e $P1) {\n            exitStatus(\"Access_Error\", \"can't access \\'$P1\\'\");\n        }\n        \n        if(not $P2) {\n            exitStatus(\"Error\", \"second argument is not specified\");\n        }\n        elsif(not -e $P2) {\n            exitStatus(\"Access_Error\", \"can't access \\'$P2\\'\");\n        }\n        \n        my %ABI = ();\n        \n        $ABI{1} = eval(readFile($P1));\n        $ABI{2} = eval(readFile($P2));\n        \n        my %SymInfo = ();\n        \n        foreach (1, 2)\n        {\n            foreach my $ID (keys(%{$ABI{$_}->{\"SymbolInfo\"}}))\n            {\n                my $Info = $ABI{$_}->{\"SymbolInfo\"}{$ID};\n                \n                if(my $MnglName = $Info->{\"MnglName\"}) {\n                    $SymInfo{$_}{$MnglName} = $Info;\n                }\n                elsif(my $ShortName = $Info->{\"ShortName\"}) {\n                    $SymInfo{$_}{$ShortName} = $Info;\n                }\n            }\n        }\n        \n        foreach my $Symbol (sort keys(%{$SymInfo{1}}))\n        {\n            if(not defined $SymInfo{2}{$Symbol}) {\n                printMsg(\"INFO\", \"Removed $Symbol\");\n            }\n        }\n        \n        foreach my $Symbol (sort keys(%{$SymInfo{2}}))\n        {\n            if(not defined $SymInfo{1}{$Symbol}) {\n                printMsg(\"INFO\", \"Added $Symbol\");\n            }\n        }\n        \n        exit(0);\n    }\n    \n    if($TargetVersion eq \"\") {\n        printMsg(\"WARNING\", \"module version is not specified (-lver NUM)\");\n    }\n    \n    if($FullDump)\n    {\n        $AllTypes = 1;\n        $AllSymbols = 1;\n    }\n    \n    if(not $OutputDump) {\n        $OutputDump = \"./ABI.dump\";\n    }\n    \n    if(not @ARGV) {\n        exitStatus(\"Error\", \"object path is not specified\");\n    }\n    \n    foreach my $Obj (@ARGV)\n    {\n        if(not -e $Obj) {\n            exitStatus(\"Access_Error\", \"can't access \\'$Obj\\'\");\n        }\n    }\n    \n    if($AltDebugInfoOpt)\n    {\n        if(not -e $AltDebugInfoOpt) {\n            exitStatus(\"Access_Error\", \"can't access \\'$AltDebugInfoOpt\\'\");\n        }\n        $AltDebugInfo = $AltDebugInfoOpt;\n        readAltInfo($AltDebugInfoOpt);\n    }\n    \n    if($ExtraInfo)\n    {\n        mkpath($ExtraInfo);\n        $ExtraInfo = abs_path($ExtraInfo);\n    }\n    \n    initABI();\n    \n    my $Res = 0;\n    \n    foreach my $Obj (@ARGV)\n    {\n        if($Obj=~/\\.a\\Z/) {\n            exitStatus(\"Error\", \"analysis of static libraries is not supported, please dump ABIs of individual objects in the archive or compile a shared library\");\n        }\n        \n        if(not $TargetName)\n        {\n            $TargetName = getFilename(realpath($Obj));\n            $TargetName=~s/\\.debug\\Z//; # nouveau.ko.debug\n            \n            if(index($TargetName, \"libstdc++\")==0\n            or index($TargetName, \"libc++\")==0) {\n                $STDCXX_TARGET = 1;\n            }\n        }\n        \n        readSymbols($Obj);\n        \n        if(not defined $PublicSymbols_Detected)\n        {\n            if(defined $PublicHeadersPath) {\n                detectPublicSymbols($PublicHeadersPath);\n            }\n        }\n        \n        $Res += readDWARFInfo($Obj);\n        \n        %DWARF_Info = ();\n        \n        readVtables($Obj);\n    }\n    \n    if(not defined $Library_Symbol{$TargetName}) {\n        exitStatus(\"No_Exported\", \"can't find exported symbols in object(s), please add a shared object on command line\");\n    }\n    \n    if(not $Res) {\n        exitStatus(\"No_DWARF\", \"can't find debug info in object(s)\");\n    }\n\n    if(defined $ExtraDump)\n    { # add v-table symbols\n        add_VtableSymbols();\n    }\n\n    %VTable_Symbol = ();\n    %VTable_Class = ();\n\n    %VirtualTable = ();\n    \n    completeABI();\n    selectSymbols();\n    removeUnused();\n    \n    if(defined $PublicHeadersPath)\n    {\n        foreach my $Tid (sort {$a<=>$b} keys(%TypeInfo))\n        {\n            if(not $TypeInfo{$Tid}{\"Header\"}\n            or not defined $PublicHeader{$TypeInfo{$Tid}{\"Header\"}})\n            {\n                if($TypeInfo{$Tid}{\"Type\"}=~/Struct|Union|Enum|Typedef/)\n                {\n                    my $TName = $TypeInfo{$Tid}{\"Name\"};\n                    $TName=~s/\\A(struct|class|union|enum) //g;\n                    \n                    if(defined $TypeToHeader{$TName}) {\n                        $TypeInfo{$Tid}{\"Header\"} = $TypeToHeader{$TName};\n                    }\n                    #elsif(index($TName, \"::\")!=-1)\n                    #{\n                    #    if($TName=~/::(.+?)\\Z/)\n                    #    {\n                    #        if(defined $TypeToHeader{$1})\n                    #        {\n                    #            $TypeInfo{$Tid}{\"Header\"} = $TypeToHeader{$1};\n                    #        }\n                    #    }\n                    #}\n                }\n            }\n            \n            if(not selectPublicType($Tid)) {\n                $TypeInfo{$Tid}{\"PrivateABI\"} = 1;\n            }\n        }\n    }\n    \n    if(defined $PublicHeadersPath)\n    {\n        foreach my $H (keys(%HeadersInfo))\n        {\n            if(not defined $PublicHeader{getFilename($H)}) {\n                delete($HeadersInfo{$H});\n            }\n        }\n    }\n    \n    # free memory\n    %Mangled_ID = ();\n    %Checked_Spec = ();\n    %SelectedSymbols = ();\n    %Cache = ();\n    \n    %ClassChild = ();\n    %TypeSpec = ();\n    \n    %SourceFile = ();\n    %SourceFile_Alt = ();\n    %DebugLoc = ();\n    %TName_Tid = ();\n    %TName_Tids = ();\n    %SymbolTable = ();\n\n    %SymbolAttribute = ();\n\n    %NameSpace = ();\n    \n    %DeletedAnon = ();\n    %CheckedType = ();\n    %DuplBaseType = ();\n    \n    %KSymTab = ();\n    %TypeToHeader = ();\n    %PublicHeader = ();\n    \n    createABIFile();\n    \n    exit(0);\n}\n\nscenario();\n"
  }
]