qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: Gustavo Romero <gustavo.romero@linaro.org>,
	qemu-devel@nongnu.org, alex.bennee@linaro.org
Cc: peter.maydell@linaro.org
Subject: Re: [PATCH 2/2] tests/tcg: Add multiarch test for Xfer:siginfo:read stub
Date: Mon, 4 Mar 2024 07:21:57 -1000	[thread overview]
Message-ID: <e33ab9ae-e2d4-41ba-b053-e7e918572808@linaro.org> (raw)
In-Reply-To: <20240303192610.498490-2-gustavo.romero@linaro.org>

On 3/3/24 09:26, Gustavo Romero wrote:
> Add multiarch test for testing if Xfer:siginfo:read query is properly
> handled by gdbstub.
> 
> Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
> ---
>   tests/tcg/multiarch/Makefile.target           | 10 ++++++-
>   .../gdbstub/test-qxfer-siginfo-read.py        | 26 +++++++++++++++++++
>   tests/tcg/multiarch/segfault.c                | 14 ++++++++++
>   3 files changed, 49 insertions(+), 1 deletion(-)
>   create mode 100644 tests/tcg/multiarch/gdbstub/test-qxfer-siginfo-read.py
>   create mode 100644 tests/tcg/multiarch/segfault.c
> 
> diff --git a/tests/tcg/multiarch/Makefile.target b/tests/tcg/multiarch/Makefile.target
> index e10951a801..61cda9640e 100644
> --- a/tests/tcg/multiarch/Makefile.target
> +++ b/tests/tcg/multiarch/Makefile.target
> @@ -80,6 +80,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) \
> @@ -122,7 +129,8 @@ endif
>   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-catch-syscalls \
> +	      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)
> 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);
> +    }
> +}

Any reason SIGSEGV is interesting?
Perhaps just abort for SIGABRT instead?

A test using setitimer to raise SIGALRM would test the async path.


r~



  reply	other threads:[~2024-03-04 17:22 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-03 19:26 [PATCH 1/2] gdbstub: Add Xfer:siginfo:read stub Gustavo Romero
2024-03-03 19:26 ` [PATCH 2/2] tests/tcg: Add multiarch test for " Gustavo Romero
2024-03-04 17:21   ` Richard Henderson [this message]
2024-03-04 20:59     ` Gustavo Romero
2024-03-04 22:51       ` Richard Henderson
2024-03-07 17:50         ` Gustavo Romero
2024-03-07 19:31           ` Richard Henderson
2024-03-08 14:59             ` Gustavo Romero
2024-03-04 17:18 ` [PATCH 1/2] gdbstub: Add " Richard Henderson
2024-03-07 17:51   ` Gustavo Romero

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e33ab9ae-e2d4-41ba-b053-e7e918572808@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=alex.bennee@linaro.org \
    --cc=gustavo.romero@linaro.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).