diff options
| author | Ilya Leoshkevich <iii@linux.ibm.com> | 2024-02-07 16:38:12 +0000 |
|---|---|---|
| committer | Alex Bennée <alex.bennee@linaro.org> | 2024-02-09 17:52:40 +0000 |
| commit | 86b75667e04b49a0b75f061f589b3fbec3fb78f1 (patch) | |
| tree | 0c1e6df37dfb0c9a305ac5145318d6ea8339a1d7 /tests/tcg/multiarch/gdbstub/catch-syscalls.py | |
| parent | 046f143c51128d130fac8ed1ddda1bae33c4bb4b (diff) | |
| download | focaccia-qemu-86b75667e04b49a0b75f061f589b3fbec3fb78f1.tar.gz focaccia-qemu-86b75667e04b49a0b75f061f589b3fbec3fb78f1.zip | |
tests/tcg: Add the syscall catchpoint gdbstub test
Check that adding/removing syscall catchpoints works. Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> Message-Id: <20240202152506.279476-6-iii@linux.ibm.com> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20240207163812.3231697-15-alex.bennee@linaro.org>
Diffstat (limited to 'tests/tcg/multiarch/gdbstub/catch-syscalls.py')
| -rw-r--r-- | tests/tcg/multiarch/gdbstub/catch-syscalls.py | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/tcg/multiarch/gdbstub/catch-syscalls.py b/tests/tcg/multiarch/gdbstub/catch-syscalls.py new file mode 100644 index 0000000000..ccce35902f --- /dev/null +++ b/tests/tcg/multiarch/gdbstub/catch-syscalls.py @@ -0,0 +1,53 @@ +"""Test GDB syscall catchpoints. + +SPDX-License-Identifier: GPL-2.0-or-later +""" +from test_gdbstub import main, report + + +def check_state(expected): + """Check the catch_syscalls_state value""" + actual = gdb.parse_and_eval("catch_syscalls_state").string() + report(actual == expected, "{} == {}".format(actual, expected)) + + +def run_test(): + """Run through the tests one by one""" + gdb.Breakpoint("main") + gdb.execute("continue") + + # Check that GDB stops for pipe2/read calls/returns, but not for write. + gdb.execute("delete") + try: + gdb.execute("catch syscall pipe2 read") + except gdb.error as exc: + exc_str = str(exc) + if "not supported on this architecture" in exc_str: + print("SKIP: {}".format(exc_str)) + return + raise + for _ in range(2): + gdb.execute("continue") + check_state("pipe2") + for _ in range(2): + gdb.execute("continue") + check_state("read") + + # Check that deletion works. + gdb.execute("delete") + gdb.Breakpoint("end_of_main") + gdb.execute("continue") + check_state("end") + + # Check that catch-all works (libc should at least call exit). + gdb.execute("delete") + gdb.execute("catch syscall") + gdb.execute("continue") + gdb.execute("delete") + gdb.execute("continue") + + exitcode = int(gdb.parse_and_eval("$_exitcode")) + report(exitcode == 0, "{} == 0".format(exitcode)) + + +main(run_test) |