DXR will be turned off on Tuesday, December 29th. It will redirect to Searchfox.
See the announcement on Discourse.

DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (c68fe15a81fc)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308
#!/bin/env python
#!/bin/env python
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
#
# Usage: symbolstore.py <params> <dump_syms path> <symbol store path>
#                                <debug info files or dirs>
#   Runs dump_syms on each debug info file specified on the command line,
#   then places the resulting symbol file in the proper directory
#   structure in the symbol store path.  Accepts multiple files
#   structure in the symbol store path.  Accepts multiple files
#   on the command line, so can be called as part of a pipe using
#   find <dir> | xargs symbolstore.pl <dump_syms> <storepath>
#   But really, you might just want to pass it <dir>.
#
#   Parameters accepted:
#   Parameters accepted:
#     -c           : Copy debug info files to the same directory structure
#                    as sym files. On Windows, this will also copy
#                    binaries into the symbol store.
#     -a "<archs>" : Run dump_syms -a <arch> for each space separated
#                    cpu architecture in <archs> (only on OS X)
#                    cpu architecture in <archs> (only on OS X)
#     -s <srcdir>  : Use <srcdir> as the top source directory to
#                    generate relative filenames.

from __future__ import print_function


import buildconfig
import errno
import sys
import platform
import platform
import os
import re
import shutil
import textwrap
import subprocess
import subprocess
import time
import ctypes

from optparse import OptionParser


from mozbuild.util import memoize
from mozbuild.generated_sources import (
    get_filename_with_digest,
    get_generated_sources,
    get_s3_region_and_bucket,
    get_s3_region_and_bucket,
)
from mozpack.copier import FileRegistry
from mozpack.manifests import (
    InstallManifest,
    UnreadableInstallManifest,
    UnreadableInstallManifest,
)
)

# Utility classes




class VCSFileInfo:
    """ A base class for version-controlled file information. Ensures that the
        following attributes are generated only once (successfully):
        following attributes are generated only once (successfully):

            self.root
            self.clean_root
            self.revision
            self.filename
            self.filename

        The attributes are generated by a single call to the GetRoot,
        GetRevision, and GetFilename methods. Those methods are explicitly not
        implemented here and must be implemented in derived classes. """


    def __init__(self, file):
        if not file:
            raise ValueError
        self.file = file


    def __getattr__(self, name):
        """ __getattr__ is only called for attributes that are not set on self,
            so setting self.[attr] will prevent future calls to the GetRoot,
            GetRevision, and GetFilename methods. We don't set the values on
            failure on the off chance that a future call might succeed. """


        if name == "root":
            root = self.GetRoot()
            if root:
            if root:
                self.root = root
                self.root = root
            return root

        elif name == "clean_root":
        elif name == "clean_root":
            clean_root = self.GetCleanRoot()
            if clean_root:
                self.clean_root = clean_root
            return clean_root


        elif name == "revision":
            revision = self.GetRevision()
            if revision:
                self.revision = revision
            return revision
            return revision

        elif name == "filename":
            filename = self.GetFilename()
            if filename:
                self.filename = filename
                self.filename = filename
            return filename

        raise AttributeError

    def GetRoot(self):
        """ This method should return the unmodified root for the file or 'None'
        """ This method should return the unmodified root for the file or 'None'
            on failure. """
        raise NotImplementedError

    def GetCleanRoot(self):
        """ This method should return the repository root for the file or 'None'
        """ This method should return the repository root for the file or 'None'
            on failure. """
        raise NotImplementedError

    def GetRevision(self):
        """ This method should return the revision number for the file or 'None'
        """ This method should return the revision number for the file or 'None'
            on failure. """
        raise NotImplementedError

    def GetFilename(self):
        """ This method should return the repository-specific filename for the
        """ This method should return the repository-specific filename for the
            file or 'None' on failure. """
        raise NotImplementedError


# This regex separates protocol and optional username/password from a url.
# This regex separates protocol and optional username/password from a url.
# For instance, all the following urls will be transformed into
# 'foo.com/bar':
#
#   http://foo.com/bar
#   svn+ssh://user@foo.com/bar
#   svn+ssh://user:pass@foo.com/bar
#   svn+ssh://user:pass@foo.com/bar
#
rootRegex = re.compile(r"^\S+?:/+(?:[^\s/]*@)?(\S+)$")


def read_output(*args):
def read_output(*args):
    (stdout, _) = subprocess.Popen(
        args=args, universal_newlines=True, stdout=subprocess.PIPE).communicate()
    return stdout.rstrip()



