Browse Source
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>pull/264/head
committed by
Alex Bennée
3 changed files with 49 additions and 1 deletions
@ -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) |
|||
@ -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); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue