-
Notifications
You must be signed in to change notification settings - Fork 12.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[lldb][RISCV] add function calls tests
Function calls support in LLDB expressions for RISCV: 5 of 5 Adds tests on function calls inside lldb expressions
- Loading branch information
Showing
3 changed files
with
140 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
CXX_SOURCES := main.cpp | ||
|
||
include Makefile.rules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
""" | ||
Test RISC-V expressions evaluation. | ||
""" | ||
|
||
import lldb | ||
from lldbsuite.test.decorators import * | ||
from lldbsuite.test.lldbtest import * | ||
from lldbsuite.test import lldbutil | ||
|
||
|
||
class TestExpressions(TestBase): | ||
def common_setup(self): | ||
self.build() | ||
lldbutil.run_to_source_breakpoint( | ||
self, "// break here", lldb.SBFileSpec("main.cpp") | ||
) | ||
|
||
@skipIf(archs=no_match(["rv64gc"])) | ||
def test_int_arg(self): | ||
self.common_setup() | ||
self.expect_expr("foo(foo(5), foo())", result_type="int", result_value="8") | ||
|
||
@skipIf(archs=no_match(["rv64gc"])) | ||
def test_double_arg(self): | ||
self.common_setup() | ||
self.expect( | ||
"expr func_with_double_arg(1, 6.5)", | ||
error=True, | ||
substrs=["Architecture passes failure on function $__lldb_expr"], | ||
) | ||
|
||
@skipIf(archs=no_match(["rv64gc"])) | ||
def test_ptr_arg(self): | ||
self.common_setup() | ||
self.expect( | ||
'expr func_with_ptr_arg("bla")', | ||
error=True, | ||
substrs=["Architecture passes failure on function $__lldb_expr"], | ||
) | ||
|
||
@skipIf(archs=no_match(["rv64gc"])) | ||
def test_struct_arg(self): | ||
self.common_setup() | ||
self.expect_expr("func_with_struct_arg(s)", result_type="int", result_value="3") | ||
|
||
@skipIf(archs=no_match(["rv64gc"])) | ||
def test_unsupported_struct_arg(self): | ||
self.common_setup() | ||
self.expect( | ||
"expr func_with_unsupported_struct_arg(u)", | ||
error=True, | ||
substrs=["Architecture passes failure on function $__lldb_expr"], | ||
) | ||
|
||
@skipIf(archs=no_match(["rv64gc"])) | ||
def test_double_ret_val(self): | ||
self.common_setup() | ||
|
||
self.expect( | ||
"expr func_with_double_return()", | ||
error=True, | ||
substrs=["Architecture passes failure on function $__lldb_expr"], | ||
) | ||
|
||
@skipIf(archs=no_match(["rv64gc"])) | ||
def test_ptr_ret_val(self): | ||
self.common_setup() | ||
self.expect( | ||
"expr func_with_ptr_return()", | ||
error=True, | ||
substrs=["Architecture passes failure on function $__lldb_expr"], | ||
) | ||
|
||
@skipIf(archs=no_match(["rv64gc"])) | ||
def test_struct_return(self): | ||
self.common_setup() | ||
self.expect_expr("func_with_struct_return()", result_type="S") | ||
|
||
@skipIf(archs=no_match(["rv64gc"])) | ||
def test_ptr_ret_val(self): | ||
self.common_setup() | ||
self.expect( | ||
"expr func_with_unsupported_struct_return()", | ||
error=True, | ||
substrs=["Architecture passes failure on function $__lldb_expr"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
struct S { | ||
int a; | ||
int b; | ||
}; | ||
|
||
struct U { | ||
int a; | ||
double d; | ||
}; | ||
|
||
int g; | ||
|
||
int func_with_double_arg(int a, double b) { return 1; } | ||
|
||
int func_with_ptr_arg(char *msg) { return 2; } | ||
|
||
int func_with_struct_arg(struct S s) { return 3; } | ||
|
||
int func_with_unsupported_struct_arg(struct U u) { return 4; } | ||
|
||
double func_with_double_return() { return 42.0; } | ||
|
||
int *func_with_ptr_return() { return &g; } | ||
|
||
struct S func_with_struct_return() { | ||
struct S s = {3, 4}; | ||
return s; | ||
} | ||
|
||
struct U func_with_unsupported_struct_return() { | ||
struct U u = {3, 42.0}; | ||
return u; | ||
} | ||
|
||
int foo() { return 3; } | ||
|
||
int foo(int a) { return a; } | ||
|
||
int foo(int a, int b) { return a + b; } | ||
|
||
int main() { | ||
struct S s = {1, 2}; | ||
struct U u = {1, 1.0}; | ||
double d = func_with_double_arg(1, 1.0) + func_with_ptr_arg("msg") + | ||
func_with_struct_arg(s) + func_with_double_return() + | ||
func_with_unsupported_struct_arg(u) + foo() + foo(1) + foo(1, 2); | ||
int *ptr = func_with_ptr_return(); | ||
s = func_with_struct_return(); | ||
u = func_with_unsupported_struct_return(); | ||
return 0; // break here | ||
} |