brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.5 KiB · 45c1c64 Raw
130 lines · python
1import lldb2from lldbsuite.test.decorators import *3from lldbsuite.test.lldbtest import *4from lldbsuite.test import lldbutil5 6 7class TestMacros(TestBase):8    @skipIf(compiler="clang", compiler_version=["<", "9.0"])9    @expectedFailureAll(10        compiler="clang", bugnumber="clang does not emit .debug_macro[.dwo] sections."11    )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",15    )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",21    )22    def test_expr_with_macros(self):23        self.build()24 25        # Get main source file26        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")30 31        (target, process, thread, bp1) = lldbutil.run_to_source_breakpoint(32            self, "Break here", src_file_spec33        )34 35        # Get frame for current thread36        frame = thread.GetSelectedFrame()37 38        result = frame.EvaluateExpression("MACRO_1")39        self.assertTrue(40            result.IsValid() and result.GetValue() == "100", "MACRO_1 = 100"41        )42 43        result = frame.EvaluateExpression("MACRO_2")44        self.assertTrue(45            result.IsValid() and result.GetValue() == "200", "MACRO_2 = 200"46        )47 48        result = frame.EvaluateExpression("ONE")49        self.assertTrue(result.IsValid() and result.GetValue() == "1", "ONE = 1")50 51        result = frame.EvaluateExpression("TWO")52        self.assertTrue(result.IsValid() and result.GetValue() == "2", "TWO = 2")53 54        result = frame.EvaluateExpression("THREE")55        self.assertTrue(result.IsValid() and result.GetValue() == "3", "THREE = 3")56 57        result = frame.EvaluateExpression("FOUR")58        self.assertTrue(result.IsValid() and result.GetValue() == "4", "FOUR = 4")59 60        result = frame.EvaluateExpression("HUNDRED")61        self.assertTrue(62            result.IsValid() and result.GetValue() == "100", "HUNDRED = 100"63        )64 65        result = frame.EvaluateExpression("THOUSAND")66        self.assertTrue(67            result.IsValid() and result.GetValue() == "1000", "THOUSAND = 1000"68        )69 70        result = frame.EvaluateExpression("MILLION")71        self.assertTrue(72            result.IsValid() and result.GetValue() == "1000000", "MILLION = 1000000"73        )74 75        result = frame.EvaluateExpression("MAX(ONE, TWO)")76        self.assertTrue(77            result.IsValid() and result.GetValue() == "2", "MAX(ONE, TWO) = 2"78        )79 80        result = frame.EvaluateExpression("MAX(THREE, TWO)")81        self.assertTrue(82            result.IsValid() and result.GetValue() == "3", "MAX(THREE, TWO) = 3"83        )84 85        # Get the thread of the process86        thread.StepOver()87 88        # Get frame for current thread89        frame = thread.GetSelectedFrame()90 91        result = frame.EvaluateExpression("MACRO_2")92        self.assertTrue(93            result.GetError().Fail(), "Printing MACRO_2 fails in the mail file"94        )95 96        result = frame.EvaluateExpression("FOUR")97        self.assertTrue(98            result.GetError().Fail(), "Printing FOUR fails in the main file"99        )100 101        thread.StepInto()102 103        # Get frame for current thread104        frame = thread.GetSelectedFrame()105 106        result = frame.EvaluateExpression("ONE")107        self.assertTrue(result.IsValid() and result.GetValue() == "1", "ONE = 1")108 109        result = frame.EvaluateExpression("MAX(ONE, TWO)")110        self.assertTrue(111            result.IsValid() and result.GetValue() == "2", "MAX(ONE, TWO) = 2"112        )113 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"118        )119 120        result = frame.EvaluateExpression("MACRO_2")121        self.assertTrue(122            result.GetError().Fail(), "Printing MACRO_2 fails in the header file"123        )124 125        # Check that the macro definitions do not trigger bogus Clang126        # 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()))130