1""" 2Tests calling builtin functions using expression evaluation. 3""" 4 5 6 7import lldb 8from lldbsuite.test.decorators import * 9from lldbsuite.test.lldbtest import * 10from lldbsuite.test import lldbutil 11 12 13class ExprCommandCallBuiltinFunction(TestBase): 14 15 mydir = TestBase.compute_mydir(__file__) 16 17 # Builtins are expanded by Clang, so debug info shouldn't matter. 18 NO_DEBUG_INFO_TESTCASE = True 19 20 def setUp(self): 21 TestBase.setUp(self) 22 # Find the line number to break for main.c. 23 self.line = line_number( 24 'main.cpp', 25 '// Please test these expressions while stopped at this line:') 26 27 def test(self): 28 self.build() 29 30 # Set breakpoint in main and run exe 31 self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) 32 lldbutil.run_break_set_by_file_and_line( 33 self, "main.cpp", self.line, num_expected_locations=-1, loc_exact=True) 34 35 self.runCmd("run", RUN_SUCCEEDED) 36 37 # Test different builtin functions. 38 39 self.expect_expr("__builtin_isinf(0.0f)", result_type="int", result_value="0") 40 self.expect_expr("__builtin_isnormal(0.0f)", result_type="int", result_value="0") 41 self.expect_expr("__builtin_constant_p(1)", result_type="int", result_value="1") 42 self.expect_expr("__builtin_abs(-14)", result_type="int", result_value="14") 43