mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
Bug 1628927 - Convert symbolstore.py to python 3. r=rstewart
Differential Revision: https://phabricator.services.mozilla.com/D70467 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
8403480b31
commit
e62d5e9a93
@ -69,7 +69,7 @@ def dump_symbols(target, tracking_file, count_ctors=False):
|
||||
if objcopy:
|
||||
os.environ['OBJCOPY'] = objcopy
|
||||
|
||||
args = ([buildconfig.substs['PYTHON'],
|
||||
args = ([sys.executable,
|
||||
os.path.join(buildconfig.topsrcdir, 'toolkit',
|
||||
'crashreporter', 'tools', 'symbolstore.py')] +
|
||||
sym_store_args +
|
||||
|
@ -1,4 +1,4 @@
|
||||
[DEFAULT]
|
||||
skip-if = python == 3
|
||||
skip-if = python == 2
|
||||
|
||||
[unit-symbolstore.py]
|
||||
|
@ -21,8 +21,6 @@
|
||||
# -s <srcdir> : Use <srcdir> as the top source directory to
|
||||
# generate relative filenames.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import buildconfig
|
||||
import errno
|
||||
import sys
|
||||
@ -35,7 +33,6 @@ import fnmatch
|
||||
import subprocess
|
||||
import time
|
||||
import ctypes
|
||||
import urlparse
|
||||
import concurrent.futures
|
||||
import multiprocessing
|
||||
|
||||
@ -137,7 +134,8 @@ class VCSFileInfo:
|
||||
rootRegex = re.compile(r'^\S+?:/+(?:[^\s/]*@)?(\S+)$')
|
||||
|
||||
def read_output(*args):
|
||||
(stdout, _) = subprocess.Popen(args=args, stdout=subprocess.PIPE).communicate()
|
||||
(stdout, _) = subprocess.Popen(
|
||||
args=args, universal_newlines=True, stdout=subprocess.PIPE).communicate()
|
||||
return stdout.rstrip()
|
||||
|
||||
class HGRepoInfo:
|
||||
@ -266,8 +264,6 @@ if platform.system() == 'Windows':
|
||||
result = path
|
||||
|
||||
ctypes.windll.kernel32.SetErrorMode(ctypes.c_uint(1))
|
||||
if not isinstance(path, unicode):
|
||||
path = unicode(path, sys.getfilesystemencoding())
|
||||
handle = ctypes.windll.kernel32.CreateFileW(path,
|
||||
# GENERIC_READ
|
||||
0x80000000,
|
||||
@ -358,7 +354,7 @@ def validate_install_manifests(install_manifest_args):
|
||||
if len(bits) != 2:
|
||||
raise ValueError('Invalid format for --install-manifest: '
|
||||
'specify manifest,target_dir')
|
||||
manifest_file, destination = map(os.path.abspath, bits)
|
||||
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)
|
||||
@ -524,9 +520,9 @@ class Dumper:
|
||||
try:
|
||||
cmd = self.dump_syms_cmdline(file, arch, dsymbundle=dsymbundle)
|
||||
print(' '.join(cmd), file=sys.stderr)
|
||||
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
|
||||
proc = subprocess.Popen(cmd, universal_newlines=True, stdout=subprocess.PIPE,
|
||||
stderr=open(os.devnull, 'wb'))
|
||||
module_line = proc.stdout.next()
|
||||
module_line = next(proc.stdout)
|
||||
if module_line.startswith("MODULE"):
|
||||
# MODULE os cpu guid debug_file
|
||||
(guid, debug_file) = (module_line.split())[3:5]
|
||||
@ -852,8 +848,8 @@ class Dumper_Mac(Dumper):
|
||||
[file])
|
||||
print(' '.join(cmd), file=sys.stderr)
|
||||
|
||||
dsymutil_proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE)
|
||||
dsymutil_proc = subprocess.Popen(cmd, universal_newlines=True,
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
dsymout, dsymerr = dsymutil_proc.communicate()
|
||||
if dsymutil_proc.returncode != 0:
|
||||
raise RuntimeError('Error running dsymutil: %s' % dsymerr)
|
||||
@ -889,7 +885,8 @@ class Dumper_Mac(Dumper):
|
||||
|
||||
otool_out = subprocess.check_output([buildconfig.substs['OTOOL'],
|
||||
'-l',
|
||||
os.path.join(contents_dir, files[0])])
|
||||
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)
|
||||
|
@ -116,7 +116,7 @@ class TestCopyDebug(HelperMixin, unittest.TestCase):
|
||||
def next_popen(*args, **kwargs):
|
||||
m = mock.MagicMock()
|
||||
# Get the iterators over whatever output was provided.
|
||||
stdout_ = stdout_iter.next()
|
||||
stdout_ = next(stdout_iter)
|
||||
# Eager evaluation for communicate(), below.
|
||||
stdout_ = list(stdout_)
|
||||
# stdout is really an iterator, so back to iterators we go.
|
||||
@ -362,7 +362,7 @@ class TestInstallManifest(HelperMixin, unittest.TestCase):
|
||||
self.assertEqual(dest, self.objdir)
|
||||
|
||||
file_mapping = symbolstore.make_file_mapping(ret)
|
||||
for obj, src in self.canonical_mapping.iteritems():
|
||||
for obj, src in self.canonical_mapping.items():
|
||||
self.assertTrue(obj in file_mapping)
|
||||
self.assertEqual(file_mapping[obj], src)
|
||||
|
||||
@ -387,7 +387,7 @@ class TestInstallManifest(HelperMixin, unittest.TestCase):
|
||||
Test that a bad manifest file give errors.
|
||||
'''
|
||||
bad_manifest = os.path.join(self.test_dir, 'bad-manifest')
|
||||
with open(bad_manifest, 'wb') as f:
|
||||
with open(bad_manifest, 'w') as f:
|
||||
f.write('junk\n')
|
||||
arg = '%s,%s' % (bad_manifest, self.objdir)
|
||||
with self.assertRaises(IOError) as e:
|
||||
@ -450,7 +450,7 @@ class TestFileMapping(HelperMixin, unittest.TestCase):
|
||||
d = symbolstore.Dumper('dump_syms', self.symboldir,
|
||||
file_mapping=file_mapping)
|
||||
f = os.path.join(self.objdir, 'somefile')
|
||||
open(f, 'wb').write('blah')
|
||||
open(f, 'w').write('blah')
|
||||
d.Process(f)
|
||||
expected_output = ''.join(mk_output(expected_files))
|
||||
symbol_file = os.path.join(self.symboldir,
|
||||
@ -514,9 +514,10 @@ class TestFunctional(HelperMixin, unittest.TestCase):
|
||||
self.dump_syms,
|
||||
self.test_dir,
|
||||
self.target_bin],
|
||||
universal_newlines=True,
|
||||
stderr=None,
|
||||
cwd=browser_app)
|
||||
lines = filter(lambda x: x.strip(), output.splitlines())
|
||||
lines = [l for l in output.splitlines() if l.strip()]
|
||||
self.assertEqual(1, len(lines),
|
||||
'should have one filename in the output; got %s' % repr(output))
|
||||
symbol_file = os.path.join(self.test_dir, lines[0])
|
||||
|
Loading…
Reference in New Issue
Block a user