[Lldb-commits] [lldb] r266791 - Adds a test to detect when clang omits specialized generic types from debug information when using precompiled headers and -gmodules.
Kate Stone via lldb-commits
lldb-commits at lists.llvm.org
Tue Apr 19 11:20:11 PDT 2016
Author: kate
Date: Tue Apr 19 13:20:11 2016
New Revision: 266791
URL: http://llvm.org/viewvc/llvm-project?rev=266791&view=rev
Log:
Adds a test to detect when clang omits specialized generic types from debug information when using precompiled headers and -gmodules.
Added:
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/Makefile
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/TestWithModuleDebugging.py
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/main.cpp
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/pch.h
Modified:
lldb/trunk/packages/Python/lldbsuite/test/decorators.py
lldb/trunk/packages/Python/lldbsuite/test/make/Makefile.rules
Modified: lldb/trunk/packages/Python/lldbsuite/test/decorators.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/decorators.py?rev=266791&r1=266790&r2=266791&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/decorators.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/decorators.py Tue Apr 19 13:20:11 2016
@@ -15,6 +15,7 @@ import unittest2
# LLDB modules
import use_lldb_suite
+import lldbtest
import lldb
from . import configuration
@@ -507,3 +508,16 @@ def skipUnlessCompilerRt(func):
compilerRtPath = os.path.join(os.path.dirname(__file__), "..", "..", "..", "..", "llvm","projects","compiler-rt")
return "compiler-rt not found" if not os.path.exists(compilerRtPath) else None
return skipTestIfFn(is_compiler_rt_missing)(func)
+
+def skipUnlessClangModules():
+ """Decorate the item to skip test unless Clang -gmodules flag is supported."""
+ def is_compiler_clang_with_gmodules(self):
+ builder = lldbtest.builder_module()
+ compiler_path = builder.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)
Added: lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/Makefile?rev=266791&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/Makefile (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/Makefile Tue Apr 19 13:20:11 2016
@@ -0,0 +1,7 @@
+LEVEL = ../../../make
+
+PCH_CXX_SOURCE = pch.h
+CXX_SOURCES = main.cpp
+CFLAGS_EXTRAS += $(MODULE_DEBUG_INFO_FLAGS)
+
+include $(LEVEL)/Makefile.rules
Added: lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/TestWithModuleDebugging.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/TestWithModuleDebugging.py?rev=266791&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/TestWithModuleDebugging.py (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/TestWithModuleDebugging.py Tue Apr 19 13:20:11 2016
@@ -0,0 +1,56 @@
+import lldb, os
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestWithGmodulesDebugInfo(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @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()
+
+ src_file = os.path.join(cwd, "main.cpp")
+ src_file_spec = lldb.SBFileSpec(src_file)
+ self.assertTrue(src_file_spec.IsValid(), "breakpoint file")
+
+ # Get the path of the executable
+ exe_path = os.path.join(cwd, 'a.out')
+
+ # Load the executable
+ target = self.dbg.CreateTarget(exe_path)
+ self.assertTrue(target.IsValid(), VALID_TARGET)
+
+ # Break on interesting line
+ breakpoint = target.BreakpointCreateBySourceRegex("break here", src_file_spec)
+ self.assertTrue(breakpoint.IsValid() and breakpoint.GetNumLocations() >= 1, VALID_BREAKPOINT)
+
+ # Launch the process
+ process = target.LaunchSimple(None, None, self.get_process_working_directory())
+ self.assertTrue(process.IsValid(), PROCESS_IS_VALID)
+
+ # Get the thread of the process
+ self.assertTrue(process.GetState() == lldb.eStateStopped)
+ thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)
+ self.assertTrue(thread.IsValid(), "There should be a thread stopped due to breakpoint condition")
+
+ # Get frame for current thread
+ frame = thread.frames[0]
+
+ testValue = frame.EvaluateExpression("test")
+ self.assertTrue(testValue.GetError().Success(), "Test expression value invalid: %s" % (testValue.GetError().GetCString()))
+ self.assertTrue(testValue.GetTypeName() == "IntContainer", "Test expression type incorrect")
+
+ memberValue = testValue.GetChildMemberWithName("storage")
+ self.assertTrue(memberValue.GetError().Success(), "Member value missing or invalid: %s" % (testValue.GetError().GetCString()))
+ self.assertTrue(memberValue.GetTypeName() == "int", "Member type incorrect")
+ self.assertEqual(42, memberValue.GetValueAsSigned(), "Member value incorrect")
Added: lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/main.cpp?rev=266791&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/main.cpp (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/main.cpp Tue Apr 19 13:20:11 2016
@@ -0,0 +1,5 @@
+int main(int argc, const char * argv[])
+{
+ IntContainer test(42);
+ return 0; // break here
+}
Added: lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/pch.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/pch.h?rev=266791&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/pch.h (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/pch.h Tue Apr 19 13:20:11 2016
@@ -0,0 +1,12 @@
+template<typename T>
+class GenericContainer {
+ private:
+ T storage;
+
+ public:
+ GenericContainer(T value) {
+ storage = value;
+ };
+};
+
+typedef GenericContainer<int> IntContainer;
Modified: lldb/trunk/packages/Python/lldbsuite/test/make/Makefile.rules
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/make/Makefile.rules?rev=266791&r1=266790&r2=266791&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/make/Makefile.rules (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/make/Makefile.rules Tue Apr 19 13:20:11 2016
@@ -183,9 +183,11 @@ endif
LIMIT_DEBUG_INFO_FLAGS =
NO_LIMIT_DEBUG_INFO_FLAGS =
+MODULE_DEBUG_INFO_FLAGS =
ifneq (,$(findstring clang,$(CC)))
LIMIT_DEBUG_INFO_FLAGS += -flimit-debug-info
NO_LIMIT_DEBUG_INFO_FLAGS += -fno-limit-debug-info
+ MODULE_DEBUG_INFO_FLAGS += -gmodules
endif
DEBUG_INFO_FLAG ?= -g
@@ -344,6 +346,14 @@ ifneq "$(strip $(DYLIB_CXX_SOURCES))" ""
endif
#----------------------------------------------------------------------
+# Check if we have a precompiled header
+#----------------------------------------------------------------------
+ifneq "$(strip $(PCH_CXX_SOURCE))" ""
+ PCH_OUTPUT = $(PCH_CXX_SOURCE:.h=.h.pch)
+ PCHFLAGS = -include $(PCH_CXX_SOURCE)
+endif
+
+#----------------------------------------------------------------------
# Check if we have any C source files
#----------------------------------------------------------------------
ifneq "$(strip $(C_SOURCES))" ""
@@ -502,6 +512,17 @@ endif
endif
#----------------------------------------------------------------------
+# Make the precompiled header and compile C++ sources against it
+#----------------------------------------------------------------------
+
+#ifneq "$(PCH_OUTPUT)" ""
+$(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 $@ $<
+#endif
+
+#----------------------------------------------------------------------
# Automatic variables based on items already entered. Below we create
# an object's lists from the list of sources by replacing all entries
# that end with .c with .o, and we also create a list of prerequisite
@@ -574,6 +595,9 @@ ifneq "$(DYLIB_NAME)" ""
$(RM) -r $(DYLIB_FILENAME).dSYM
$(RM) $(DYLIB_OBJECTS) $(DYLIB_PREREQS) $(DYLIB_PREREQS:.d=.d.tmp) $(DYLIB_DWOS) $(DYLIB_FILENAME) $(DYLIB_FILENAME).debug
endif
+ifneq "$(PCH_OUTPUT)" ""
+ $(RM) $(PCH_OUTPUT)
+endif
ifneq "$(DSYM)" ""
$(RM) -r "$(DSYM)"
endif
More information about the lldb-commits
mailing list