class HGRepoInfo:
    def __init__(self, path):
        self.path = path


        rev = os.environ.get("MOZ_SOURCE_CHANGESET")
        if not rev:
            rev = read_output("hg", "-R", path, "parent", "--template={node}")

        # Look for the default hg path. If MOZ_SOURCE_REPO is set, we
        # don't bother asking hg.
        hg_root = os.environ.get("MOZ_SOURCE_REPO")
        if hg_root:
            root = hg_root
        else:
            root = read_output("hg", "-R", path, "showconfig", "paths.default")
            root = read_output("hg", "-R", path, "showconfig", "paths.default")
            if not root:
                print("Failed to get HG Repo for %s" % path, file=sys.stderr)
        cleanroot = None
        if root:
            match = rootRegex.match(root)
            match = rootRegex.match(root)
            if match:
                cleanroot = match.group(1)
                if cleanroot.endswith("/"):
                    cleanroot = cleanroot[:-1]
        if cleanroot is None:
        if cleanroot is None:
            print(
                textwrap.dedent(
                    """\
            Could not determine repo info for %s.  This is either not a clone of the web-based
            repository, or you have not specified MOZ_SOURCE_REPO, or the clone is corrupt."""
            repository, or you have not specified MOZ_SOURCE_REPO, or the clone is corrupt."""
                ) % path,
                sys.stderr,
            )
            )
            sys.exit(1)
        self.rev = rev
        self.root = root
        self.cleanroot = cleanroot


    def GetFileInfo(self, file):
        return HGFileInfo(file, self)



class HGFileInfo(VCSFileInfo):
    def __init__(self, file, repo):
        VCSFileInfo.__init__(self, file)
        self.repo = repo
        self.file = os.path.relpath(file, repo.path)
        self.file = os.path.relpath(file, repo.path)

    def GetRoot(self):
        return self.repo.root

    def GetCleanRoot(self):
    def GetCleanRoot(self):
        return self.repo.cleanroot

    def GetRevision(self):
        return self.repo.rev


    def GetFilename(self):
        if self.revision and self.clean_root:
            return "hg:%s:%s:%s" % (self.clean_root, self.file, self.revision)
        return self.file
        return self.file


class GitRepoInfo:
    """
    Info about a local git repository. Does not currently
    support discovering info about a git clone, the info must be
    provided out-of-band.
    provided out-of-band.
    """

    def __init__(self, path, rev, root):
        self.path = path
        cleanroot = None
        cleanroot = None
        if root:
            match = rootRegex.match(root)
            if match:
                cleanroot = match.group(1)
                if cleanroot.endswith("/"):
                if cleanroot.endswith("/"):
                    cleanroot = cleanroot[:-1]
        if cleanroot is None:
            print(
                textwrap.dedent(
                    """\
                    """\
            Could not determine repo info for %s (%s).  This is either not a clone of a web-based
            repository, or you have not specified MOZ_SOURCE_REPO, or the clone is corrupt."""
                )
                )
                % (path, root),
                file=sys.stderr,
            )
            sys.exit(1)
        self.rev = rev
        self.rev = rev
        self.cleanroot = cleanroot

    def GetFileInfo(self, file):
        return GitFileInfo(file, self)



class GitFileInfo(VCSFileInfo):
    def __init__(self, file, repo):
        VCSFileInfo.__init__(self, file)
        VCSFileInfo.__init__(self, file)
        self.repo = repo
        self.file = os.path.relpath(file, repo.path)

    def GetRoot(self):
        return self.repo.path
        return self.repo.path

    def GetCleanRoot(self):
        return self.repo.cleanroot

    def GetRevision(self):
    def GetRevision(self):
        return self.repo.rev


    def GetFilename(self):
        if self.revision and self.clean_root:
            return "git:%s:%s:%s" % (self.clean_root, self.file, self.revision)
        return self.file



# Utility functions


# A cache of files for which VCS info has already been determined. Used to
# A cache of files for which VCS info has already been determined. Used to
# prevent extra filesystem activity or process launching.
vcsFileInfoCache = {}

if platform.system() == "Windows":
if platform.system() == "Windows":

    def realpath(path):
        """
        Normalize a path using `GetFinalPathNameByHandleW` to get the
        path with all components in the case they exist in on-disk, so
        path with all components in the case they exist in on-disk, so
        that making links to a case-sensitive server (hg.mozilla.org) works.

        This function also resolves any symlinks in the path.
        """
        # Return the original path if something fails, which can happen for paths that
        # don't exist on this system (like paths from the CRT).
        # don't exist on this system (like paths from the CRT).
        result = path

        ctypes.windll.kernel32.SetErrorMode(ctypes.c_uint(1))
        handle = ctypes.windll.kernel32.CreateFileW(path,
                                                    # GENERIC_READ
                                                    # GENERIC_READ
                                                    0x80000000,
                                                    # FILE_SHARE_READ
                                                    1,
                                                    None,
                                                    # OPEN_EXISTING
                                                    # OPEN_EXISTING
                                                    3,
                                                    # FILE_FLAG_BACKUP_SEMANTICS
                                                    # This is necessary to open
                                                    # directory handles.
                                                    0x02000000,
                                                    0x02000000,
                                                    None)
        if handle != -1:
            size = ctypes.windll.kernel32.GetFinalPathNameByHandleW(handle, None, 0, 0)
            buf = ctypes.create_unicode_buffer(size)
            buf = ctypes.create_unicode_buffer(size)
            if (
                ctypes.windll.kernel32.GetFinalPathNameByHandleW(handle, buf, size, 0)
                > 0
            ):
                # The return value of GetFinalPathNameByHandleW uses the
                # The return value of GetFinalPathNameByHandleW uses the
                # '\\?\' prefix.
                result = buf.value[4:]
                result = buf.value[4:]
            ctypes.windll.kernel32.CloseHandle(handle)
        return result


else:
else:
    # Just use the os.path version otherwise.
    realpath = os.path.realpath


def IsInDir(file, dir):
def IsInDir(file, dir):
    # the lower() is to handle win32+vc8, where
    # the source filenames come out all lowercase,
    # but the srcdir can be mixed case
    return os.path.abspath(file).lower().startswith(os.path.abspath(dir).lower())


