44627990d2f850265f1afd453afe27fa3e2e9f5d
[openbsd] /
1 """
2 Tests calling builtin functions using expression evaluation.
3 """
4
5
6
7 import lldb
8 from lldbsuite.test.decorators import *
9 from lldbsuite.test.lldbtest import *
10 from lldbsuite.test import lldbutil
11
12
13 class 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         interp = self.dbg.GetCommandInterpreter()
38         result = lldb.SBCommandReturnObject()
39
40         # Test different builtin functions.
41
42         self.expect_expr("__builtin_isinf(0.0f)", result_type="int", result_value="0")
43         self.expect_expr("__builtin_isnormal(0.0f)", result_type="int", result_value="0")
44         self.expect_expr("__builtin_constant_p(1)", result_type="int", result_value="1")
45         self.expect_expr("__builtin_abs(-14)", result_type="int", result_value="14")