199451b44SJordan Rupprecht""" 299451b44SJordan RupprechtTest calling user defined functions using expression evaluation. 399451b44SJordan Rupprecht 499451b44SJordan RupprechtNote: 599451b44SJordan Rupprecht LLDBs current first choice of evaluating functions is using the IR interpreter, 699451b44SJordan Rupprecht which is only supported on Hexagon. Otherwise JIT is used for the evaluation. 799451b44SJordan Rupprecht 899451b44SJordan Rupprecht""" 999451b44SJordan Rupprecht 1099451b44SJordan Rupprechtimport lldb 1199451b44SJordan Rupprechtfrom lldbsuite.test.decorators import * 1299451b44SJordan Rupprechtfrom lldbsuite.test.lldbtest import * 1399451b44SJordan Rupprechtfrom lldbsuite.test import lldbutil 1499451b44SJordan Rupprecht 1599451b44SJordan Rupprechtclass ExprCommandCallUserDefinedFunction(TestBase): 1699451b44SJordan Rupprecht 1799451b44SJordan Rupprecht mydir = TestBase.compute_mydir(__file__) 1899451b44SJordan Rupprecht 1999451b44SJordan Rupprecht def test(self): 2099451b44SJordan Rupprecht """Test return values of user defined function calls.""" 2199451b44SJordan Rupprecht self.build() 22*edb0efcaSRaphael Isemann lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.cpp")) 2399451b44SJordan Rupprecht 2499451b44SJordan Rupprecht # Test recursive function call. 2599451b44SJordan Rupprecht self.expect_expr("fib(5)", result_type="unsigned int", result_value="5") 2699451b44SJordan Rupprecht 2799451b44SJordan Rupprecht # Test function with more than one paramter 2899451b44SJordan Rupprecht self.expect_expr("add(4, 8)", result_type="int", result_value="12") 2999451b44SJordan Rupprecht 3099451b44SJordan Rupprecht # Test nesting function calls in function paramters 3199451b44SJordan Rupprecht self.expect_expr("add(add(5,2),add(3,4))", result_type="int", result_value="14") 3299451b44SJordan Rupprecht self.expect_expr("add(add(5,2),fib(5))", result_type="int", result_value="12") 3399451b44SJordan Rupprecht 3499451b44SJordan Rupprecht # Test function with pointer paramter 3599451b44SJordan Rupprecht self.expect_expr('stringCompare((const char*) \"Hello world\")', result_type="bool", result_value="true") 3699451b44SJordan Rupprecht self.expect_expr('stringCompare((const char*) \"Hellworld\")', result_type="bool", result_value="false") 37