Browse Source
Add a small test to prevent regressions. Make sure that host_interrupt_signal is not visible to the guest. Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> Message-Id: <20250117001542.8290-9-iii@linux.ibm.com> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20250207153112.3939799-18-alex.bennee@linaro.org>pull/281/head
committed by
Alex Bennée
4 changed files with 90 additions and 3 deletions
@ -0,0 +1,28 @@ |
|||
"""Test attaching GDB to a running process. |
|||
|
|||
SPDX-License-Identifier: GPL-2.0-or-later |
|||
""" |
|||
from test_gdbstub import main, report |
|||
|
|||
|
|||
def run_test(): |
|||
"""Run through the tests one by one""" |
|||
try: |
|||
phase = gdb.parse_and_eval("phase").string() |
|||
except gdb.error: |
|||
# Assume the guest did not reach main(). |
|||
phase = "start" |
|||
|
|||
if phase == "start": |
|||
gdb.execute("break sigwait") |
|||
gdb.execute("continue") |
|||
phase = gdb.parse_and_eval("phase").string() |
|||
report(phase == "sigwait", "{} == \"sigwait\"".format(phase)) |
|||
|
|||
gdb.execute("signal SIGUSR1") |
|||
|
|||
exitcode = int(gdb.parse_and_eval("$_exitcode")) |
|||
report(exitcode == 0, "{} == 0".format(exitcode)) |
|||
|
|||
|
|||
main(run_test) |
|||
@ -0,0 +1,41 @@ |
|||
/*
|
|||
* Test attaching GDB to a running process. |
|||
* |
|||
* SPDX-License-Identifier: GPL-2.0-or-later |
|||
*/ |
|||
#include <assert.h> |
|||
#include <signal.h> |
|||
#include <stdio.h> |
|||
#include <stdlib.h> |
|||
|
|||
static const char *phase = "start"; |
|||
|
|||
int main(void) |
|||
{ |
|||
sigset_t set; |
|||
int sig; |
|||
|
|||
assert(sigfillset(&set) == 0); |
|||
assert(sigprocmask(SIG_BLOCK, &set, NULL) == 0); |
|||
|
|||
/* Let GDB know it can send SIGUSR1. */ |
|||
phase = "sigwait"; |
|||
if (getenv("LATE_ATTACH_PY")) { |
|||
assert(sigwait(&set, &sig) == 0); |
|||
if (sig != SIGUSR1) { |
|||
fprintf(stderr, "Unexpected signal %d\n", sig); |
|||
return EXIT_FAILURE; |
|||
} |
|||
} |
|||
|
|||
/* Check that the guest does not see host_interrupt_signal. */ |
|||
assert(sigpending(&set) == 0); |
|||
for (sig = 1; sig < NSIG; sig++) { |
|||
if (sigismember(&set, sig)) { |
|||
fprintf(stderr, "Unexpected signal %d\n", sig); |
|||
return EXIT_FAILURE; |
|||
} |
|||
} |
|||
|
|||
return EXIT_SUCCESS; |
|||
} |
|||
Loading…
Reference in new issue