summaryrefslogtreecommitdiffstats
path: root/packages/Python/lldbsuite/test/expression_command/options
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2016-01-06 20:12:03 +0000
committerdim <dim@FreeBSD.org>2016-01-06 20:12:03 +0000
commit78b9749c0a4ea980a8b934645da6ae98fcc665e8 (patch)
treedd2a1ddf0476664c2b823409c36cbccd52662ca7 /packages/Python/lldbsuite/test/expression_command/options
parent60cb593f9d55fa5ca7a5372b731f2330345b4b9a (diff)
downloadFreeBSD-src-78b9749c0a4ea980a8b934645da6ae98fcc665e8.zip
FreeBSD-src-78b9749c0a4ea980a8b934645da6ae98fcc665e8.tar.gz
Vendor import of lldb trunk r256945:
https://llvm.org/svn/llvm-project/lldb/trunk@256945
Diffstat (limited to 'packages/Python/lldbsuite/test/expression_command/options')
-rw-r--r--packages/Python/lldbsuite/test/expression_command/options/Makefile5
-rw-r--r--packages/Python/lldbsuite/test/expression_command/options/TestExprOptions.py76
-rw-r--r--packages/Python/lldbsuite/test/expression_command/options/foo.cpp11
-rw-r--r--packages/Python/lldbsuite/test/expression_command/options/main.cpp15
4 files changed, 107 insertions, 0 deletions
diff --git a/packages/Python/lldbsuite/test/expression_command/options/Makefile b/packages/Python/lldbsuite/test/expression_command/options/Makefile
new file mode 100644
index 0000000..81ae6f6
--- /dev/null
+++ b/packages/Python/lldbsuite/test/expression_command/options/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../make
+
+CXX_SOURCES := main.cpp foo.cpp
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/expression_command/options/TestExprOptions.py b/packages/Python/lldbsuite/test/expression_command/options/TestExprOptions.py
new file mode 100644
index 0000000..00c3482
--- /dev/null
+++ b/packages/Python/lldbsuite/test/expression_command/options/TestExprOptions.py
@@ -0,0 +1,76 @@
+"""
+Test expression command options.
+
+Test cases:
+
+o test_expr_options:
+ Test expression command options.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+
+class ExprOptionsTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+
+ self.main_source = "main.cpp"
+ self.main_source_spec = lldb.SBFileSpec (self.main_source)
+ self.line = line_number('main.cpp', '// breakpoint_in_main')
+ self.exe = os.path.join(os.getcwd(), "a.out")
+
+ def test_expr_options(self):
+ """These expression command options should work as expected."""
+ self.build()
+
+ # Set debugger into synchronous mode
+ self.dbg.SetAsync(False)
+
+ # Create a target by the debugger.
+ target = self.dbg.CreateTarget(self.exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ # Set breakpoints inside main.
+ breakpoint = target.BreakpointCreateBySourceRegex('// breakpoint_in_main', self.main_source_spec)
+ self.assertTrue(breakpoint)
+
+ # Now launch the process, and do not stop at entry point.
+ process = target.LaunchSimple(None, None, self.get_process_working_directory())
+ self.assertTrue(process, PROCESS_IS_VALID)
+
+ threads = lldbutil.get_threads_stopped_at_breakpoint(process, breakpoint)
+ self.assertEqual(len(threads), 1)
+
+ frame = threads[0].GetFrameAtIndex(0)
+ options = lldb.SBExpressionOptions()
+
+ # test --language on C++ expression using the SB API's
+
+ # Make sure we can evaluate a C++11 expression.
+ val = frame.EvaluateExpression('foo != nullptr')
+ self.assertTrue(val.IsValid())
+ self.assertTrue(val.GetError().Success())
+ self.DebugSBValue(val)
+
+ # Make sure it still works if language is set to C++11:
+ options.SetLanguage(lldb.eLanguageTypeC_plus_plus_11)
+ val = frame.EvaluateExpression('foo != nullptr', options)
+ self.assertTrue(val.IsValid())
+ self.assertTrue(val.GetError().Success())
+ self.DebugSBValue(val)
+
+ # Make sure it fails if language is set to C:
+ options.SetLanguage(lldb.eLanguageTypeC)
+ val = frame.EvaluateExpression('foo != nullptr', options)
+ self.assertTrue(val.IsValid())
+ self.assertFalse(val.GetError().Success())
diff --git a/packages/Python/lldbsuite/test/expression_command/options/foo.cpp b/packages/Python/lldbsuite/test/expression_command/options/foo.cpp
new file mode 100644
index 0000000..8a5a6a2
--- /dev/null
+++ b/packages/Python/lldbsuite/test/expression_command/options/foo.cpp
@@ -0,0 +1,11 @@
+namespace ns {
+ int func(void)
+ {
+ return 0;
+ }
+}
+
+extern "C" int foo(void)
+{
+ return ns::func();
+}
diff --git a/packages/Python/lldbsuite/test/expression_command/options/main.cpp b/packages/Python/lldbsuite/test/expression_command/options/main.cpp
new file mode 100644
index 0000000..ecd9a90
--- /dev/null
+++ b/packages/Python/lldbsuite/test/expression_command/options/main.cpp
@@ -0,0 +1,15 @@
+extern "C" int foo(void);
+static int static_value = 0;
+
+int
+bar()
+{
+ static_value++;
+ return static_value;
+}
+
+int main (int argc, char const *argv[])
+{
+ bar(); // breakpoint_in_main
+ return foo();
+}
OpenPOWER on IntegriCloud