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.
10 from __future__ import print_function
15 from lldbsuite.test.decorators import *
16 from lldbsuite.test.lldbtest import *
17 from lldbsuite.test import lldbutil
19 class ExprCommandCallUserDefinedFunction(TestBase):
21 mydir = TestBase.compute_mydir(__file__)
24 # Call super's setUp().
26 # Find the line number to break for main.c.
27 self.line = line_number('main.cpp',
28 '// Please test these expressions while stopped at this line:')
29 @expectedFlakeyDsym("llvm.org/pr20274")
30 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24489: Name lookup not working correctly on Windows")
32 """Test return values of user defined function calls."""
35 # Set breakpoint in main and run exe
36 self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
37 lldbutil.run_break_set_by_file_and_line (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
52 self.expect("exp stringCompare((const char*) \"Hello world\")", substrs = ['$4 = true'])
53 self.expect("exp stringCompare((const char*) \"Hellworld\")", substrs = ['$5 = false'])