summaryrefslogtreecommitdiffstats
path: root/lldb/test/expression_command
diff options
context:
space:
mode:
authorDawn Perchik <dawn@burble.org>2015-09-04 01:02:30 +0000
committerDawn Perchik <dawn@burble.org>2015-09-04 01:02:30 +0000
commit009d110de476e6a1c9581b1e57a90dd73593b8aa (patch)
treeb3c21aba02ef7872b0b88463b77f5a96d9c92ba8 /lldb/test/expression_command
parentb2e9897644383e7e535a3f4465706760b336ca49 (diff)
downloadbcm5719-llvm-009d110de476e6a1c9581b1e57a90dd73593b8aa.tar.gz
bcm5719-llvm-009d110de476e6a1c9581b1e57a90dd73593b8aa.zip
Set the default language to use when evaluating to that of the frame's CU.
* Use the frame's context (instead of just the target's) when evaluating, so that the language of the frame's CU can be used to select the compiler and/or compiler options to use when parsing the expression. This allows for modules built with mixed languages to be parsed in the context of their frame. * Add all C and C++ language variants when determining the language options to set. * Enable C++ language options when language is C or ObjC as a workaround since the expression parser uses features of C++ to capture values. * Enable ObjC language options when language is C++ as a workaround for ObjC requirements. * Disable C++11 language options when language is C++03. * Add test TestMixedLanguages.py to check that the language being used for evaluation is that of the frame. * Fix test TestExprOptions.py to check for C++11 instead of C++ since C++ has to be enabled for C, and remove redundant expr --language test for ObjC. * Fix TestPersistentPtrUpdate.py to not require C++11 in C. Reviewed by: clayborg, spyffe, jingham Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D11102 llvm-svn: 246829
Diffstat (limited to 'lldb/test/expression_command')
-rw-r--r--lldb/test/expression_command/options/TestExprOptions.py73
-rw-r--r--lldb/test/expression_command/persistent_ptr_update/TestPersistentPtrUpdate.py2
2 files changed, 22 insertions, 53 deletions
diff --git a/lldb/test/expression_command/options/TestExprOptions.py b/lldb/test/expression_command/options/TestExprOptions.py
index 4beba7d959b..2dca24657a3 100644
--- a/lldb/test/expression_command/options/TestExprOptions.py
+++ b/lldb/test/expression_command/options/TestExprOptions.py
@@ -26,15 +26,7 @@ class ExprOptionsTestCase(TestBase):
self.line = line_number('main.cpp', '// breakpoint_in_main')
self.exe = os.path.join(os.getcwd(), "a.out")
- @skipUnlessDarwin
- def test_expr_options_objc_cpp(self):
- self.expr_options(test_objc = True, test_cpp = True)
-
- @skipIfDarwin # Already covered by test_expr_options_objc_cpp
- def test_expr_options_cpp(self):
- self.expr_options(test_objc = False, test_cpp = True)
-
- def expr_options(self, test_objc, test_cpp):
+ def test_expr_options(self):
"""These expression command options should work as expected."""
self.buildDefault()
@@ -59,49 +51,26 @@ class ExprOptionsTestCase(TestBase):
frame = threads[0].GetFrameAtIndex(0)
options = lldb.SBExpressionOptions()
- if test_objc:
- # -- test --language on ObjC builtin type using the SB API's --
- # Make sure we can evaluate the ObjC builtin type 'id':
- val = frame.EvaluateExpression('id my_id = 0; my_id')
- self.assertTrue(val.IsValid())
- self.assertTrue(val.GetError().Success())
- self.assertEqual(val.GetValueAsUnsigned(0), 0)
- self.DebugSBValue(val)
-
- # Make sure it still works if language is set to ObjC++:
- options.SetLanguage(lldb.eLanguageTypeObjC_plus_plus)
- val = frame.EvaluateExpression('id my_id = 0; my_id', options)
- self.assertTrue(val.IsValid())
- self.assertTrue(val.GetError().Success())
- self.assertEqual(val.GetValueAsUnsigned(0), 0)
- self.DebugSBValue(val)
-
- # Make sure it fails if language is set to C:
- options.SetLanguage(lldb.eLanguageTypeC)
- val = frame.EvaluateExpression('id my_id = 0; my_id', options)
- self.assertTrue(val.IsValid())
- self.assertFalse(val.GetError().Success())
-
- if test_cpp:
- # -- test --language on C++ expression using the SB API's --
- # Make sure we can evaluate 'ns::func'.
- val = frame.EvaluateExpression('ns::func')
- self.assertTrue(val.IsValid())
- self.assertTrue(val.GetError().Success())
- self.DebugSBValue(val)
-
- # Make sure it still works if language is set to C++:
- options.SetLanguage(lldb.eLanguageTypeC_plus_plus)
- val = frame.EvaluateExpression('ns::func', 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('ns::func', options)
- self.assertTrue(val.IsValid())
- self.assertFalse(val.GetError().Success())
+ # test --language on C++ expression using the SB API's
+
+ # Make sure we can evaluate 'ns::func'.
+ 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())
if __name__ == '__main__':
import atexit
diff --git a/lldb/test/expression_command/persistent_ptr_update/TestPersistentPtrUpdate.py b/lldb/test/expression_command/persistent_ptr_update/TestPersistentPtrUpdate.py
index 9c291219529..af21086c006 100644
--- a/lldb/test/expression_command/persistent_ptr_update/TestPersistentPtrUpdate.py
+++ b/lldb/test/expression_command/persistent_ptr_update/TestPersistentPtrUpdate.py
@@ -42,7 +42,7 @@ class PersistentPtrUpdateTestCase(TestBase):
self.runCmd("run", RUN_SUCCEEDED)
- self.runCmd("expr void* $foo = nullptr")
+ self.runCmd("expr void* $foo = 0")
self.runCmd("continue")
OpenPOWER on IntegriCloud