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"])
10 compiler
="clang", bugnumber
="clang does not emit .debug_macro[.dwo] sections."
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")
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
):
25 # Get main source file
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")
40 result
.IsValid() and result
.GetValue() == "100", "MACRO_1 = 100"
43 result
= frame
.EvaluateExpression("MACRO_2")
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")
62 result
.IsValid() and result
.GetValue() == "100", "HUNDRED = 100"
65 result
= frame
.EvaluateExpression("THOUSAND")
67 result
.IsValid() and result
.GetValue() == "1000", "THOUSAND = 1000"
70 result
= frame
.EvaluateExpression("MILLION")
72 result
.IsValid() and result
.GetValue() == "1000000", "MILLION = 1000000"
75 result
= frame
.EvaluateExpression("MAX(ONE, TWO)")
77 result
.IsValid() and result
.GetValue() == "2", "MAX(ONE, TWO) = 2"
80 result
= frame
.EvaluateExpression("MAX(THREE, TWO)")
82 result
.IsValid() and result
.GetValue() == "3", "MAX(THREE, TWO) = 3"
85 # Get the thread of the process
88 # Get frame for current thread
89 frame
= thread
.GetSelectedFrame()
91 result
= frame
.EvaluateExpression("MACRO_2")
93 result
.GetError().Fail(), "Printing MACRO_2 fails in the mail file"
96 result
= frame
.EvaluateExpression("FOUR")
98 result
.GetError().Fail(), "Printing FOUR fails in the main file"
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)")
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")
117 result
.GetError().Fail(), "Printing MACRO_1 fails in the header file"
120 result
= frame
.EvaluateExpression("MACRO_2")
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()))