[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 7/8] tests/tcg: Add multiarch test for Xfer:siginfo:read stub
From: |
Alex Bennée |
Subject: |
[PULL 7/8] tests/tcg: Add multiarch test for Xfer:siginfo:read stub |
Date: |
Tue, 12 Mar 2024 11:25:31 +0000 |
From: Gustavo Romero <gustavo.romero@linaro.org>
Add multiarch test for testing if Xfer:siginfo:read query is properly
handled by gdbstub.
Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20240309030901.1726211-6-gustavo.romero@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
diff --git a/tests/tcg/multiarch/segfault.c b/tests/tcg/multiarch/segfault.c
new file mode 100644
index 0000000000..e6c8ff31ca
--- /dev/null
+++ b/tests/tcg/multiarch/segfault.c
@@ -0,0 +1,14 @@
+#include <stdio.h>
+#include <string.h>
+
+/* Cause a segfault for testing purposes. */
+
+int main(int argc, char *argv[])
+{
+ int *ptr = (void *)0xdeadbeef;
+
+ if (argc == 2 && strcmp(argv[1], "-s") == 0) {
+ /* Cause segfault. */
+ printf("%d\n", *ptr);
+ }
+}
diff --git a/tests/tcg/multiarch/Makefile.target
b/tests/tcg/multiarch/Makefile.target
index 979a0dd1bc..5e3391ec9d 100644
--- a/tests/tcg/multiarch/Makefile.target
+++ b/tests/tcg/multiarch/Makefile.target
@@ -71,6 +71,13 @@ run-gdbstub-qxfer-auxv-read: sha1
--bin $< --test
$(MULTIARCH_SRC)/gdbstub/test-qxfer-auxv-read.py, \
basic gdbstub qXfer:auxv:read support)
+run-gdbstub-qxfer-siginfo-read: segfault
+ $(call run-test, $@, $(GDB_SCRIPT) \
+ --gdb $(GDB) \
+ --qemu $(QEMU) --qargs "$(QEMU_OPTS)" \
+ --bin "$< -s" --test
$(MULTIARCH_SRC)/gdbstub/test-qxfer-siginfo-read.py, \
+ basic gdbstub qXfer:siginfo:read support)
+
run-gdbstub-proc-mappings: sha1
$(call run-test, $@, $(GDB_SCRIPT) \
--gdb $(GDB) \
@@ -128,7 +135,8 @@ EXTRA_RUNS += run-gdbstub-sha1 run-gdbstub-qxfer-auxv-read \
run-gdbstub-proc-mappings run-gdbstub-thread-breakpoint \
run-gdbstub-registers run-gdbstub-prot-none \
run-gdbstub-catch-syscalls run-gdbstub-follow-fork-mode-child \
- run-gdbstub-follow-fork-mode-parent
+ run-gdbstub-follow-fork-mode-parent \
+ run-gdbstub-qxfer-siginfo-read
# ARM Compatible Semi Hosting Tests
#
diff --git a/tests/tcg/multiarch/gdbstub/test-qxfer-siginfo-read.py
b/tests/tcg/multiarch/gdbstub/test-qxfer-siginfo-read.py
new file mode 100644
index 0000000000..862596b07a
--- /dev/null
+++ b/tests/tcg/multiarch/gdbstub/test-qxfer-siginfo-read.py
@@ -0,0 +1,26 @@
+from __future__ import print_function
+#
+# Test gdbstub Xfer:siginfo:read stub.
+#
+# The test runs a binary that causes a SIGSEGV and then looks for additional
+# info about the signal through printing GDB's '$_siginfo' special variable,
+# which sends a Xfer:siginfo:read query to the gdbstub.
+#
+# The binary causes a SIGSEGV at dereferencing a pointer with value 0xdeadbeef,
+# so the test looks for and checks if this address is correctly reported by the
+# gdbstub.
+#
+# This is launched via tests/guest-debug/run-test.py
+#
+
+import gdb
+from test_gdbstub import main, report
+
+def run_test():
+ "Run through the test"
+
+ gdb.execute("continue", False, True)
+ resp = gdb.execute("print/x $_siginfo", False, True)
+ report(resp.find("si_addr = 0xdeadbeef"), "Found fault address.")
+
+main(run_test)
--
2.39.2
- [PULL for 9.0 0/8] final maintainer updates (testing, gdbstub), Alex Bennée, 2024/03/12
- [PULL 3/8] gdbstub: Rename back gdb_handlesig, Alex Bennée, 2024/03/12
- [PULL 1/8] gitlab: aggressively avoid extra GIT data, Alex Bennée, 2024/03/12
- [PULL 2/8] tests/vm: ensure we build everything by default, Alex Bennée, 2024/03/12
- [PULL 7/8] tests/tcg: Add multiarch test for Xfer:siginfo:read stub,
Alex Bennée <=
- [PULL 5/8] gdbstub: Save target's siginfo, Alex Bennée, 2024/03/12
- [PULL 6/8] gdbstub: Add Xfer:siginfo:read stub, Alex Bennée, 2024/03/12
- [PULL 8/8] gdbstub: Fix double close() of the follow-fork-mode socket, Alex Bennée, 2024/03/12
- [PULL 4/8] linux-user: Move tswap_siginfo out of target code, Alex Bennée, 2024/03/12
- Re: [PULL for 9.0 0/8] final maintainer updates (testing, gdbstub), Peter Maydell, 2024/03/12