def GetVCSFilenameFromSrcdir(file, srcdir):
def GetVCSFilenameFromSrcdir(file, srcdir):
    if srcdir not in Dumper.srcdirRepoInfo:
        # Not in cache, so find it adnd cache it
        if os.path.isdir(os.path.join(srcdir, ".hg")):
            Dumper.srcdirRepoInfo[srcdir] = HGRepoInfo(srcdir)
        else:
        else:
            # Unknown VCS or file is not in a repo.
            return None
    return Dumper.srcdirRepoInfo[srcdir].GetFileInfo(file)
    return Dumper.srcdirRepoInfo[srcdir].GetFileInfo(file)


def GetVCSFilename(file, srcdirs):
    """Given a full path to a file, and the top source directory,
    look for version control information about this file, and return
    look for version control information about this file, and return
    a tuple containing
    1) a specially formatted filename that contains the VCS type,
    VCS location, relative filename, and revision number, formatted like:
    vcs:vcs location:filename:revision
    For example:
    For example:
    cvs:cvs.mozilla.org/cvsroot:mozilla/browser/app/nsBrowserApp.cpp:1.36
    2) the unmodified root information if it exists"""
    (path, filename) = os.path.split(file)
    if path == "" or filename == "":
        return (file, None)
        return (file, None)

    fileInfo = None
    root = ""
    if file in vcsFileInfoCache:
        # Already cached this info, use it.
        fileInfo = vcsFileInfoCache[file]
    else:
    else:
        for srcdir in srcdirs:
            if not IsInDir(file, srcdir):
                continue
            fileInfo = GetVCSFilenameFromSrcdir(file, srcdir)
            if fileInfo:
                vcsFileInfoCache[file] = fileInfo
                break
                break

    if fileInfo:
        file = fileInfo.filename
        root = fileInfo.root


    # we want forward slashes on win32 paths
    return (file.replace("\\", "/"), root)


