[Lldb-commits] [lldb] r234016 - Added a testcase that covers loading a module and
Sean Callanan
scallanan at apple.com
Fri Apr 3 08:39:47 PDT 2015
Author: spyffe
Date: Fri Apr 3 10:39:47 2015
New Revision: 234016
URL: http://llvm.org/viewvc/llvm-project?rev=234016&view=rev
Log:
Added a testcase that covers loading a module and
verifying that the types from that module don't
override types from DWARF. Also added a target setting
to LLDB so we can tell Clang where to look for these
local modules.
<rdar://problem/18805055>
Added:
lldb/trunk/test/lang/objc/modules-incomplete/
lldb/trunk/test/lang/objc/modules-incomplete/Makefile
lldb/trunk/test/lang/objc/modules-incomplete/TestIncompleteModules.py
lldb/trunk/test/lang/objc/modules-incomplete/main.m
lldb/trunk/test/lang/objc/modules-incomplete/module.map
lldb/trunk/test/lang/objc/modules-incomplete/myModule.h
lldb/trunk/test/lang/objc/modules-incomplete/myModule.m
Modified:
lldb/trunk/include/lldb/Target/Target.h
lldb/trunk/source/Expression/ClangModulesDeclVendor.cpp
lldb/trunk/source/Target/Target.cpp
Modified: lldb/trunk/include/lldb/Target/Target.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=234016&r1=234015&r2=234016&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Target.h (original)
+++ lldb/trunk/include/lldb/Target/Target.h Fri Apr 3 10:39:47 2015
@@ -124,6 +124,9 @@ public:
FileSpecList &
GetDebugFileSearchPaths ();
+ FileSpecList &
+ GetClangModuleSearchPaths ();
+
bool
GetEnableSyntheticValue () const;
@@ -557,6 +560,9 @@ public:
static FileSpecList
GetDefaultDebugFileSearchPaths ();
+
+ static FileSpecList
+ GetDefaultClangModuleSearchPaths ();
static ArchSpec
GetDefaultArchitecture ();
Modified: lldb/trunk/source/Expression/ClangModulesDeclVendor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangModulesDeclVendor.cpp?rev=234016&r1=234015&r2=234016&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangModulesDeclVendor.cpp (original)
+++ lldb/trunk/source/Expression/ClangModulesDeclVendor.cpp Fri Apr 3 10:39:47 2015
@@ -309,6 +309,18 @@ ClangModulesDeclVendor::Create(Target &t
compiler_invocation_arguments.push_back(module_cache_argument);
}
+ FileSpecList &module_search_paths = target.GetClangModuleSearchPaths();
+
+ for (size_t spi = 0, spe = module_search_paths.GetSize(); spi < spe; ++spi)
+ {
+ const FileSpec &search_path = module_search_paths.GetFileSpecAtIndex(spi);
+
+ std::string search_path_argument = "-I";
+ search_path_argument.append(search_path.GetPath());
+
+ compiler_invocation_arguments.push_back(search_path_argument);
+ }
+
{
FileSpec clang_resource_dir = GetResourceDir();
Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=234016&r1=234015&r2=234016&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Fri Apr 3 10:39:47 2015
@@ -1921,6 +1921,15 @@ Target::GetDefaultDebugFileSearchPaths (
return FileSpecList();
}
+FileSpecList
+Target::GetDefaultClangModuleSearchPaths ()
+{
+ TargetPropertiesSP properties_sp(Target::GetGlobalProperties());
+ if (properties_sp)
+ return properties_sp->GetClangModuleSearchPaths();
+ return FileSpecList();
+}
+
ArchSpec
Target::GetDefaultArchitecture ()
{
@@ -2935,6 +2944,7 @@ g_properties[] =
"Each element of the array is checked in order and the first one that results in a match wins." },
{ "exec-search-paths" , OptionValue::eTypeFileSpecList, false, 0 , NULL, NULL, "Executable search paths to use when locating executable files whose paths don't match the local file system." },
{ "debug-file-search-paths" , OptionValue::eTypeFileSpecList, false, 0 , NULL, NULL, "List of directories to be searched when locating debug symbol files." },
+ { "clang-module-search-paths" , OptionValue::eTypeFileSpecList, false, 0 , NULL, NULL, "List of directories to be searched when locating modules for Clang." },
{ "max-children-count" , OptionValue::eTypeSInt64 , false, 256 , NULL, NULL, "Maximum number of children to expand in any level of depth." },
{ "max-string-summary-length" , OptionValue::eTypeSInt64 , false, 1024 , NULL, NULL, "Maximum number of characters to show when using %s in summary strings." },
{ "max-memory-read-size" , OptionValue::eTypeSInt64 , false, 1024 , NULL, NULL, "Maximum number of bytes that 'memory read' will fetch before --force must be specified." },
@@ -2985,6 +2995,7 @@ enum
ePropertySourceMap,
ePropertyExecutableSearchPaths,
ePropertyDebugFileSearchPaths,
+ ePropertyClangModuleSearchPaths,
ePropertyMaxChildrenCount,
ePropertyMaxSummaryLength,
ePropertyMaxMemReadSize,
@@ -3327,6 +3338,15 @@ TargetProperties::GetDebugFileSearchPath
OptionValueFileSpecList *option_value = m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList (NULL, false, idx);
assert(option_value);
return option_value->GetCurrentValue();
+}
+
+FileSpecList &
+TargetProperties::GetClangModuleSearchPaths ()
+{
+ const uint32_t idx = ePropertyClangModuleSearchPaths;
+ OptionValueFileSpecList *option_value = m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList (NULL, false, idx);
+ assert(option_value);
+ return option_value->GetCurrentValue();
}
bool
Added: lldb/trunk/test/lang/objc/modules-incomplete/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/modules-incomplete/Makefile?rev=234016&view=auto
==============================================================================
--- lldb/trunk/test/lang/objc/modules-incomplete/Makefile (added)
+++ lldb/trunk/test/lang/objc/modules-incomplete/Makefile Fri Apr 3 10:39:47 2015
@@ -0,0 +1,8 @@
+LEVEL = ../../../make
+
+OBJC_SOURCES := main.m myModule.m
+
+include $(LEVEL)/Makefile.rules
+
+CFLAGS += -fmodules -I$(PWD)
+LDFLAGS += -framework Foundation
Added: lldb/trunk/test/lang/objc/modules-incomplete/TestIncompleteModules.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/modules-incomplete/TestIncompleteModules.py?rev=234016&view=auto
==============================================================================
--- lldb/trunk/test/lang/objc/modules-incomplete/TestIncompleteModules.py (added)
+++ lldb/trunk/test/lang/objc/modules-incomplete/TestIncompleteModules.py Fri Apr 3 10:39:47 2015
@@ -0,0 +1,80 @@
+"""Test that DWARF types are trusted over module types"""
+
+import os, time
+import unittest2
+import lldb
+import platform
+import lldbutil
+
+from distutils.version import StrictVersion
+
+from lldbtest import *
+
+class IncompleteModulesTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @skipUnlessDarwin
+ @dsym_test
+ def test_expr_with_dsym(self):
+ self.buildDsym()
+ self.expr()
+
+ @dwarf_test
+ @skipIfFreeBSD
+ @skipIfLinux
+ def test_expr_with_dwarf(self):
+ self.buildDwarf()
+ self.expr()
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break inside main().
+ self.line = line_number('main.m', '// Set breakpoint 0 here.')
+
+ def applies(self):
+ if platform.system() != "Darwin":
+ return False
+ if StrictVersion('12.0.0') > platform.release():
+ return False
+
+ return True
+
+ def common_setup(self):
+ exe = os.path.join(os.getcwd(), "a.out")
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ # Break inside the foo function which takes a bar_ptr argument.
+ lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # The breakpoint should have a hit count of 1.
+ self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
+ substrs = [' resolved, hit count = 1'])
+
+ def expr(self):
+ if not self.applies():
+ return
+
+ self.common_setup()
+
+ self.runCmd("settings set target.clang-module-search-paths \"" + os.getcwd() + "\"")
+
+ self.expect("expr @import myModule; 3", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs = ["int", "3"])
+
+ self.expect("expr [myObject privateMethod]", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs = ["int", "5"])
+
+if __name__ == '__main__':
+ import atexit
+ lldb.SBDebugger.Initialize()
+ atexit.register(lambda: lldb.SBDebugger.Terminate())
+ unittest2.main()
Added: lldb/trunk/test/lang/objc/modules-incomplete/main.m
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/modules-incomplete/main.m?rev=234016&view=auto
==============================================================================
--- lldb/trunk/test/lang/objc/modules-incomplete/main.m (added)
+++ lldb/trunk/test/lang/objc/modules-incomplete/main.m Fri Apr 3 10:39:47 2015
@@ -0,0 +1,11 @@
+ at import Foundation;
+ at import myModule;
+
+int main()
+{
+ @autoreleasepool
+ {
+ MyClass *myObject = [MyClass alloc];
+ [myObject publicMethod]; // Set breakpoint 0 here.
+ }
+}
Added: lldb/trunk/test/lang/objc/modules-incomplete/module.map
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/modules-incomplete/module.map?rev=234016&view=auto
==============================================================================
--- lldb/trunk/test/lang/objc/modules-incomplete/module.map (added)
+++ lldb/trunk/test/lang/objc/modules-incomplete/module.map Fri Apr 3 10:39:47 2015
@@ -0,0 +1,4 @@
+module myModule {
+ header "myModule.h"
+ export *
+}
Added: lldb/trunk/test/lang/objc/modules-incomplete/myModule.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/modules-incomplete/myModule.h?rev=234016&view=auto
==============================================================================
--- lldb/trunk/test/lang/objc/modules-incomplete/myModule.h (added)
+++ lldb/trunk/test/lang/objc/modules-incomplete/myModule.h Fri Apr 3 10:39:47 2015
@@ -0,0 +1,6 @@
+ at import Foundation;
+
+ at interface MyClass : NSObject {
+};
+-(void)publicMethod;
+ at end
Added: lldb/trunk/test/lang/objc/modules-incomplete/myModule.m
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/modules-incomplete/myModule.m?rev=234016&view=auto
==============================================================================
--- lldb/trunk/test/lang/objc/modules-incomplete/myModule.m (added)
+++ lldb/trunk/test/lang/objc/modules-incomplete/myModule.m Fri Apr 3 10:39:47 2015
@@ -0,0 +1,14 @@
+#include "myModule.h"
+#include "stdio.h"
+
+ at implementation MyClass {
+};
+-(void)publicMethod {
+ printf("Hello public!\n");
+}
+-(int)privateMethod {
+ printf("Hello private!\n");
+ return 3;
+}
+ at end
+
More information about the lldb-commits
mailing list