|
| 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( |
| 27 | + "expr func_with_double_arg(1, 6.5)", |
| 28 | + error=True, |
| 29 | + substrs=["Architecture passes failure on function $__lldb_expr"], |
| 30 | + ) |
| 31 | + |
| 32 | + @skipIf(archs=no_match(["rv64gc"])) |
| 33 | + def test_ptr_arg(self): |
| 34 | + self.common_setup() |
| 35 | + self.expect_expr("func_with_ptr_arg(\"message\")", result_type="int", result_value="2") |
| 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("func_with_struct_arg(s)", result_type="int", result_value="3") |
| 62 | + |
| 63 | + @skipIf(archs=no_match(["rv64gc"])) |
| 64 | + def test_unsupported_struct_arg(self): |
| 65 | + self.common_setup() |
| 66 | + self.expect( |
| 67 | + "expr func_with_unsupported_struct_arg(u)", |
| 68 | + error=True, |
| 69 | + substrs=["Architecture passes failure on function $__lldb_expr"], |
| 70 | + ) |
| 71 | + |
| 72 | + @skipIf(archs=no_match(["rv64gc"])) |
| 73 | + def test_double_ret_val(self): |
| 74 | + self.common_setup() |
| 75 | + |
| 76 | + self.expect( |
| 77 | + "expr func_with_double_return()", |
| 78 | + error=True, |
| 79 | + substrs=["Architecture passes failure on function $__lldb_expr"], |
| 80 | + ) |
| 81 | + |
| 82 | + @skipIf(archs=no_match(["rv64gc"])) |
| 83 | + def test_struct_return(self): |
| 84 | + self.common_setup() |
| 85 | + self.expect_expr("func_with_struct_return()", result_type="S") |
| 86 | + |
| 87 | + @skipIf(archs=no_match(["rv64gc"])) |
| 88 | + def test_ptr_ret_val(self): |
| 89 | + self.common_setup() |
| 90 | + self.expect( |
| 91 | + "expr func_with_unsupported_struct_return()", |
| 92 | + error=True, |
| 93 | + substrs=["Architecture passes failure on function $__lldb_expr"], |
| 94 | + ) |
0 commit comments