in automation/symbols-generation/symbolstore.py [0:0]
def ProcessFileWork(self, file, arch_num, arch, vcs_root, dsymbundle=None):
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)
proc = subprocess.Popen(
cmd, stdout=subprocess.PIPE, stderr=open(os.devnull, "wb")
)
stdout = io.TextIOWrapper(proc.stdout, encoding="utf-8")
module_line = stdout.readline()
if module_line.startswith("MODULE"):
# 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(r"\.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))
try:
os.makedirs(os.path.dirname(full_path))
except OSError: # already exists
pass
f = open(full_path, "w")
f.write(module_line)
# now process the rest of the output
for line in stdout:
if line.startswith("FILE"):
# FILE index filename
(x, index, filename) = line.rstrip().split(None, 2)
# We want original file paths for the source server.
sourcepath = filename
filename = normpath(filename)
if filename in self.file_mapping:
filename = self.file_mapping[filename]
if self.vcsinfo:
(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 rootname:
vcs_root = rootname
# gather up files with git for indexing
if filename.startswith("git"):
(vcs, checkout, source_file, revision) = filename.split(
":", 3
)
# Contrary to HG we do not include the revision as it is part of the
# repo URL.
sourceFileStream += sourcepath + "*" + source_file + "\r\n"
f.write("FILE %s %s\n" % (index, filename))
elif line.startswith("INFO CODE_ID "):
# 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:
code_id, code_file = bits[2:]
f.write(line)
else:
# pass through all other lines unchanged
f.write(line)
f.close()
retcode = proc.wait()
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:
# 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
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:
print("Unexpected error: %s" % str(e), file=sys.stderr)
raise
if dsymbundle:
shutil.rmtree(dsymbundle)
elapsed = time.time() - t_start
print("Finished processing %s in %.2fs" % (file, elapsed), file=sys.stderr)