diff options
Diffstat (limited to 'packages/Python/lldbsuite/test/expression_command/options')
-rw-r--r-- | packages/Python/lldbsuite/test/expression_command/options/TestExprOptions.py | 28 | ||||
-rw-r--r-- | packages/Python/lldbsuite/test/expression_command/options/main.cpp | 4 |
2 files changed, 31 insertions, 1 deletions
diff --git a/packages/Python/lldbsuite/test/expression_command/options/TestExprOptions.py b/packages/Python/lldbsuite/test/expression_command/options/TestExprOptions.py index 1dbafc36a82a..13bc3b7ce2ac 100644 --- a/packages/Python/lldbsuite/test/expression_command/options/TestExprOptions.py +++ b/packages/Python/lldbsuite/test/expression_command/options/TestExprOptions.py @@ -14,6 +14,7 @@ import os import time import lldb import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * @@ -63,3 +64,30 @@ class ExprOptionsTestCase(TestBase): val = frame.EvaluateExpression('foo != nullptr', options) self.assertTrue(val.IsValid()) self.assertFalse(val.GetError().Success()) + + @skipIfDarwin + def test_expr_options_lang(self): + """These expression language options should work as expected.""" + self.build() + + # Set debugger into synchronous mode + self.dbg.SetAsync(False) + + (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( + self, '// breakpoint_in_main', self.main_source_spec) + + frame = thread.GetFrameAtIndex(0) + options = lldb.SBExpressionOptions() + + # Make sure we can retrieve `id` variable if language is set to C++11: + options.SetLanguage(lldb.eLanguageTypeC_plus_plus_11) + val = frame.EvaluateExpression('id == 0', options) + self.assertTrue(val.IsValid()) + self.assertTrue(val.GetError().Success()) + self.DebugSBValue(val) + + # Make sure we can't retrieve `id` variable if language is set to ObjC: + options.SetLanguage(lldb.eLanguageTypeObjC) + val = frame.EvaluateExpression('id == 0', options) + self.assertTrue(val.IsValid()) + self.assertFalse(val.GetError().Success()) diff --git a/packages/Python/lldbsuite/test/expression_command/options/main.cpp b/packages/Python/lldbsuite/test/expression_command/options/main.cpp index ecd9a90f6626..0d30c79bd229 100644 --- a/packages/Python/lldbsuite/test/expression_command/options/main.cpp +++ b/packages/Python/lldbsuite/test/expression_command/options/main.cpp @@ -1,11 +1,13 @@ extern "C" int foo(void); static int static_value = 0; +static int id = 1234; int bar() { static_value++; - return static_value; + id++; + return static_value + id; } int main (int argc, char const *argv[]) |