foss-for-synopsys-dwc-arc-processors / qemu

QEMU port for ARCv2 Processors
Other
12 stars 9 forks source link

gdbserver hangs on ARC HS3x/4x Linux targets #213

Open kolerov opened 2 months ago

kolerov commented 2 months ago

A sample program:

#include <stdio.h>

int main()
{
        printf("Hello, World!\n");
        return 0;
}

First, build Linux image using Buildroot, arc-2023.09 branch (don't forget to select building GDB in toolchain's configuration and then gdbserver package itself). I did it in build-hs4x-glibc subdirectory of Buildroot source tree. Then run Linux image using QEMU:

qemu-system-arc -M virt -cpu archs -m 2G -kernel images/vmlinux \
                -display none -nographic -monitor none \
                -device virtio-rng-pci \
                -netdev user,id=net0,hostfwd=tcp::2022-:22,hostfwd=tcp::12345-:12345 \
                -device virtio-net-device,netdev=net0

Run gdbserver on target:

# gdbserver :12345 main-hs4x-glibc

Run GDB:

$ ./build-hs4x-glibc/host/bin/arc-buildroot-linux-gnu-gdb -q \
        -ex "set sysroot build-hs4x-glibc/host/arc-buildroot-linux-gnu/sysroot" \
        -ex "target remote :12345" \
        overlay/root/main-hs4x-glibc
Reading symbols from overlay/root/main-hs4x-glibc...
Remote debugging using :12345
Reading symbols from build-hs4x-glibc/host/arc-buildroot-linux-gnu/sysroot/lib/ld-linux-arc.so.2...
0x2000d47c in __start () from build-hs4x-glibc/host/arc-buildroot-linux-gnu/sysroot/lib/ld-linux-arc.so.2
(gdb) b main
Breakpoint 1 at 0x40000540: file main.c, line 5.
(gdb) c
Continuing.

gdbserver output:

Process /root/main-hs4x-glibc created; pid = 96
Listening on port 12345
Remote debugging from host 10.0.2.2, port 34430

Then nothing happens. Sometimes that issue does not happen, but in most cases it does. The same issue does not happen on ARCv3 targets.

kolerov commented 2 months ago

Cannot reproduce this issue when building an image using a prebuilt 2024.06 toolchain.