summaryrefslogtreecommitdiffstats
path: root/lldb/test/lang/objc/modules-inline-functions
diff options
context:
space:
mode:
authorSean Callanan <scallanan@apple.com>2015-05-01 00:47:29 +0000
committerSean Callanan <scallanan@apple.com>2015-05-01 00:47:29 +0000
commit80c9759ef74037c485d3e9f4b27a38b3633a2139 (patch)
treec4d4ec5a3d116a22ec0ac532e22f1b4bb45294b2 /lldb/test/lang/objc/modules-inline-functions
parent65b5b01d56f55bd9e9ea3ed03861c653f342c3fd (diff)
downloadbcm5719-llvm-80c9759ef74037c485d3e9f4b27a38b3633a2139.tar.gz
bcm5719-llvm-80c9759ef74037c485d3e9f4b27a38b3633a2139.zip
Added support for locating and importing functions
(including inline functions) from modules in the expression parser. We now have to retain a reference to the code generator in ClangExpressionDeclMap so that any imported function bodies can be appropriately sent to that code generator. <rdar://problem/19883002> llvm-svn: 236297
Diffstat (limited to 'lldb/test/lang/objc/modules-inline-functions')
-rw-r--r--lldb/test/lang/objc/modules-inline-functions/Makefile9
-rw-r--r--lldb/test/lang/objc/modules-inline-functions/TestModulesInlineFunctions.py80
-rw-r--r--lldb/test/lang/objc/modules-inline-functions/main.m9
-rw-r--r--lldb/test/lang/objc/modules-inline-functions/module.map4
-rw-r--r--lldb/test/lang/objc/modules-inline-functions/myModule.c7
-rw-r--r--lldb/test/lang/objc/modules-inline-functions/myModule.h7
6 files changed, 116 insertions, 0 deletions
diff --git a/lldb/test/lang/objc/modules-inline-functions/Makefile b/lldb/test/lang/objc/modules-inline-functions/Makefile
new file mode 100644
index 00000000000..6ad9e0010bb
--- /dev/null
+++ b/lldb/test/lang/objc/modules-inline-functions/Makefile
@@ -0,0 +1,9 @@
+LEVEL = ../../../make
+
+C_SOURCES := myModule.c
+
+OBJC_SOURCES := main.m
+
+include $(LEVEL)/Makefile.rules
+
+CFLAGS += -fmodules -I$(PWD)
diff --git a/lldb/test/lang/objc/modules-inline-functions/TestModulesInlineFunctions.py b/lldb/test/lang/objc/modules-inline-functions/TestModulesInlineFunctions.py
new file mode 100644
index 00000000000..a9c7ce65067
--- /dev/null
+++ b/lldb/test/lang/objc/modules-inline-functions/TestModulesInlineFunctions.py
@@ -0,0 +1,80 @@
+"""Test that inline functions from modules are imported correctly"""
+
+import os, time
+import unittest2
+import lldb
+import platform
+import lldbutil
+
+from distutils.version import StrictVersion
+
+from lldbtest import *
+
+class ModulesInlineFunctionsTestCase(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 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 isInline(2)", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs = ["4"])
+
+if __name__ == '__main__':
+ import atexit
+ lldb.SBDebugger.Initialize()
+ atexit.register(lambda: lldb.SBDebugger.Terminate())
+ unittest2.main()
diff --git a/lldb/test/lang/objc/modules-inline-functions/main.m b/lldb/test/lang/objc/modules-inline-functions/main.m
new file mode 100644
index 00000000000..13a5bf316ee
--- /dev/null
+++ b/lldb/test/lang/objc/modules-inline-functions/main.m
@@ -0,0 +1,9 @@
+@import Darwin;
+@import myModule;
+
+int main()
+{
+ int a = isInline(2);
+ int b = notInline();
+ printf("%d %d\n", a, b); // Set breakpoint here.
+}
diff --git a/lldb/test/lang/objc/modules-inline-functions/module.map b/lldb/test/lang/objc/modules-inline-functions/module.map
new file mode 100644
index 00000000000..2ef8064d15b
--- /dev/null
+++ b/lldb/test/lang/objc/modules-inline-functions/module.map
@@ -0,0 +1,4 @@
+module myModule {
+ header "myModule.h"
+ export *
+}
diff --git a/lldb/test/lang/objc/modules-inline-functions/myModule.c b/lldb/test/lang/objc/modules-inline-functions/myModule.c
new file mode 100644
index 00000000000..ad3c85d155e
--- /dev/null
+++ b/lldb/test/lang/objc/modules-inline-functions/myModule.c
@@ -0,0 +1,7 @@
+#include "myModule.h"
+
+int notInline()
+{
+ return 3;
+}
+
diff --git a/lldb/test/lang/objc/modules-inline-functions/myModule.h b/lldb/test/lang/objc/modules-inline-functions/myModule.h
new file mode 100644
index 00000000000..d50d0101f64
--- /dev/null
+++ b/lldb/test/lang/objc/modules-inline-functions/myModule.h
@@ -0,0 +1,7 @@
+int notInline();
+
+static __inline__ __attribute__ ((always_inline)) int isInline(int a)
+{
+ int b = a + a;
+ return b;
+}
OpenPOWER on IntegriCloud