2 Test expression command options.
7 Test expression command options.
10 from __future__ import print_function
16 import lldbsuite.test.lldbutil as lldbutil
17 from lldbsuite.test.lldbtest import *
19 class ExprOptionsTestCase(TestBase):
21 mydir = TestBase.compute_mydir(__file__)
24 # Call super's setUp().
27 self.main_source = "main.cpp"
28 self.main_source_spec = lldb.SBFileSpec (self.main_source)
29 self.line = line_number('main.cpp', '// breakpoint_in_main')
30 self.exe = os.path.join(os.getcwd(), "a.out")
32 def test_expr_options(self):
33 """These expression command options should work as expected."""
36 # Set debugger into synchronous mode
37 self.dbg.SetAsync(False)
39 # Create a target by the debugger.
40 target = self.dbg.CreateTarget(self.exe)
41 self.assertTrue(target, VALID_TARGET)
43 # Set breakpoints inside main.
44 breakpoint = target.BreakpointCreateBySourceRegex('// breakpoint_in_main', self.main_source_spec)
45 self.assertTrue(breakpoint)
47 # Now launch the process, and do not stop at entry point.
48 process = target.LaunchSimple(None, None, self.get_process_working_directory())
49 self.assertTrue(process, PROCESS_IS_VALID)
51 threads = lldbutil.get_threads_stopped_at_breakpoint(process, breakpoint)
52 self.assertEqual(len(threads), 1)
54 frame = threads[0].GetFrameAtIndex(0)
55 options = lldb.SBExpressionOptions()
57 # test --language on C++ expression using the SB API's
59 # Make sure we can evaluate a C++11 expression.
60 val = frame.EvaluateExpression('foo != nullptr')
61 self.assertTrue(val.IsValid())
62 self.assertTrue(val.GetError().Success())
63 self.DebugSBValue(val)
65 # Make sure it still works if language is set to C++11:
66 options.SetLanguage(lldb.eLanguageTypeC_plus_plus_11)
67 val = frame.EvaluateExpression('foo != nullptr', options)
68 self.assertTrue(val.IsValid())
69 self.assertTrue(val.GetError().Success())
70 self.DebugSBValue(val)
72 # Make sure it fails if language is set to C:
73 options.SetLanguage(lldb.eLanguageTypeC)
74 val = frame.EvaluateExpression('foo != nullptr', options)
75 self.assertTrue(val.IsValid())
76 self.assertFalse(val.GetError().Success())