|
| 1 | +""" |
| 2 | +Test RISC-V expressions evaluation. |
| 3 | +""" |
| 4 | + |
| 5 | +import lldb |
| 6 | +from lldbsuite.test.decorators import * |
| 7 | +from lldbsuite.test.lldbtest import * |
| 8 | +from lldbsuite.test import lldbutil |
| 9 | + |
| 10 | + |
| 11 | +class TestExpressions(TestBase): |
| 12 | + def common_setup(self): |
| 13 | + self.build() |
| 14 | + lldbutil.run_to_source_breakpoint( |
| 15 | + self, "// break here", lldb.SBFileSpec("main.cpp") |
| 16 | + ) |
| 17 | + |
| 18 | + @skipIf(archs=no_match(["rv64gc"])) |
| 19 | + def test_int_arg(self): |
| 20 | + self.common_setup() |
| 21 | + self.expect_expr("foo(foo(5), foo())", result_type="int", result_value="8") |
| 22 | + |
| 23 | + @skipIf(archs=no_match(["rv64gc"])) |
| 24 | + def test_double_arg(self): |
| 25 | + self.common_setup() |
| 26 | + self.expect_expr( |
| 27 | + "func_with_double_arg(1, 6.5)", result_type="int", result_value="1" |
| 28 | + ) |
| 29 | + |
| 30 | + @skipIf(archs=no_match(["rv64gc"])) |
| 31 | + def test_ptr_arg(self): |
| 32 | + self.common_setup() |
| 33 | + self.expect_expr( |
| 34 | + 'func_with_ptr_arg("message")', result_type="int", result_value="2" |
| 35 | + ) |
| 36 | + |
| 37 | + @skipIf(archs=no_match(["rv64gc"])) |
| 38 | + def test_ptr_ret_val(self): |
| 39 | + self.common_setup() |
| 40 | + self.expect("expr func_with_ptr_return()", substrs=["global"]) |
| 41 | + |
| 42 | + @skipIf(archs=no_match(["rv64gc"])) |
| 43 | + def test_ptr(self): |
| 44 | + self.common_setup() |
| 45 | + self.expect( |
| 46 | + 'expr func_with_ptr("message")', |
| 47 | + substrs=["message"], |
| 48 | + ) |
| 49 | + |
| 50 | + @skipIf(archs=no_match(["rv64gc"])) |
| 51 | + def test_global_ptr(self): |
| 52 | + self.common_setup() |
| 53 | + self.expect( |
| 54 | + "expr func_with_ptr(g_str)", |
| 55 | + substrs=["global"], |
| 56 | + ) |
| 57 | + |
| 58 | + @skipIf(archs=no_match(["rv64gc"])) |
| 59 | + def test_struct_arg(self): |
| 60 | + self.common_setup() |
| 61 | + self.expect_expr( |
| 62 | + "func_with_struct_arg(s)", result_type="int", result_value="110" |
| 63 | + ) |
| 64 | + |
| 65 | + @skipIf(archs=no_match(["rv64gc"])) |
| 66 | + def test_unsupported_struct_arg(self): |
| 67 | + self.common_setup() |
| 68 | + self.expect_expr( |
| 69 | + "func_with_double_struct_arg(u)", result_type="int", result_value="400" |
| 70 | + ) |
| 71 | + |
| 72 | + @skipIf(archs=no_match(["rv64gc"])) |
| 73 | + def test_double_ret_val(self): |
| 74 | + self.common_setup() |
| 75 | + self.expect_expr( |
| 76 | + "func_with_double_return()", result_type="double", result_value="42" |
| 77 | + ) |
| 78 | + |
| 79 | + @skipIf(archs=no_match(["rv64gc"])) |
| 80 | + def test_struct_return(self): |
| 81 | + self.common_setup() |
| 82 | + self.expect_expr("func_with_struct_return()", result_type="S") |
| 83 | + |
| 84 | + @skipIf(archs=no_match(["rv64gc"])) |
| 85 | + def test_struct_double_ret_val(self): |
| 86 | + self.common_setup() |
| 87 | + self.expect_expr("func_with_double_struct_return()", result_type="U") |
| 88 | + |
| 89 | + @skipIf(archs=no_match(["rv64gc"])) |
| 90 | + def test_float_arg(self): |
| 91 | + self.common_setup() |
| 92 | + self.expect_expr( |
| 93 | + "func_with_float_arg(9.99, 8.88)", result_type="int", result_value="7" |
| 94 | + ) |
| 95 | + |
| 96 | + @skipIf(archs=no_match(["rv64gc"])) |
| 97 | + def test_float_ret_val(self): |
| 98 | + self.common_setup() |
| 99 | + self.expect_expr( |
| 100 | + "func_with_float_ret_val()", result_type="float", result_value="8" |
| 101 | + ) |
0 commit comments