Add "-gmodules" support to the test suite.
This change adds the capability of building test inferiors with the -gmodules flag to enable module debug info support. Windows is excluded per @zturner. Reviewers: granata.enrico, aprantl, zturner, labath Subscribers: zturner, labath, lldb-commits Differential Revision: http://reviews.llvm.org/D19998 git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@270848 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
435ed8c9fa
Коммит
422b4e70ea
|
@ -0,0 +1,30 @@
|
|||
from __future__ import absolute_import
|
||||
from __future__ import print_function
|
||||
|
||||
# System modules
|
||||
import os
|
||||
import re
|
||||
|
||||
|
||||
GMODULES_SUPPORT_MAP = {}
|
||||
GMODULES_HELP_REGEX = re.compile(r"\s-gmodules\s")
|
||||
|
||||
|
||||
def is_compiler_clang_with_gmodules(compiler_path):
|
||||
# Before computing the result, check if we already have it cached.
|
||||
if compiler_path in GMODULES_SUPPORT_MAP:
|
||||
return GMODULES_SUPPORT_MAP[compiler_path]
|
||||
|
||||
def _gmodules_supported_internal():
|
||||
compiler = os.path.basename(compiler_path)
|
||||
if "clang" not in compiler:
|
||||
return False
|
||||
else:
|
||||
# Check the compiler help for the -gmodules option.
|
||||
clang_help = os.popen("%s --help" % compiler_path).read()
|
||||
return GMODULES_HELP_REGEX.search(clang_help, re.DOTALL) is not None
|
||||
|
||||
GMODULES_SUPPORT_MAP[compiler_path] = _gmodules_supported_internal()
|
||||
return GMODULES_SUPPORT_MAP[compiler_path]
|
||||
|
||||
|
|
@ -522,15 +522,3 @@ def skipUnlessThreadSanitizer(func):
|
|||
return "Compiler cannot compile with -fsanitize=thread"
|
||||
return None
|
||||
return skipTestIfFn(is_compiler_clang_with_thread_sanitizer)(func)
|
||||
|
||||
def skipUnlessClangModules():
|
||||
"""Decorate the item to skip test unless Clang -gmodules flag is supported."""
|
||||
def is_compiler_clang_with_gmodules(self):
|
||||
compiler_path = self.getCompiler()
|
||||
compiler = os.path.basename(compiler_path)
|
||||
if compiler != "clang":
|
||||
return "Test requires clang as compiler"
|
||||
clang_help = os.popen("%s --help" % (compiler_path)).read()
|
||||
match = re.match(".* -gmodules ", clang_help, re.DOTALL)
|
||||
return "Clang version doesn't support -gmodules flag" if not match else None
|
||||
return skipTestIfFn(is_compiler_clang_with_gmodules)
|
||||
|
|
|
@ -52,6 +52,7 @@ class TopLevelExpressionsTestCase(TestBase):
|
|||
@add_test_categories(['pyapi'])
|
||||
@expectedFailureAndroid(api_levels=[21, 22], bugnumber="llvm.org/pr27787")
|
||||
@expectedFailureAll(oslist=["linux"], archs=["arm", "aarch64"], bugnumber="llvm.org/pr27787")
|
||||
@expectedFailureAll(oslist=["macosx"], debug_info="gmodules", bugnumber="llvm.org/pr27864")
|
||||
@skipIf(oslist=["windows"]) # Error in record layout on Windows
|
||||
def test_top_level_expressions(self):
|
||||
self.build_and_run()
|
||||
|
|
|
@ -18,6 +18,7 @@ class DeadStripTestCase(TestBase):
|
|||
|
||||
@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778")
|
||||
@expectedFailureAll(debug_info="dwo", bugnumber="llvm.org/pr25087")
|
||||
@expectedFailureAll(oslist=["linux"], debug_info="gmodules", bugnumber="llvm.org/pr27865")
|
||||
@skipIfFreeBSD # The -dead_strip linker option isn't supported on FreeBSD versions of ld.
|
||||
def test(self):
|
||||
"""Test breakpoint works correctly with dead-code stripping."""
|
||||
|
|
|
@ -20,7 +20,7 @@ class GlobalVariablesTestCase(TestBase):
|
|||
self.shlib_names = ["a"]
|
||||
|
||||
@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")
|
||||
@expectedFailureAll("llvm.org/pr25872", oslist=["macosx"], debug_info="dwarf")
|
||||
@expectedFailureAll("llvm.org/pr25872", oslist=["macosx"], debug_info=["dwarf", "gmodules"])
|
||||
def test_c_global_variables(self):
|
||||
"""Test 'frame variable --scope --no-args' which omits args and shows scopes."""
|
||||
self.build()
|
||||
|
|
|
@ -7,15 +7,9 @@ class TestWithGmodulesDebugInfo(TestBase):
|
|||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
|
||||
@add_test_categories(["gmodules"])
|
||||
@expectedFailureAll(bugnumber="llvm.org/pr27412")
|
||||
@skipUnlessClangModules()
|
||||
def test_specialized_typedef_from_pch(self):
|
||||
clang_help = os.popen("clang --help").read()
|
||||
match = re.match(".* -gmodules ", clang_help, re.DOTALL)
|
||||
if not match:
|
||||
self.skipTest("Clang version doesn't support -gmodules flag")
|
||||
return
|
||||
|
||||
self.build()
|
||||
cwd = os.getcwd()
|
||||
|
||||
|
|
|
@ -90,6 +90,7 @@ class FoundationTestCase2(TestBase):
|
|||
patterns = ["\(int\) \$.* = 3"])
|
||||
self.runCmd("process continue")
|
||||
|
||||
@expectedFailureAll(oslist=["macosx"], debug_info="gmodules", bugnumber="llvm.org/pr27861")
|
||||
def test_NSString_expr_commands(self):
|
||||
"""Test expression commands for NSString."""
|
||||
self.build()
|
||||
|
|
|
@ -17,6 +17,7 @@ class RuntimeTypesTestCase(TestBase):
|
|||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
|
||||
@expectedFailureAll(oslist=["macosx"], debug_info="gmodules", bugnumber="llvm.org/pr27862")
|
||||
def test_break(self):
|
||||
"""Test setting objc breakpoints using '_regexp-break' and 'breakpoint set'."""
|
||||
if self.getArchitecture() != 'x86_64':
|
||||
|
|
|
@ -9,6 +9,7 @@ import os
|
|||
# LLDB modules
|
||||
import lldb
|
||||
from .lldbtest import *
|
||||
from . import configuration
|
||||
from . import lldbutil
|
||||
from .decorators import *
|
||||
|
||||
|
@ -141,6 +142,12 @@ class InlineTest(TestBase):
|
|||
self.buildDwo()
|
||||
self.do_test()
|
||||
|
||||
def __test_with_gmodules(self):
|
||||
self.using_dsym = False
|
||||
self.BuildMakefile()
|
||||
self.buildGModules()
|
||||
self.do_test()
|
||||
|
||||
def execute_user_command(self, __command):
|
||||
exec(__command, globals(), locals())
|
||||
|
||||
|
@ -205,12 +212,14 @@ def MakeInlineTest(__file, __globals, decorators=None):
|
|||
test.name = test_name
|
||||
|
||||
target_platform = lldb.DBG.GetSelectedPlatform().GetTriple().split('-')[2]
|
||||
if test_categories.is_supported_on_platform("dsym", target_platform):
|
||||
if test_categories.is_supported_on_platform("dsym", target_platform, configuration.compilers):
|
||||
test.test_with_dsym = ApplyDecoratorsToFunction(test._InlineTest__test_with_dsym, decorators)
|
||||
if test_categories.is_supported_on_platform("dwarf", target_platform):
|
||||
if test_categories.is_supported_on_platform("dwarf", target_platform, configuration.compilers):
|
||||
test.test_with_dwarf = ApplyDecoratorsToFunction(test._InlineTest__test_with_dwarf, decorators)
|
||||
if test_categories.is_supported_on_platform("dwo", target_platform):
|
||||
if test_categories.is_supported_on_platform("dwo", target_platform, configuration.compilers):
|
||||
test.test_with_dwo = ApplyDecoratorsToFunction(test._InlineTest__test_with_dwo, decorators)
|
||||
if test_categories.is_supported_on_platform("gmodules", target_platform, configuration.compilers):
|
||||
test.test_with_gmodules = ApplyDecoratorsToFunction(test._InlineTest__test_with_gmodules, decorators)
|
||||
|
||||
# Add the test case to the globals, and hide InlineTest
|
||||
__globals.update({test_name : test})
|
||||
|
|
|
@ -1329,6 +1329,12 @@ class Base(unittest2.TestCase):
|
|||
if not module.buildDwo(self, architecture, compiler, dictionary, clean):
|
||||
raise Exception("Don't know how to build binary with dwo")
|
||||
|
||||
def buildGModules(self, architecture=None, compiler=None, dictionary=None, clean=True):
|
||||
"""Platform specific way to build binaries with gmodules info."""
|
||||
module = builder_module()
|
||||
if not module.buildGModules(self, architecture, compiler, dictionary, clean):
|
||||
raise Exception("Don't know how to build binary with gmodules")
|
||||
|
||||
def buildGo(self):
|
||||
"""Build the default go binary.
|
||||
"""
|
||||
|
@ -1447,8 +1453,9 @@ class LLDBTestCaseFactory(type):
|
|||
if not categories:
|
||||
categories = all_dbginfo_categories
|
||||
|
||||
supported_categories = [x for x in categories
|
||||
if test_categories.is_supported_on_platform(x, target_platform)]
|
||||
supported_categories = [x for x in categories
|
||||
if test_categories.is_supported_on_platform(
|
||||
x, target_platform, configuration.compilers)]
|
||||
if "dsym" in supported_categories:
|
||||
@decorators.add_test_categories(["dsym"])
|
||||
@wraps(attrvalue)
|
||||
|
@ -1478,6 +1485,17 @@ class LLDBTestCaseFactory(type):
|
|||
dwo_method_name = attrname + "_dwo"
|
||||
dwo_test_method.__name__ = dwo_method_name
|
||||
newattrs[dwo_method_name] = dwo_test_method
|
||||
|
||||
if "gmodules" in supported_categories:
|
||||
@decorators.add_test_categories(["gmodules"])
|
||||
@wraps(attrvalue)
|
||||
def gmodules_test_method(self, attrvalue=attrvalue):
|
||||
self.debug_info = "gmodules"
|
||||
return attrvalue(self)
|
||||
gmodules_method_name = attrname + "_gmodules"
|
||||
gmodules_test_method.__name__ = gmodules_method_name
|
||||
newattrs[gmodules_method_name] = gmodules_test_method
|
||||
|
||||
else:
|
||||
newattrs[attrname] = attrvalue
|
||||
return super(LLDBTestCaseFactory, cls).__new__(cls, name, bases, newattrs)
|
||||
|
@ -1947,6 +1965,8 @@ class TestBase(Base):
|
|||
return self.buildDwarf(architecture, compiler, dictionary, clean)
|
||||
elif self.debug_info == "dwo":
|
||||
return self.buildDwo(architecture, compiler, dictionary, clean)
|
||||
elif self.debug_info == "gmodules":
|
||||
return self.buildGModules(architecture, compiler, dictionary, clean)
|
||||
else:
|
||||
self.fail("Can't build for debug info: %s" % self.debug_info)
|
||||
|
||||
|
|
|
@ -212,8 +212,13 @@ ifeq "$(MAKE_DWO)" "YES"
|
|||
CFLAGS += -gsplit-dwarf
|
||||
endif
|
||||
|
||||
ifeq "$(MAKE_GMODULES)" "YES"
|
||||
CFLAGS += -fmodules -gmodules
|
||||
endif
|
||||
|
||||
CXXFLAGS += -std=c++11
|
||||
CXXFLAGS += $(CFLAGS)
|
||||
# FIXME: C++ modules aren't supported on all platforms.
|
||||
CXXFLAGS += $(subst -fmodules,, $(CFLAGS))
|
||||
LD = $(CC)
|
||||
LDFLAGS ?= $(CFLAGS)
|
||||
LDFLAGS += $(LD_EXTRAS)
|
||||
|
@ -519,7 +524,7 @@ endif
|
|||
$(PCH_OUTPUT) : $(PCH_CXX_SOURCE)
|
||||
$(CXX) $(CXXFLAGS) -x c++-header -o $(PCH_OUTPUT) $(PCH_CXX_SOURCE)
|
||||
%.o : %.cpp $(PCH_OUTPUT)
|
||||
$(CXX) $(PCHFLAGS) $(CXXFLAGS) $(CFLAGS) -c -o $@ $<
|
||||
$(CXX) $(PCHFLAGS) $(CXXFLAGS) -c -o $@ $<
|
||||
#endif
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
|
|
@ -143,6 +143,17 @@ def buildDwo(sender=None, architecture=None, compiler=None, dictionary=None, cle
|
|||
# True signifies that we can handle building dwo.
|
||||
return True
|
||||
|
||||
def buildGModules(sender=None, architecture=None, compiler=None, dictionary=None, clean=True):
|
||||
"""Build the binaries with dwarf debug info."""
|
||||
commands = []
|
||||
if clean:
|
||||
commands.append([getMake(), "clean", getCmdLine(dictionary)])
|
||||
commands.append([getMake(), "MAKE_DSYM=NO", "MAKE_GMODULES=YES", getArchSpec(architecture), getCCSpec(compiler), getCmdLine(dictionary)])
|
||||
|
||||
lldbtest.system(commands, sender=sender)
|
||||
# True signifies that we can handle building with gmodules.
|
||||
return True
|
||||
|
||||
def cleanup(sender=None, dictionary=None):
|
||||
"""Perform a platform-specific cleanup after the test."""
|
||||
#import traceback
|
||||
|
|
|
@ -11,9 +11,11 @@ import sys
|
|||
# Third-party modules
|
||||
|
||||
# LLDB modules
|
||||
from lldbsuite.support import gmodules
|
||||
|
||||
|
||||
debug_info_categories = [
|
||||
'dwarf', 'dwo', 'dsym'
|
||||
'dwarf', 'dwo', 'dsym', 'gmodules'
|
||||
]
|
||||
|
||||
all_categories = {
|
||||
|
@ -21,6 +23,7 @@ all_categories = {
|
|||
'dwarf' : 'Tests that can be run with DWARF debug information',
|
||||
'dwo' : 'Tests that can be run with DWO debug information',
|
||||
'dsym' : 'Tests that can be run with DSYM debug information',
|
||||
'gmodules' : 'Tests that can be run with -gmodules debug information',
|
||||
'expression' : 'Tests related to the expression parser',
|
||||
'objc' : 'Tests related to the Objective-C programming language support',
|
||||
'pyapi' : 'Tests related to the Python API',
|
||||
|
@ -42,12 +45,27 @@ def unique_string_match(yourentry, list):
|
|||
candidate = item
|
||||
return candidate
|
||||
|
||||
def is_supported_on_platform(category, platform):
|
||||
|
||||
def is_supported_on_platform(category, platform, compiler_paths):
|
||||
if category == "dwo":
|
||||
# -gsplit-dwarf is not implemented by clang on Windows.
|
||||
return platform in ["linux", "freebsd"]
|
||||
elif category == "dsym":
|
||||
return platform in ["darwin", "macosx", "ios"]
|
||||
elif category == "gmodules":
|
||||
# First, check to see if the platform can even support gmodules.
|
||||
if platform not in ["linux", "freebsd", "darwin", "macosx", "ios"]:
|
||||
return False
|
||||
# If all compilers specified support gmodules, we'll enable it.
|
||||
for compiler_path in compiler_paths:
|
||||
if not gmodules.is_compiler_clang_with_gmodules(compiler_path):
|
||||
# Ideally in a multi-compiler scenario during a single test run, this would
|
||||
# allow gmodules on compilers that support it and not on ones that don't.
|
||||
# However, I didn't see an easy way for all the callers of this to know
|
||||
# the compiler being used for a test invocation. As we tend to run with
|
||||
# a single compiler per test run, this shouldn't be a major issue.
|
||||
return False
|
||||
return True
|
||||
return True
|
||||
|
||||
def validate(categories, exact_match):
|
||||
|
|
Загрузка…
Ссылка в новой задаче