2 Test calling user defined functions using expression evaluation.
5 LLDBs current first choice of evaluating functions is using the IR interpreter,
6 which is only supported on Hexagon. Otherwise JIT is used for the evaluation.
13 from lldbsuite.test.decorators import *
14 from lldbsuite.test.lldbtest import *
15 from lldbsuite.test import lldbutil
18 class ExprCommandCallUserDefinedFunction(TestBase):
20 mydir = TestBase.compute_mydir(__file__)
23 # Call super's setUp().
25 # Find the line number to break for main.c.
26 self.line = line_number(
28 '// Please test these expressions while stopped at this line:')
31 """Test return values of user defined function calls."""
34 # Set breakpoint in main and run exe
35 self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
36 lldbutil.run_break_set_by_file_and_line(
37 self, "main.cpp", self.line, num_expected_locations=-1, loc_exact=True)
39 self.runCmd("run", RUN_SUCCEEDED)
41 # Test recursive function call.
42 self.expect("expr fib(5)", substrs=['$0 = 5'])
44 # Test function with more than one paramter
45 self.expect("expr add(4,8)", substrs=['$1 = 12'])
47 # Test nesting function calls in function paramters
48 self.expect("expr add(add(5,2),add(3,4))", substrs=['$2 = 14'])
49 self.expect("expr add(add(5,2),fib(5))", substrs=['$3 = 12'])
51 # Test function with pointer paramter
53 "exp stringCompare((const char*) \"Hello world\")",
54 substrs=['$4 = true'])
56 "exp stringCompare((const char*) \"Hellworld\")",
57 substrs=['$5 = false'])