[AMDGPU] Add True16 register classes.
[llvm-project.git] / lldb / test / API / commands / expression / macros / TestMacros.py
blob45c1c644144d48b4ee35b42135be3cf73f718d7d
1 import lldb
2 from lldbsuite.test.decorators import *
3 from lldbsuite.test.lldbtest import *
4 from lldbsuite.test import lldbutil
7 class TestMacros(TestBase):
8 @skipIf(compiler="clang", compiler_version=["<", "9.0"])
9 @expectedFailureAll(
10 compiler="clang", bugnumber="clang does not emit .debug_macro[.dwo] sections."
12 @expectedFailureAll(
13 debug_info="dwo",
14 bugnumber="GCC produces multiple .debug_macro.dwo sections and the spec is unclear as to what it means",
16 @expectedFailureAll(hostoslist=["windows"], compiler="gcc", triple=".*-android")
17 @expectedFailureAll(
18 compiler="gcc",
19 compiler_version=["<", "5.1"],
20 bugnumber=".debug_macro was introduced in DWARF 5, GCC supports it since version 5.1",
22 def test_expr_with_macros(self):
23 self.build()
25 # Get main source file
26 src_file = "main.cpp"
27 hdr_file = "macro1.h"
28 src_file_spec = lldb.SBFileSpec(src_file)
29 self.assertTrue(src_file_spec.IsValid(), "Main source file")
31 (target, process, thread, bp1) = lldbutil.run_to_source_breakpoint(
32 self, "Break here", src_file_spec
35 # Get frame for current thread
36 frame = thread.GetSelectedFrame()
38 result = frame.EvaluateExpression("MACRO_1")
39 self.assertTrue(
40 result.IsValid() and result.GetValue() == "100", "MACRO_1 = 100"
43 result = frame.EvaluateExpression("MACRO_2")
44 self.assertTrue(
45 result.IsValid() and result.GetValue() == "200", "MACRO_2 = 200"
48 result = frame.EvaluateExpression("ONE")
49 self.assertTrue(result.IsValid() and result.GetValue() == "1", "ONE = 1")
51 result = frame.EvaluateExpression("TWO")
52 self.assertTrue(result.IsValid() and result.GetValue() == "2", "TWO = 2")
54 result = frame.EvaluateExpression("THREE")
55 self.assertTrue(result.IsValid() and result.GetValue() == "3", "THREE = 3")
57 result = frame.EvaluateExpression("FOUR")
58 self.assertTrue(result.IsValid() and result.GetValue() == "4", "FOUR = 4")
60 result = frame.EvaluateExpression("HUNDRED")
61 self.assertTrue(
62 result.IsValid() and result.GetValue() == "100", "HUNDRED = 100"
65 result = frame.EvaluateExpression("THOUSAND")
66 self.assertTrue(
67 result.IsValid() and result.GetValue() == "1000", "THOUSAND = 1000"
70 result = frame.EvaluateExpression("MILLION")
71 self.assertTrue(
72 result.IsValid() and result.GetValue() == "1000000", "MILLION = 1000000"
75 result = frame.EvaluateExpression("MAX(ONE, TWO)")
76 self.assertTrue(
77 result.IsValid() and result.GetValue() == "2", "MAX(ONE, TWO) = 2"
80 result = frame.EvaluateExpression("MAX(THREE, TWO)")
81 self.assertTrue(
82 result.IsValid() and result.GetValue() == "3", "MAX(THREE, TWO) = 3"
85 # Get the thread of the process
86 thread.StepOver()
88 # Get frame for current thread
89 frame = thread.GetSelectedFrame()
91 result = frame.EvaluateExpression("MACRO_2")
92 self.assertTrue(
93 result.GetError().Fail(), "Printing MACRO_2 fails in the mail file"
96 result = frame.EvaluateExpression("FOUR")
97 self.assertTrue(
98 result.GetError().Fail(), "Printing FOUR fails in the main file"
101 thread.StepInto()
103 # Get frame for current thread
104 frame = thread.GetSelectedFrame()
106 result = frame.EvaluateExpression("ONE")
107 self.assertTrue(result.IsValid() and result.GetValue() == "1", "ONE = 1")
109 result = frame.EvaluateExpression("MAX(ONE, TWO)")
110 self.assertTrue(
111 result.IsValid() and result.GetValue() == "2", "MAX(ONE, TWO) = 2"
114 # This time, MACRO_1 and MACRO_2 are not visible.
115 result = frame.EvaluateExpression("MACRO_1")
116 self.assertTrue(
117 result.GetError().Fail(), "Printing MACRO_1 fails in the header file"
120 result = frame.EvaluateExpression("MACRO_2")
121 self.assertTrue(
122 result.GetError().Fail(), "Printing MACRO_2 fails in the header file"
125 # Check that the macro definitions do not trigger bogus Clang
126 # diagnostics about macro redefinitions.
127 result = frame.EvaluateExpression("does_not_parse")
128 self.assertNotIn("macro redefined", str(result.GetError()))
129 self.assertNotIn("redefining builtin macro", str(result.GetError()))