[AMDGPU] Add True16 register classes.
[llvm-project.git] / lldb / test / API / commands / expression / options / TestExprOptions.py
blob6652c71083a958de69aa2ea8367f95baaab5edc2
1 """
2 Test expression command options.
4 Test cases:
6 o test_expr_options:
7 Test expression command options.
8 """
11 import lldb
12 import lldbsuite.test.lldbutil as lldbutil
13 from lldbsuite.test.decorators import *
14 from lldbsuite.test.lldbtest import *
17 class ExprOptionsTestCase(TestBase):
18 def setUp(self):
19 # Call super's setUp().
20 TestBase.setUp(self)
22 self.main_source = "main.cpp"
23 self.main_source_spec = lldb.SBFileSpec(self.main_source)
24 self.line = line_number("main.cpp", "// breakpoint_in_main")
25 self.exe = self.getBuildArtifact("a.out")
27 def test_expr_options(self):
28 """These expression command options should work as expected."""
29 self.build()
31 # Set debugger into synchronous mode
32 self.dbg.SetAsync(False)
34 (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
35 self, "// breakpoint_in_main", self.main_source_spec
38 frame = thread.GetFrameAtIndex(0)
39 options = lldb.SBExpressionOptions()
41 # test --language on C++ expression using the SB API's
43 # Make sure we can evaluate a C++11 expression.
44 val = frame.EvaluateExpression("foo != nullptr")
45 self.assertTrue(val.IsValid())
46 self.assertSuccess(val.GetError())
47 self.DebugSBValue(val)
49 # Make sure it still works if language is set to C++11:
50 options.SetLanguage(lldb.eLanguageTypeC_plus_plus_11)
51 val = frame.EvaluateExpression("foo != nullptr", options)
52 self.assertTrue(val.IsValid())
53 self.assertSuccess(val.GetError())
54 self.DebugSBValue(val)
56 # Make sure it fails if language is set to C:
57 options.SetLanguage(lldb.eLanguageTypeC)
58 val = frame.EvaluateExpression("foo != nullptr", options)
59 self.assertTrue(val.IsValid())
60 self.assertFalse(val.GetError().Success())
62 @skipIfDarwin
63 def test_expr_options_lang(self):
64 """These expression language options should work as expected."""
65 self.build()
67 # Set debugger into synchronous mode
68 self.dbg.SetAsync(False)
70 (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
71 self, "// breakpoint_in_main", self.main_source_spec
74 frame = thread.GetFrameAtIndex(0)
75 options = lldb.SBExpressionOptions()
77 # Make sure we can retrieve `id` variable if language is set to C++11:
78 options.SetLanguage(lldb.eLanguageTypeC_plus_plus_11)
79 val = frame.EvaluateExpression("id == 0", options)
80 self.assertTrue(val.IsValid())
81 self.assertSuccess(val.GetError())
82 self.DebugSBValue(val)
84 # Make sure we can't retrieve `id` variable if language is set to ObjC:
85 options.SetLanguage(lldb.eLanguageTypeObjC)
86 val = frame.EvaluateExpression("id == 0", options)
87 self.assertTrue(val.IsValid())
88 self.assertFalse(val.GetError().Success())