def validate_install_manifests(install_manifest_args):
def validate_install_manifests(install_manifest_args):
    args = []
    for arg in install_manifest_args:
        bits = arg.split(",")
        if len(bits) != 2:
            raise ValueError('Invalid format for --install-manifest: '
            raise ValueError('Invalid format for --install-manifest: '
                             'specify manifest,target_dir')
        manifest_file, destination = [os.path.abspath(b) for b in bits]
        if not os.path.isfile(manifest_file):
            raise IOError(errno.ENOENT, "Manifest file not found", manifest_file)
        if not os.path.isdir(destination):
            raise IOError(errno.ENOENT, "Install directory not found", destination)
        try:
            manifest = InstallManifest(manifest_file)
        except UnreadableInstallManifest:
            raise IOError(errno.EINVAL, "Error parsing manifest file", manifest_file)
            raise IOError(errno.EINVAL, "Error parsing manifest file", manifest_file)
        args.append((manifest, destination))
    return args


def make_file_mapping(install_manifests):
def make_file_mapping(install_manifests):
    file_mapping = {}
    for manifest, destination in install_manifests:
        destination = os.path.abspath(destination)
        reg = FileRegistry()
        manifest.populate_registry(reg)
        manifest.populate_registry(reg)
        for dst, src in reg:
            if hasattr(src, "path"):
                # Any paths that get compared to source file names need to go through realpath.
                abs_dest = realpath(os.path.join(destination, dst))
                file_mapping[abs_dest] = realpath(src.path)
                file_mapping[abs_dest] = realpath(src.path)
    return file_mapping


@memoize
def get_generated_file_s3_path(filename, rel_path, bucket):
def get_generated_file_s3_path(filename, rel_path, bucket):
    """Given a filename, return a path formatted similarly to
    GetVCSFilename but representing a file available in an s3 bucket."""
    with open(filename, "rb") as f:
        path = get_filename_with_digest(rel_path, f.read())
        return "s3:{bucket}:{path}:".format(bucket=bucket, path=path)



def GetPlatformSpecificDumper(**kwargs):
    """This function simply returns a instance of a subclass of Dumper
    that is appropriate for the current platform."""
    return {"WINNT": Dumper_Win32, "Linux": Dumper_Linux, "Darwin": Dumper_Mac}[
        buildconfig.substs["OS_ARCH"]
        buildconfig.substs["OS_ARCH"]
    ](**kwargs)


def SourceIndex(fileStream, outputPath, vcs_root):
    """Takes a list of files, writes info to a data block in a .stream file"""
    """Takes a list of files, writes info to a data block in a .stream file"""
    # Creates a .pdb.stream file in the mozilla\objdir to be used for source indexing
    # Create the srcsrv data block that indexes the pdb file
    result = True
    pdbStreamFile = open(outputPath, "w")
    pdbStreamFile.write('SRCSRV: ini ------------------------------------------------\r'
    pdbStreamFile.write('SRCSRV: ini ------------------------------------------------\r'
                        + '\nVERSION=2\r\nINDEXVERSION=2\r'
                        + '\nVERCTRL=http\r'
                        + '\nSRCSRV: variables ------------------------------------------\r'
                        + '\nHGSERVER=')
    pdbStreamFile.write(vcs_root)
    pdbStreamFile.write(vcs_root)
    pdbStreamFile.write('\r\nSRCSRVVERCTRL=http\r'
                        + '\nHTTP_EXTRACT_TARGET=%hgserver%/raw-file/%var3%/%var2%\r'
                        + '\nSRCSRVTRG=%http_extract_target%\r'
                        + '\nSRCSRV: source files ---------------------------------------\r\n''')
    pdbStreamFile.write(fileStream)
    # can't do string interpolation because the source server also uses this
    # so there are % in the above
    # so there are % in the above
    pdbStreamFile.write(
        "SRCSRV: end ------------------------------------------------\r\n\n"
    )
    pdbStreamFile.close()
    return result


class Dumper:
class Dumper:
    """This class can dump symbols from a file with debug info, and
    store the output in a directory structure that is valid for use as
    a Breakpad symbol server.  Requires a path to a dump_syms binary--
    |dump_syms| and a directory to store symbols in--|symbol_path|.
    Optionally takes a list of processor architectures to process from
    Optionally takes a list of processor architectures to process from
    each debug file--|archs|, the full path to the top source
    directory--|srcdir|, for generating relative source file names,
    and an option to copy debug info files alongside the dumped
    symbol files--|copy_debug|, mostly useful for creating a
    Microsoft Symbol Server from the resulting output.
    Microsoft Symbol Server from the resulting output.

    You don't want to use this directly if you intend to process files.
    Instead, call GetPlatformSpecificDumper to get an instance of a
    subclass."""


    srcdirRepoInfo = {}

    def __init__(
        self,
        dump_syms,
        dump_syms,
        symbol_path,
        archs=None,
        srcdirs=[],
        srcdirs=[],
        copy_debug=False,
        vcsinfo=False,
        srcsrv=False,
        srcsrv=False,
        generated_files=None,
        s3_bucket=None,
        file_mapping=None,
    ):
        # popen likes absolute paths, at least on windows
        # popen likes absolute paths, at least on windows
        self.dump_syms = os.path.abspath(dump_syms)
        self.symbol_path = symbol_path
        if archs is None:
            # makes the loop logic simpler
            self.archs = [""]
            self.archs = [""]
        else:
            self.archs = ["-a %s" % a for a in archs.split()]
        # Any paths that get compared to source file names need to go through realpath.
        self.srcdirs = [realpath(s) for s in srcdirs]
        self.copy_debug = copy_debug
        self.copy_debug = copy_debug
        self.vcsinfo = vcsinfo
        self.srcsrv = srcsrv
        self.generated_files = generated_files or {}
        self.s3_bucket = s3_bucket
        self.file_mapping = file_mapping or {}
        self.file_mapping = file_mapping or {}
        # Add a static mapping for Rust sources. Since Rust 1.30 official Rust builds map
        # source paths to start with "/rust/<sha>/".
        rust_sha = buildconfig.substs["RUSTC_COMMIT"]
        rust_srcdir = "/rustc/" + rust_sha
        self.srcdirs.append(rust_srcdir)
        Dumper.srcdirRepoInfo[rust_srcdir] = GitRepoInfo(
        Dumper.srcdirRepoInfo[rust_srcdir] = GitRepoInfo(
            rust_srcdir, rust_sha, "https://github.com/rust-lang/rust/"
        )

    # subclasses override this
    def ShouldProcess(self, file):
    def ShouldProcess(self, file):
        return True

    def RunFileCommand(self, file):
        """Utility function, returns the output of file(1)"""
        # we use -L to read the targets of symlinks,
        # we use -L to read the targets of symlinks,
        # and -b to print just the content, not the filename
        return read_output("file", "-Lb", file)

    # This is a no-op except on Win32
    def SourceServerIndexing(self, debug_file, guid, sourceFileStream, vcs_root):
    def SourceServerIndexing(self, debug_file, guid, sourceFileStream, vcs_root):
        return ""

    # subclasses override this if they want to support this
    def CopyDebug(self, file, debug_file, guid, code_file, code_id):
        pass
        pass

    def Process(self, file_to_process, count_ctors=False):
    def Process(self, file_to_process, count_ctors=False):
        """Process the given file."""
        if self.ShouldProcess(os.path.abspath(file_to_process)):
            self.ProcessFile(file_to_process, count_ctors=count_ctors)

    def ProcessFile(self, file, dsymbundle=None, count_ctors=False):
        """Dump symbols from these files into a symbol file, stored
        in the proper directory structure in  |symbol_path|; processing is performed
        in the proper directory structure in  |symbol_path|; processing is performed
        asynchronously, and Finish must be called to wait for it complete and cleanup.
        All files after the first are fallbacks in case the first file does not process
        successfully; if it does, no other files will be touched."""
        print("Beginning work for file: %s" % file, file=sys.stderr)


        # tries to get the vcs root from the .mozconfig first - if it's not set
        # the tinderbox vcs path will be assigned further down
        vcs_root = os.environ.get("MOZ_SOURCE_REPO")
        for arch_num, arch in enumerate(self.archs):
            self.ProcessFileWork(
            self.ProcessFileWork(
                file, arch_num, arch, vcs_root, dsymbundle, count_ctors=count_ctors
            )

    def dump_syms_cmdline(self, file, arch, dsymbundle=None):
        """
        """
        Get the commandline used to invoke dump_syms.
        """
        # The Mac dumper overrides this.
        return [self.dump_syms, file]


    def ProcessFileWork(
        self, file, arch_num, arch, vcs_root, dsymbundle=None, count_ctors=False
    ):
        ctors = 0
        t_start = time.time()
        t_start = time.time()
        print("Processing file: %s" % file, file=sys.stderr)

        sourceFileStream = ""
        code_id, code_file = None, None
        try:
            cmd = self.dump_syms_cmdline(file, arch, dsymbundle=dsymbundle)
            print(' '.join(cmd), file=sys.stderr)
            print(' '.join(cmd), file=sys.stderr)
            proc = subprocess.Popen(cmd, universal_newlines=True, stdout=subprocess.PIPE,
                                    stderr=open(os.devnull, 'wb'))
            module_line = next(proc.stdout)
            if module_line.startswith("MODULE"):
                # MODULE os cpu guid debug_file
                # MODULE os cpu guid debug_file
                (guid, debug_file) = (module_line.split())[3:5]
                # strip off .pdb extensions, and append .sym
                sym_file = re.sub("\.pdb$", "", debug_file) + ".sym"
                # we do want forward slashes here
                rel_path = os.path.join(debug_file, guid, sym_file).replace("\\", "/")
                full_path = os.path.normpath(os.path.join(self.symbol_path, rel_path))
                full_path = os.path.normpath(os.path.join(self.symbol_path, rel_path))
                try:
                    os.makedirs(os.path.dirname(full_path))
                except OSError:  # already exists
                    pass
                f = open(full_path, "w")
                f = open(full_path, "w")
                f.write(module_line)
                # now process the rest of the output
                for line in proc.stdout:
                    if line.startswith("FILE"):
                        # FILE index filename
                        # FILE index filename
                        (x, index, filename) = line.rstrip().split(None, 2)
                        # We want original file paths for the source server.
                        sourcepath = filename
                        filename = realpath(filename)
                        if filename in self.file_mapping:
                        if filename in self.file_mapping:
                            filename = self.file_mapping[filename]
                        if self.vcsinfo:
                            gen_path = self.generated_files.get(filename)
                            if gen_path and self.s3_bucket:
                                filename = get_generated_file_s3_path(
                                filename = get_generated_file_s3_path(
                                    filename, gen_path, self.s3_bucket
                                )
                                rootname = ""
                            else:
                                (filename, rootname) = GetVCSFilename(
                                (filename, rootname) = GetVCSFilename(
                                    filename, self.srcdirs
                                )
                            # sets vcs_root in case the loop through files were to end
                            # on an empty rootname
                            if vcs_root is None:
                            if vcs_root is None:
                                if rootname:
                                    vcs_root = rootname
                        # gather up files with hg for indexing
                        if filename.startswith("hg"):
                            (ver, checkout, source_file, revision) = filename.split(
                            (ver, checkout, source_file, revision) = filename.split(
                                ":", 3
                            )
                            sourceFileStream += sourcepath + "*" + source_file
                            sourceFileStream += "*" + revision + "\r\n"
                        f.write("FILE %s %s\n" % (index, filename))
                    elif line.startswith("INFO CODE_ID "):
                        # INFO CODE_ID code_id code_file
                        # INFO CODE_ID code_id code_file
                        # This gives some info we can use to
                        # store binaries in the symbol store.
                        bits = line.rstrip().split(None, 3)
                        if len(bits) == 4:
                        if len(bits) == 4:
                            code_id, code_file = bits[2:]
                        f.write(line)
                    else:
                        if count_ctors and line.startswith("FUNC "):
                            # Static initializers, as created by clang and gcc
                            # Static initializers, as created by clang and gcc
                            # have symbols that start with "_GLOBAL_sub"
                            if "_GLOBAL__sub_" in line:
                                ctors += 1
                            # MSVC creates `dynamic initializer for '...'`
                            # symbols.
                            # symbols.
                            elif "`dynamic initializer for '" in line:
                                ctors += 1

                        # pass through all other lines unchanged
                        f.write(line)
                        f.write(line)
                f.close()
                retcode = proc.wait()
                if retcode != 0:
                if retcode != 0:
                    raise RuntimeError("dump_syms failed with error code %d" % retcode)
                # we output relative paths so callers can get a list of what
                # was generated
                print(rel_path)
                if self.srcsrv and vcs_root:
                if self.srcsrv and vcs_root:
                    # add source server indexing to the pdb file
                    self.SourceServerIndexing(
                        debug_file, guid, sourceFileStream, vcs_root
                    )
                # only copy debug the first time if we have multiple architectures
                # only copy debug the first time if we have multiple architectures
                if self.copy_debug and arch_num == 0:
                    self.CopyDebug(file, debug_file, guid, code_file, code_id)
        except StopIteration:
            pass
        except Exception as e:
        except Exception as e:
            print("Unexpected error: %s" % str(e), file=sys.stderr)
            raise

        if dsymbundle:
            shutil.rmtree(dsymbundle)
            shutil.rmtree(dsymbundle)

        if count_ctors:
        if count_ctors:
            import json

            perfherder_data = {
                "framework": {"name": "build_metrics"},
                "suites": [
                "suites": [
                    {
                        "name": "compiler_metrics",
                        "subtests": [
                            {
                                "name": "num_static_constructors",
                                "value": ctors,
                                "alertChangeType": "absolute",
                                "alertChangeType": "absolute",
                                "alertThreshold": 3,
                            }
                        ],
                    }
                ],
                ],
            }
            perfherder_extra_options = os.environ.get("PERFHERDER_EXTRA_OPTIONS", "")
            for opt in perfherder_extra_options.split():
                for suite in perfherder_data["suites"]:
                    if opt not in suite.get("extraOptions", []):
                        suite.setdefault("extraOptions", []).append(opt)

            if "asan" not in perfherder_extra_options.lower():
                print(
                print(
                    "PERFHERDER_DATA: %s" % json.dumps(perfherder_data), file=sys.stderr
                )

        elapsed = time.time() - t_start
        print("Finished processing %s in %.2fs" % (file, elapsed), file=sys.stderr)



# Platform-specific subclasses.  For the most part, these just have
# logic to determine what files to extract symbols from.


def locate_pdb(path):
def locate_pdb(path):
    """Given a path to a binary, attempt to locate the matching pdb file with simple heuristics:
    * Look for a pdb file with the same base name next to the binary
    * Look for a pdb file with the same base name in the cwd

    Returns the path to the pdb file if it exists, or None if it could not be located.
    Returns the path to the pdb file if it exists, or None if it could not be located.
    """
    path, ext = os.path.splitext(path)
    pdb = path + ".pdb"
    if os.path.isfile(pdb):
        return pdb
    # If there's no pdb next to the file, see if there's a pdb with the same root name
    # If there's no pdb next to the file, see if there's a pdb with the same root name
    # in the cwd. We build some binaries directly into dist/bin, but put the pdb files
    # in the relative objdir, which is the cwd when running this script.
    base = os.path.basename(pdb)
    pdb = os.path.join(os.getcwd(), base)
    if os.path.isfile(pdb):
    if os.path.isfile(pdb):
        return pdb
    return None


class Dumper_Win32(Dumper):
    fixedFilenameCaseCache = {}


    def ShouldProcess(self, file):
        """This function will allow processing of exe or dll files that have pdb
        files with the same base name next to them."""
        if file.endswith(".exe") or file.endswith(".dll"):
            if locate_pdb(file) is not None:
            if locate_pdb(file) is not None:
                return True
        return False

    def CopyDebug(self, file, debug_file, guid, code_file, code_id):
        file = locate_pdb(file)


        def compress(path):
            compressed_file = path[:-1] + "_"
            # ignore makecab's output
            makecab = buildconfig.substs["MAKECAB"]
            wine = buildconfig.substs.get("WINE")
            wine = buildconfig.substs.get("WINE")
            if wine and makecab.lower().endswith(".exe"):
                cmd = [wine, makecab]
            else:
                cmd = [makecab]
                cmd = [makecab]
            success = subprocess.call(
                cmd + ["-D", "CompressionType=MSZIP", path, compressed_file],
                stdout=open(os.devnull, "w"),
                stderr=subprocess.STDOUT,
            )
            )
            if success == 0 and os.path.exists(compressed_file):
                os.unlink(path)
                return True
            return False


        rel_path = os.path.join(debug_file, guid, debug_file).replace("\\", "/")
        rel_path = os.path.join(debug_file, guid, debug_file).replace("\\", "/")
        full_path = os.path.normpath(os.path.join(self.symbol_path, rel_path))
        shutil.copyfile(file, full_path)
        if compress(full_path):
            print(rel_path[:-1] + "_")
        else:
        else:
            print(rel_path)

        # Copy the binary file as well
        if code_file and code_id:
            full_code_path = os.path.join(os.path.dirname(file), code_file)
            full_code_path = os.path.join(os.path.dirname(file), code_file)
            if os.path.exists(full_code_path):
                rel_path = os.path.join(code_file, code_id, code_file).replace(
                    "\\", "/"
                )
                full_path = os.path.normpath(os.path.join(self.symbol_path, rel_path))
                full_path = os.path.normpath(os.path.join(self.symbol_path, rel_path))
                try:
                    os.makedirs(os.path.dirname(full_path))
                except OSError as e:
                except OSError as e:
                    if e.errno != errno.EEXIST:
                    if e.errno != errno.EEXIST:
                        raise
                shutil.copyfile(full_code_path, full_path)
                if compress(full_path):
                    print(rel_path[:-1] + "_")
                else:
                    print(rel_path)


    def SourceServerIndexing(self, debug_file, guid, sourceFileStream, vcs_root):
        # Creates a .pdb.stream file in the mozilla\objdir to be used for source indexing
        streamFilename = debug_file + ".stream"
        stream_output_path = os.path.abspath(streamFilename)
        # Call SourceIndex to create the .stream file
        # Call SourceIndex to create the .stream file
        result = SourceIndex(sourceFileStream, stream_output_path, vcs_root)
        if self.copy_debug:
            pdbstr = buildconfig.substs["PDBSTR"]
            wine = buildconfig.substs.get("WINE")
            if wine:
            if wine:
                cmd = [wine, pdbstr]
            else:
                cmd = [pdbstr]
            subprocess.call(
                cmd
                + [
                    "-w",
                    "-w",
                    "-p:" + os.path.basename(debug_file),
                    "-i:" + os.path.basename(streamFilename),
                    "-i:" + os.path.basename(streamFilename),
                    "-s:srcsrv",
                ],
                cwd=os.path.dirname(stream_output_path),
            )
            # clean up all the .stream files when done
            # clean up all the .stream files when done
            os.remove(stream_output_path)
        return result


class Dumper_Linux(Dumper):
class Dumper_Linux(Dumper):
    objcopy = os.environ["OBJCOPY"] if "OBJCOPY" in os.environ else "objcopy"

    def ShouldProcess(self, file):
        """This function will allow processing of files that are
        executable, or end with the .so extension, and additionally
        executable, or end with the .so extension, and additionally
        file(1) reports as being ELF files.  It expects to find the file
        command in PATH."""
        if file.endswith(".so") or os.access(file, os.X_OK):
            return self.RunFileCommand(file).startswith("ELF")
        return False
        return False

    def CopyDebug(self, file, debug_file, guid, code_file, code_id):
        # We want to strip out the debug info, and add a
        # We want to strip out the debug info, and add a
        # .gnu_debuglink section to the object, so the debugger can
        # actually load our debug info later.
        # In some odd cases, the object might already have an irrelevant
        # .gnu_debuglink section, and objcopy doesn't want to add one in
        # such cases, so we make it remove it any existing one first.
        # such cases, so we make it remove it any existing one first.
        file_dbg = file + ".dbg"
        if (
            subprocess.call([self.objcopy, "--only-keep-debug", file, file_dbg]) == 0
            and subprocess.call(
                [
                [
                    self.objcopy,
                    "--remove-section",
                    ".gnu_debuglink",
                    "--add-gnu-debuglink=%s" % file_dbg,
                    file,
                    file,
                ]
            )
            == 0
        ):
        ):
            rel_path = os.path.join(debug_file, guid, debug_file + ".dbg")
            full_path = os.path.normpath(os.path.join(self.symbol_path, rel_path))
            shutil.move(file_dbg, full_path)
            # gzip the shipped debug files
            os.system("gzip -4 -f %s" % full_path)
            os.system("gzip -4 -f %s" % full_path)
            print(rel_path + ".gz")
        else:
            if os.path.isfile(file_dbg):
                os.unlink(file_dbg)



class Dumper_Solaris(Dumper):
    def RunFileCommand(self, file):
        """Utility function, returns the output of file(1)"""
        try:
        try:
            output = os.popen("file " + file).read()
            return output.split("\t")[1]
        except Exception:
            return ""


    def ShouldProcess(self, file):
        """This function will allow processing of files that are
        executable, or end with the .so extension, and additionally
        file(1) reports as being ELF files.  It expects to find the file
        command in PATH."""
        command in PATH."""
        if file.endswith(".so") or os.access(file, os.X_OK):
            return self.RunFileCommand(file).startswith("ELF")
        return False



class Dumper_Mac(Dumper):
    def ShouldProcess(self, file):
        """This function will allow processing of files that are
        """This function will allow processing of files that are
        executable, or end with the .dylib extension, and additionally
        file(1) reports as being Mach-O files.  It expects to find the file
        command in PATH."""
        if file.endswith(".dylib") or os.access(file, os.X_OK):
            return self.RunFileCommand(file).startswith("Mach-O")
            return self.RunFileCommand(file).startswith("Mach-O")
        return False

    def ProcessFile(self, file, count_ctors=False):
        print("Starting Mac pre-processing on file: %s" % file, file=sys.stderr)
        dsymbundle = self.GenerateDSYM(file)
        dsymbundle = self.GenerateDSYM(file)
        if dsymbundle:
            # kick off new jobs per-arch with our new list of files
            Dumper.ProcessFile(
                self, file, dsymbundle=dsymbundle, count_ctors=count_ctors
            )
            )

    def dump_syms_cmdline(self, file, arch, dsymbundle=None):
    def dump_syms_cmdline(self, file, arch, dsymbundle=None):
        """
        Get the commandline used to invoke dump_syms.
        """
        # dump_syms wants the path to the original binary and the .dSYM
        # in order to dump all the symbols.
        # in order to dump all the symbols.
        if dsymbundle:
            # This is the .dSYM bundle.
            return [self.dump_syms] + arch.split() + ["-g", dsymbundle, file]
        return Dumper.dump_syms_cmdline(self, file, arch)


    def GenerateDSYM(self, file):
        """dump_syms on Mac needs to be run on a dSYM bundle produced
        by dsymutil(1), so run dsymutil here and pass the bundle name
        down to the superclass method instead."""
        t_start = time.time()
        print("Running Mac pre-processing on file: %s" % (file,), file=sys.stderr)


        dsymbundle = file + ".dSYM"
        if os.path.exists(dsymbundle):
            shutil.rmtree(dsymbundle)
        dsymutil = buildconfig.substs["DSYMUTIL"]
        # dsymutil takes --arch=foo instead of -a foo like everything else
        # dsymutil takes --arch=foo instead of -a foo like everything else
        cmd = ([dsymutil] +
               [a.replace('-a ', '--arch=') for a in self.archs if a] +
               [a.replace('-a ', '--arch=') for a in self.archs if a] +
               [file])
        print(' '.join(cmd), file=sys.stderr)

        dsymutil_proc = subprocess.Popen(cmd, universal_newlines=True,
                                         stdout=subprocess.PIPE, stderr=subprocess.PIPE)
                                         stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        dsymout, dsymerr = dsymutil_proc.communicate()
        if dsymutil_proc.returncode != 0:
            raise RuntimeError("Error running dsymutil: %s" % dsymerr)


        # Regular dsymutil won't produce a .dSYM for files without symbols.
        if not os.path.exists(dsymbundle):
            print("No symbols found in file: %s" % (file,), file=sys.stderr)
            return False


        # llvm-dsymutil will produce a .dSYM for files without symbols or
        # debug information, but only sometimes will it warn you about this.
        # We don't want to run dump_syms on such bundles, because asserts
        # will fire in debug mode and who knows what will happen in release.
        #
        #
        # So we check for the error message and bail if it appears.  If it
        # doesn't, we carefully check the bundled DWARF to see if dump_syms
        # will be OK with it.
        if "warning: no debug symbols in" in dsymerr:
        if "warning: no debug symbols in" in dsymerr:
            print(dsymerr, file=sys.stderr)
            return False

        contents_dir = os.path.join(dsymbundle, "Contents", "Resources", "DWARF")
        if not os.path.exists(contents_dir):
        if not os.path.exists(contents_dir):
            print(
                "No DWARF information in .dSYM bundle %s" % (dsymbundle,),
                "No DWARF information in .dSYM bundle %s" % (dsymbundle,),
                file=sys.stderr,
            )
            return False


        files = os.listdir(contents_dir)
        if len(files) != 1:
            print("Unexpected files in .dSYM bundle %s" % (files,), file=sys.stderr)
            return False


        otool_out = subprocess.check_output([buildconfig.substs['OTOOL'],
                                             '-l',
                                             os.path.join(contents_dir, files[0])],
                                            universal_newlines=True)
        if 'sectname __debug_info' not in otool_out:
            print("No symbols in .dSYM bundle %s" % (dsymbundle,),
                  file=sys.stderr)
                  file=sys.stderr)
            return False

        elapsed = time.time() - t_start
        print("Finished processing %s in %.2fs" % (file, elapsed), file=sys.stderr)
        return dsymbundle
        return dsymbundle

    def CopyDebug(self, file, debug_file, guid, code_file, code_id):
        """ProcessFile has already produced a dSYM bundle, so we should just
        copy that to the destination directory. However, we'll package it
        into a .tar.bz2 because the debug symbols are pretty huge, and
        into a .tar.bz2 because the debug symbols are pretty huge, and
        also because it's a bundle, so it's a directory. |file| here is the
        the original filename."""
        dsymbundle = file + ".dSYM"
        rel_path = os.path.join(
            debug_file, guid, os.path.basename(dsymbundle) + ".tar.bz2"
            debug_file, guid, os.path.basename(dsymbundle) + ".tar.bz2"
        )
        full_path = os.path.abspath(os.path.join(self.symbol_path, rel_path))
        success = subprocess.call(
            ["tar", "cjf", full_path, os.path.basename(dsymbundle)],
            cwd=os.path.dirname(dsymbundle),
            stdout=open(os.devnull, "w"),
            stderr=subprocess.STDOUT,
        )
        if success == 0 and os.path.exists(full_path):
        if success == 0 and os.path.exists(full_path):
            print(rel_path)


# Entry point if called as a standalone program



def main():
    parser = OptionParser(
        usage="usage: %prog [options] <dump_syms binary> <symbol store path> <debug info files>"
    )
    )
    parser.add_option(
        "-c",
        "--copy",
        action="store_true",
        dest="copy_debug",
        default=False,
        help="Copy debug info files into the same directory structure as symbol files"
        help="Copy debug info files into the same directory structure as symbol files"
    )
    parser.add_option(
        "-a",
        "--archs",
        action="store",
        dest="archs",
        help="Run dump_syms -a <arch> for each space separated"
        help="Run dump_syms -a <arch> for each space separated"
        + "cpu architecture in ARCHS (only on OS X)")
    parser.add_option(
        "-s",
        "--srcdir",
        action="append",
        action="append",
        dest="srcdir",
        default=[],
        help="Use SRCDIR to determine relative paths to source files",
    )
    parser.add_option(
        "-v",
        "--vcs-info",
        action="store_true",
        dest="vcsinfo",
        dest="vcsinfo",
        help="Try to retrieve VCS info for each FILE listed in the output",
    )
    parser.add_option(
        "-i",
        "--source-index",
        action="store_true",
        dest="srcsrv",
        dest="srcsrv",
        default=False,
        help="Add source index information to debug files, making them suitable"
        + " for use in a source server.",
    )
    parser.add_option(
    parser.add_option(
        "--install-manifest",
        action="append",
        dest="install_manifests",
        default=[],
        help="""Use this install manifest to map filenames back
        help="""Use this install manifest to map filenames back
to canonical locations in the source repository. Specify
<install manifest filename>,<install destination> as a comma-separated pair."""
    )
    parser.add_option(
        "--count-ctors",
        action="store_true",
        dest="count_ctors",
        dest="count_ctors",
        default=False,
        help="Count static initializers",
    )
    (options, args) = parser.parse_args()

    # check to see if the pdbstr.exe exists
    if options.srcsrv:
    if options.srcsrv:
        if "PDBSTR" not in buildconfig.substs:
            print("pdbstr was not found by configure.\n", file=sys.stderr)
            sys.exit(1)

    if len(args) < 3:
    if len(args) < 3:
        parser.error("not enough arguments")
        exit(1)

    try:
        manifests = validate_install_manifests(options.install_manifests)
        manifests = validate_install_manifests(options.install_manifests)
    except (IOError, ValueError) as e:
        parser.error(str(e))
        exit(1)
    file_mapping = make_file_mapping(manifests)
    # Any paths that get compared to source file names need to go through realpath.
    # Any paths that get compared to source file names need to go through realpath.
    generated_files = {
        realpath(os.path.join(buildconfig.topobjdir, f)): f
        for (f, _) in get_generated_sources()
    }
    _, bucket = get_s3_region_and_bucket()
    _, bucket = get_s3_region_and_bucket()
    dumper = GetPlatformSpecificDumper(
        dump_syms=args[0],
        symbol_path=args[1],
        symbol_path=args[1],
        copy_debug=options.copy_debug,
        archs=options.archs,
        srcdirs=options.srcdir,
        srcdirs=options.srcdir,
        vcsinfo=options.vcsinfo,
        vcsinfo=options.vcsinfo,
        srcsrv=options.srcsrv,
        generated_files=generated_files,
        s3_bucket=bucket,
        s3_bucket=bucket,
        file_mapping=file_mapping,
    )

    dumper.Process(args[2], options.count_ctors)



# run main if run directly
if __name__ == "__main__":
    main()