QEMU gdbstub does not report SIGALRM

For QEMU build of aarch64 linux-user (v8.2.0-2115-g8f6330a8) and configured this way:

gromero@amd:~/git/qemu/build$ ../configure --target-list=aarch64-linux-user --enable-debug --disable-docs

... and running the following binary that triggers a SIGALRM:

gromero@arm64:~$ cat sigalrm.c 
#include <unistd.h>

int main(int argc, char *argv[])
{
   ualarm(1, 0);
   while(1) ; 
}

gromero@arm64:~$ gcc -static sigalrm.c -o sigalrm

... driven remotely by GDB:

gromero@arm64:~$ gdb -q 
(gdb) target remote amd:1234
Remote debugging using amd:1234
Reading /home/gromero/git/qemu/build/sigalrm from remote target...
warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead.
Reading /home/gromero/git/qemu/build/sigalrm from remote target...
Reading symbols from target:/home/gromero/git/qemu/build/sigalrm...
Reading /usr/lib/debug/.build-id/02/8510a65d70b3d9965caf338dbc69e806421b99.debug from remote target...
(No debugging symbols found in target:/home/gromero/git/qemu/build/sigalrm)
Failed to read a valid object file image from memory.
0x0000000000400580 in _start ()
(gdb) catch signal SIGALRM
Catchpoint 1 (signal SIGALRM)
(gdb) c
Continuing.
Remote connection closed
(gdb) 

... it does not report SIGALRM correctly to GDB. The connection is closed and no SIGALRM is reported to GDB.

QEMU reports a SIGALRM was generated on the gdbstub side:

gromero@amd:~/git/qemu/build$ ./qemu-aarch64 -g 1234 ./sigalrm
Alarm clock
gromero@amd:~/git/qemu/build$ 

This result is not what is expected. The result should be the same as for a local target. For example, this is the result of running the very same binary locally, on Linux:

gromero@arm64:~$ gdb -q ./sigalrm
Reading symbols from ./sigalrm...
(No debugging symbols found in ./sigalrm)
(gdb) catch signal SIGALRM 
Catchpoint 1 (signal SIGALRM)
(gdb) run
Starting program: /home/gromero/sigalrm 

Catchpoint 1 (signal SIGALRM), 0x000000000040a514 in ualarm ()
(gdb) quit

So, for the remote target, QEMU gdbstub should report back SIGALRM to GDB so GDB can catch the signal and not close the connection silently.

Edited by Gustavo Romero