зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1196430 - part 6 - move cut-and-paste stack fixer code into mozrunner; r=wlach
This code is cut-and-pasted in several different places around the tree. Let's put it in a common place.
This commit is contained in:
Родитель
3953358c0b
Коммит
956d3c942b
|
@ -29,7 +29,7 @@ import mozleak
|
|||
import mozprocess
|
||||
import mozprofile
|
||||
import mozrunner
|
||||
from mozrunner.utils import test_environment
|
||||
from mozrunner.utils import get_stack_fixer_function, test_environment
|
||||
from mozscreenshot import printstatus, dump_screen
|
||||
|
||||
here = os.path.abspath(os.path.dirname(__file__))
|
||||
|
@ -503,48 +503,9 @@ class RefTest(object):
|
|||
|
||||
def stack_fixer(self):
|
||||
"""
|
||||
return stackFixerFunction, if any, to use on the output lines
|
||||
return get_stack_fixer_function, if any, to use on the output lines
|
||||
"""
|
||||
|
||||
if not mozinfo.info.get('debug'):
|
||||
return None
|
||||
|
||||
stack_fixer_function = None
|
||||
|
||||
def import_stack_fixer_module(module_name):
|
||||
sys.path.insert(0, self.utilityPath)
|
||||
module = __import__(module_name, globals(), locals(), [])
|
||||
sys.path.pop(0)
|
||||
return module
|
||||
|
||||
if self.symbolsPath and os.path.exists(self.symbolsPath):
|
||||
# Run each line through a function in fix_stack_using_bpsyms.py (uses breakpad symbol files).
|
||||
# This method is preferred for Tinderbox builds, since native
|
||||
# symbols may have been stripped.
|
||||
stack_fixer_module = import_stack_fixer_module(
|
||||
'fix_stack_using_bpsyms')
|
||||
stack_fixer_function = lambda line: stack_fixer_module.fixSymbols(
|
||||
line, self.symbolsPath)
|
||||
|
||||
elif mozinfo.isMac:
|
||||
# Run each line through fix_macosx_stack.py (uses atos).
|
||||
# This method is preferred for developer machines, so we don't
|
||||
# have to run "make buildsymbols".
|
||||
stack_fixer_module = import_stack_fixer_module(
|
||||
'fix_macosx_stack')
|
||||
stack_fixer_function = lambda line: stack_fixer_module.fixSymbols(
|
||||
line)
|
||||
|
||||
elif mozinfo.isLinux:
|
||||
# Run each line through fix_linux_stack.py (uses addr2line).
|
||||
# This method is preferred for developer machines, so we don't
|
||||
# have to run "make buildsymbols".
|
||||
stack_fixer_module = import_stack_fixer_module(
|
||||
'fix_linux_stack')
|
||||
stack_fixer_function = lambda line: stack_fixer_module.fixSymbols(
|
||||
line)
|
||||
|
||||
return stack_fixer_function
|
||||
return get_stack_fixer_function(self.utilityPath, self.symbolsPath)
|
||||
|
||||
# output line handlers:
|
||||
# these take a line and return a line
|
||||
|
|
|
@ -51,7 +51,7 @@ from mozprofile.permissions import ServerLocations
|
|||
from urllib import quote_plus as encodeURIComponent
|
||||
from mozlog.formatters import TbplFormatter
|
||||
from mozlog import commandline
|
||||
from mozrunner.utils import test_environment
|
||||
from mozrunner.utils import get_stack_fixer_function, test_environment
|
||||
from mozscreenshot import dump_screen
|
||||
import mozleak
|
||||
|
||||
|
@ -2357,47 +2357,9 @@ class Mochitest(MochitestUtilsMixin):
|
|||
|
||||
def stackFixer(self):
|
||||
"""
|
||||
return stackFixerFunction, if any, to use on the output lines
|
||||
return get_stack_fixer_function, if any, to use on the output lines
|
||||
"""
|
||||
|
||||
if not mozinfo.info.get('debug'):
|
||||
return None
|
||||
|
||||
stackFixerFunction = None
|
||||
|
||||
def import_stackFixerModule(module_name):
|
||||
sys.path.insert(0, self.utilityPath)
|
||||
module = __import__(module_name, globals(), locals(), [])
|
||||
sys.path.pop(0)
|
||||
return module
|
||||
|
||||
if self.symbolsPath and os.path.exists(self.symbolsPath):
|
||||
# Run each line through a function in fix_stack_using_bpsyms.py (uses breakpad symbol files).
|
||||
# This method is preferred for Tinderbox builds, since native
|
||||
# symbols may have been stripped.
|
||||
stackFixerModule = import_stackFixerModule(
|
||||
'fix_stack_using_bpsyms')
|
||||
stackFixerFunction = lambda line: stackFixerModule.fixSymbols(
|
||||
line,
|
||||
self.symbolsPath)
|
||||
|
||||
elif mozinfo.isMac:
|
||||
# Run each line through fix_macosx_stack.py (uses atos).
|
||||
# This method is preferred for developer machines, so we don't
|
||||
# have to run "make buildsymbols".
|
||||
stackFixerModule = import_stackFixerModule('fix_macosx_stack')
|
||||
stackFixerFunction = lambda line: stackFixerModule.fixSymbols(
|
||||
line)
|
||||
|
||||
elif mozinfo.isLinux:
|
||||
# Run each line through fix_linux_stack.py (uses addr2line).
|
||||
# This method is preferred for developer machines, so we don't
|
||||
# have to run "make buildsymbols".
|
||||
stackFixerModule = import_stackFixerModule('fix_linux_stack')
|
||||
stackFixerFunction = lambda line: stackFixerModule.fixSymbols(
|
||||
line)
|
||||
|
||||
return stackFixerFunction
|
||||
return get_stack_fixer_function(self.utilityPath, self.symbolsPath)
|
||||
|
||||
def finish(self):
|
||||
if self.shutdownLeaks:
|
||||
|
|
|
@ -243,3 +243,53 @@ def test_environment(xrePath, env=None, crashreporter=True, debugger=False,
|
|||
" symbolizer at %s" % llvmsym)
|
||||
|
||||
return env
|
||||
|
||||
|
||||
def get_stack_fixer_function(utilityPath, symbolsPath):
|
||||
"""
|
||||
Return a stack fixing function, if possible, to use on output lines.
|
||||
|
||||
A stack fixing function checks if a line conforms to the output from
|
||||
MozFormatCodeAddressDetails. If the line does not, the line is returned
|
||||
unchanged. If the line does, an attempt is made to convert the
|
||||
file+offset into something human-readable (e.g. a function name).
|
||||
"""
|
||||
if not mozinfo.info.get('debug'):
|
||||
return None
|
||||
|
||||
stack_fixer_function = None
|
||||
|
||||
def import_stack_fixer_module(module_name):
|
||||
sys.path.insert(0, utilityPath)
|
||||
module = __import__(module_name, globals(), locals(), [])
|
||||
sys.path.pop(0)
|
||||
return module
|
||||
|
||||
if symbolsPath and os.path.exists(symbolsPath):
|
||||
# Run each line through a function in fix_stack_using_bpsyms.py (uses breakpad symbol files).
|
||||
# This method is preferred for Tinderbox builds, since native
|
||||
# symbols may have been stripped.
|
||||
stack_fixer_module = import_stack_fixer_module(
|
||||
'fix_stack_using_bpsyms')
|
||||
stack_fixer_function = lambda line: stack_fixer_module.fixSymbols(
|
||||
line, symbolsPath)
|
||||
|
||||
elif mozinfo.isMac:
|
||||
# Run each line through fix_macosx_stack.py (uses atos).
|
||||
# This method is preferred for developer machines, so we don't
|
||||
# have to run "make buildsymbols".
|
||||
stack_fixer_module = import_stack_fixer_module(
|
||||
'fix_macosx_stack')
|
||||
stack_fixer_function = lambda line: stack_fixer_module.fixSymbols(
|
||||
line)
|
||||
|
||||
elif mozinfo.isLinux:
|
||||
# Run each line through fix_linux_stack.py (uses addr2line).
|
||||
# This method is preferred for developer machines, so we don't
|
||||
# have to run "make buildsymbols".
|
||||
stack_fixer_module = import_stack_fixer_module(
|
||||
'fix_linux_stack')
|
||||
stack_fixer_function = lambda line: stack_fixer_module.fixSymbols(
|
||||
line)
|
||||
|
||||
return stack_fixer_function
|
||||
|
|
|
@ -66,6 +66,7 @@ from manifestparser.filters import chunk_by_slice, tags
|
|||
from mozlog import commandline
|
||||
import mozcrash
|
||||
import mozinfo
|
||||
from mozrunner.utils import get_stack_fixer_function
|
||||
|
||||
# --------------------------------------------------------------
|
||||
|
||||
|
@ -91,39 +92,6 @@ def cleanup_encoding(s):
|
|||
# Replace all C0 and C1 control characters with \xNN escapes.
|
||||
return _cleanup_encoding_re.sub(_cleanup_encoding_repl, s)
|
||||
|
||||
def find_stack_fixer(mozinfo, utility_dir, symbols_path):
|
||||
# This is mostly taken from the equivalent in runreftest.py, itself similar
|
||||
# to the mochitest version. It's not a huge amount of code, but deduping it
|
||||
# might be nice. This version is indepenent of an enclosing harness class,
|
||||
# so should easily be movable to a shared location.
|
||||
if not mozinfo.info.get('debug'):
|
||||
return None
|
||||
|
||||
def import_stack_fixer_module(module_name):
|
||||
sys.path.insert(0, utility_dir)
|
||||
module = importlib.import_module(module_name)
|
||||
sys.path.pop(0)
|
||||
return module
|
||||
|
||||
stack_fixer_function = None
|
||||
|
||||
if symbols_path and os.path.exists(symbols_path):
|
||||
# Run each line through a function in fix_stack_using_bpsyms.py (uses breakpad symbol files).
|
||||
# This method is preferred for Tinderbox builds, since native symbols may have been stripped.
|
||||
stack_fixer_module = import_stack_fixer_module('fix_stack_using_bpsyms')
|
||||
stack_fixer_function = lambda line: stack_fixer_module.fixSymbols(line, symbols_path)
|
||||
elif mozinfo.isMac:
|
||||
# Run each line through fix_macosx_stack.py (uses atos).
|
||||
# This method is preferred for developer machines, so we don't have to run "make buildsymbols".
|
||||
stack_fixer_module = import_stack_fixer_module('fix_macosx_stack')
|
||||
stack_fixer_function = stack_fixer_module.fixSymbols
|
||||
elif mozinfo.isLinux:
|
||||
stack_fixer_module = import_stack_fixer_module('fix_linux_stack')
|
||||
stack_fixer_function = stack_fixer_module.fixSymbols
|
||||
|
||||
return stack_fixer_function
|
||||
|
||||
|
||||
""" Control-C handling """
|
||||
gotSIGINT = False
|
||||
def markGotSIGINT(signum, stackFrame):
|
||||
|
@ -1219,9 +1187,7 @@ class XPCShellTests(object):
|
|||
|
||||
self.stack_fixer_function = None
|
||||
if utility_path and os.path.exists(utility_path):
|
||||
self.stack_fixer_function = find_stack_fixer(mozinfo,
|
||||
utility_path,
|
||||
self.symbolsPath)
|
||||
self.stack_fixer_function = get_stack_fixer_function(utility_path, self.symbolsPath)
|
||||
|
||||
# buildEnvironment() needs mozInfo, so we call it after mozInfo is initialized.
|
||||
self.buildEnvironment()
|
||||
|
|
Загрузка…
Ссылка в новой задаче