Bug 1578531 - be even more careful about success when running dsymutil; r=nalexander

Even if we don't see error messages from `llvm-dsymutil`, we can still
generate dSYM bundles that `dump_syms` completely falls over on.  Let's
implement a super-careful check that actually examines the debug
information produced to ensure that `dump_syms` will accept our bundle.

Differential Revision: https://phabricator.services.mozilla.com/D44529

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nathan Froyd 2019-09-03 20:46:43 +00:00
Родитель 0b27e4437e
Коммит ab3b2432a1
1 изменённых файлов: 28 добавлений и 5 удалений

Просмотреть файл

@ -856,15 +856,38 @@ class Dumper_Mac(Dumper):
print("No symbols found in file: %s" % (file,), file=sys.stderr)
return False
# llvm-dsymutil will produce a .dSYM for files without debug
# symbols, but only warns you in the output and doesn't actually
# fail. 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.
# 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:
print(dsymerr, file=sys.stderr)
return False
contents_dir = os.path.join(dsymbundle, 'Contents', 'Resources', 'DWARF')
if not os.path.exists(contents_dir):
print("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])])
if 'sectname __debug_info' not in otool_out:
print("No symbols in .dSYM bundle %s" % (dsymbundle,),
file=sys.stderr)
return False
elapsed = time.time() - t_start
print('Finished processing %s in %.2fs' % (file, elapsed),
file=sys.stderr)