Skip to contentSkip to conversation

Revert "package/gdb: prevent gdbserver being selected for RISC-V builds"

PATCH New Vineet Gupta 3 participants 6 messages Dec 4, 2020 – Jan 5, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Revert "package/gdb: prevent gdbserver being selected for RISC-V builds"

This reverts commit 44a9babcc67cd011e957ba9fd1cf741891957c12.

As of Buildroot 2020.11 (glibc build of qemu_riscv64_virt_defconfig), cross-gdb for RISCV buildis fine and can also attach to a qemu instance, so remove the gate on not building it.

---
 package/gdb/Config.in      | 3 ---
 package/gdb/Config.in.host | 1 -
 2 files changed, 4 deletions(-)
package/gdb/Config.in +0 -3
index 48ec3e0202ac..c90d47cf0de6 100644
@@ -20,8 +20,6 @@ config BR2_PACKAGE_GDB
 	depends on BR2_PACKAGE_GDB_ARCH_SUPPORTS
 	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_8
 	depends on BR2_INSTALL_LIBSTDCPP
-	# no gdbserver on riscv
-	select BR2_PACKAGE_GDB_DEBUGGER if BR2_riscv
 	# When the external toolchain gdbserver is copied to the
 	# target, we don't allow building a separate gdbserver. The
 	# one from the external toolchain should be used.
@@ -48,7 +46,6 @@ if BR2_PACKAGE_GDB
 config BR2_PACKAGE_GDB_SERVER
 	bool "gdbserver"
 	depends on !BR2_TOOLCHAIN_EXTERNAL_GDB_SERVER_COPY
-	depends on !BR2_riscv
 	help
 	  Build the gdbserver stub to run on the target.
 	  A full gdb is needed to debug the progam.
package/gdb/Config.in.host +0 -1
index 4b868e22556b..199f1c72b001 100644
@@ -5,7 +5,6 @@ config BR2_PACKAGE_HOST_GDB_ARCH_SUPPORTS
 	depends on !BR2_microblaze
 	depends on !BR2_nios2
 	depends on !BR2_or1k
-	depends on !BR2_riscv
 	depends on !BR2_nds32
 
 comment "Host GDB Options"
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/1 Revert "package/gdb: prevent gdbserver being selected for RISC-V builds"

Hello,

Quoted 5 lines · On Thu, 3 Dec 2020 17:45:49 -0800 Vineet Gupta <[email protected]>…

This reverts commit 44a9babcc67cd011e957ba9fd1cf741891957c12.

As of Buildroot 2020.11 (glibc build of qemu_riscv64_virt_defconfig), cross-gdb for RISCV buildis fine and can also attach to a qemu instance, so remove the gate on not building it.

Is this true for all gdb versions we support ? We currently support 8.2, 8.3 and 9.2.

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#2 lore raw

PATCH 1/1 Revert "package/gdb: prevent gdbserver being selected for RISC-V builds"

Hi Thomas,

Quoted 5 lines · Thomas Petazzoni

Hello,

On Thu, 3 Dec 2020 17:45:49 -0800
Vineet Gupta <[email protected]> wrote:

Quoted 7 lines
Quoted 5 lines

This reverts commit 44a9babcc67cd011e957ba9fd1cf741891957c12.

As of Buildroot 2020.11 (glibc build of qemu_riscv64_virt_defconfig), cross-gdb for RISCV buildis fine and can also attach to a qemu instance, so remove the gate on not building it.

Is this true for all gdb versions we support ? We currently support 8.2, 8.3 and 9.2.

My working setup has gdb 8.3 and I just tested 8.2 works well too - I'm guessing 9.2 should be fine.

riscv64-softmmu/qemu-system-riscv64 -M virt -nographic -bios images/fw_jump.elf? -kernel images/Image? -append "root=/dev/vda ro"? -drive file=images/rootfs.ext2,format=raw,id=hd0 -device virtio-blk-device,drive=hd0? -netdev user,id=net0 -device virtio-net-device,netdev=net0 -s -S

./host/usr/bin/riscv64-linux-gdb
GNU gdb (GDB) 8.2.1
Copyright (C) 2018 Free Software Foundation, Inc.
(gdb) file build/linux-5.4.58/vmlinux

(gdb) b start_kernel
Breakpoint 1 at 0xffffffe00000070e

(gdb) target remote :1234
Remote debugging using :1234
warning: Target-supplied registers are not supported by the current architecture
0x0000000000001000 in ?? ()
(gdb) c
Continuing.

Breakpoint 1, 0xffffffe00000070c in start_kernel () (gdb) si
0xffffffe00000070e in start_kernel ()

-Vineet

#3 lore raw

PATCH 1/1 Revert "package/gdb: prevent gdbserver being selected for RISC-V builds"

In reply to Vineet Gupta
Quoted 8 lines · Vineet Gupta

This reverts commit 44a9babcc67cd011e957ba9fd1cf741891957c12.

As of Buildroot 2020.11 (glibc build of qemu_riscv64_virt_defconfig), cross-gdb for RISCV buildis fine and can also attach to a qemu instance, so remove the gate on not building it.

Alistair

Quoted 45 lines
---
 package/gdb/Config.in      | 3 ---
 package/gdb/Config.in.host | 1 -
 2 files changed, 4 deletions(-)
package/gdb/Config.in +0 -3
index 48ec3e0202ac..c90d47cf0de6 100644
@@ -20,8 +20,6 @@ config BR2_PACKAGE_GDB
        depends on BR2_PACKAGE_GDB_ARCH_SUPPORTS
        depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_8
        depends on BR2_INSTALL_LIBSTDCPP
-       # no gdbserver on riscv
-       select BR2_PACKAGE_GDB_DEBUGGER if BR2_riscv
        # When the external toolchain gdbserver is copied to the
        # target, we don't allow building a separate gdbserver. The
        # one from the external toolchain should be used.
@@ -48,7 +46,6 @@ if BR2_PACKAGE_GDB
 config BR2_PACKAGE_GDB_SERVER
        bool "gdbserver"
        depends on !BR2_TOOLCHAIN_EXTERNAL_GDB_SERVER_COPY
-       depends on !BR2_riscv
        help
          Build the gdbserver stub to run on the target.
          A full gdb is needed to debug the progam.
package/gdb/Config.in.host +0 -2
index 4b868e22556b..199f1c72b001 100644
@@ -5,7 +5,6 @@ config BR2_PACKAGE_HOST_GDB_ARCH_SUPPORTS
        depends on !BR2_microblaze
        depends on !BR2_nios2
        depends on !BR2_or1k
-       depends on !BR2_riscv
        depends on !BR2_nds32
 
 comment "Host GDB Options"
--

2.25.1

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

#4 lore raw

PATCH 1/1 Revert "package/gdb: prevent gdbserver being selected for RISC-V builds"

In reply to Vineet Gupta

Hello,

Quoted 7 lines · On Thu, 3 Dec 2020 17:45:49 -0800 Vineet Gupta <[email protected]>…

This reverts commit 44a9babcc67cd011e957ba9fd1cf741891957c12.

As of Buildroot 2020.11 (glibc build of qemu_riscv64_virt_defconfig), cross-gdb for RISCV buildis fine and can also attach to a qemu instance, so remove the gate on not building it.

I am sorry, but I don't see how this can work. RISC-V support in gdbserver was only added in upstream gdb in commit bf84f7066626c78884436e1c39fb60f04c665f21, which first appeared in gdb 10.1.

And indeed, when I build:

BR2_riscv=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y BR2_TOOLCHAIN_EXTERNAL_URL="http://autobuild.buildroot.net/toolchains/tarballs/br-riscv64-musl-2020.02.tar.bz2" BR2_TOOLCHAIN_EXTERNAL_GCC_9=y
BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_19=y
BR2_TOOLCHAIN_EXTERNAL_CUSTOM_MUSL=y
BR2_TOOLCHAIN_EXTERNAL_CXX=y
BR2_PACKAGE_HOST_GDB=y
BR2_INIT_NONE=y
BR2_SYSTEM_BIN_SH_NONE=y
# BR2_PACKAGE_BUSYBOX is not set
BR2_PACKAGE_GDB=y
# BR2_TARGET_ROOTFS_TAR is not set

It fails to build gdbserver, with:

Error: target not supported by gdbserver.

However, if I build:

BR2_riscv=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y BR2_TOOLCHAIN_EXTERNAL_URL="http://autobuild.buildroot.net/toolchains/tarballs/br-riscv64-musl-2020.02.tar.bz2" BR2_TOOLCHAIN_EXTERNAL_GCC_9=y
BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_19=y
BR2_TOOLCHAIN_EXTERNAL_CUSTOM_MUSL=y
BR2_TOOLCHAIN_EXTERNAL_CXX=y
BR2_PACKAGE_HOST_GDB=y
BR2_GDB_VERSION_10=y
BR2_INIT_NONE=y
BR2_SYSTEM_BIN_SH_NONE=y
# BR2_PACKAGE_BUSYBOX is not set
BR2_PACKAGE_GDB=y
# BR2_TARGET_ROOTFS_TAR is not set

which uses gdb 10.x, then indeed, the gdbserver configure script recognizes RISC-V as a supported CPU architecture, but it fails to build with:

../../gdbserver/linux-riscv-low.cc: In function ?void riscv_fill_fpregset(regcache*, void*)?:
../../gdbserver/linux-riscv-low.cc:140:19: error: ?ELF_NFPREG? was not declared in this scope; did you mean ?ELF_NGREG??

  140 |   for (i = 0; i < ELF_NFPREG - 1; i++, regbuf += flen)
      |                   ^~~~~~~~~~
      |                   ELF_NGREG
../../gdbserver/linux-riscv-low.cc: In function ?void riscv_store_fpregset(regcache*, const void*)?:
../../gdbserver/linux-riscv-low.cc:156:19: error: ?ELF_NFPREG? was not declared in this scope; did you mean ?ELF_NGREG??
  156 |   for (i = 0; i < ELF_NFPREG - 1; i++, regbuf += flen)
      |                   ^~~~~~~~~~
      |                   ELF_NGREG

Note: this is with a musl toolchain, it is possible that it builds fine with a glibc toolchain.

But regardless of that, RISC-V support in gdbserver only appeared in gdb 10.x, so I don't see how your patch could have worked, as we only introduced gdb 10.x support in Buildroot yesterday.

Could you clarify ?

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#5 lore raw

PATCH 1/1 Revert "package/gdb: prevent gdbserver being selected for RISC-V builds"

Hi Thomas,

Quoted 73 lines · Thomas Petazzoni

Hello,

Quoted 7 lines · On Thu, 3 Dec 2020 17:45:49 -0800 Vineet Gupta<[email protected]>…

This reverts commit 44a9babcc67cd011e957ba9fd1cf741891957c12.

As of Buildroot 2020.11 (glibc build of qemu_riscv64_virt_defconfig), cross-gdb for RISCV buildis fine and can also attach to a qemu instance, so remove the gate on not building it.

I am sorry, but I don't see how this can work. RISC-V support in gdbserver was only added in upstream gdb in commit bf84f7066626c78884436e1c39fb60f04c665f21, which first appeared in gdb 10.1.

And indeed, when I build:

BR2_riscv=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y BR2_TOOLCHAIN_EXTERNAL_URL="https://urldefense.com/v3/__http://autobuild.buildroot.net/toolchains/tarballs/br-riscv64-musl-2020.02.tar.bz2__;!!A4F2R9G_pg!IMmgVQqsgsBbM7Snzr0Ck153bU3q4JemVARBT3hfaRonq8Vy9HduoagpFw94R_gCUN_sqw$ "
BR2_TOOLCHAIN_EXTERNAL_GCC_9=y
BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_19=y
BR2_TOOLCHAIN_EXTERNAL_CUSTOM_MUSL=y
BR2_TOOLCHAIN_EXTERNAL_CXX=y
BR2_PACKAGE_HOST_GDB=y
BR2_INIT_NONE=y
BR2_SYSTEM_BIN_SH_NONE=y
# BR2_PACKAGE_BUSYBOX is not set
BR2_PACKAGE_GDB=y
# BR2_TARGET_ROOTFS_TAR is not set

It fails to build gdbserver, with:

Error: target not supported by gdbserver.

However, if I build:

BR2_riscv=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y BR2_TOOLCHAIN_EXTERNAL_URL="https://urldefense.com/v3/__http://autobuild.buildroot.net/toolchains/tarballs/br-riscv64-musl-2020.02.tar.bz2__;!!A4F2R9G_pg!IMmgVQqsgsBbM7Snzr0Ck153bU3q4JemVARBT3hfaRonq8Vy9HduoagpFw94R_gCUN_sqw$ "
BR2_TOOLCHAIN_EXTERNAL_GCC_9=y
BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_19=y
BR2_TOOLCHAIN_EXTERNAL_CUSTOM_MUSL=y
BR2_TOOLCHAIN_EXTERNAL_CXX=y
BR2_PACKAGE_HOST_GDB=y
BR2_GDB_VERSION_10=y
BR2_INIT_NONE=y
BR2_SYSTEM_BIN_SH_NONE=y
# BR2_PACKAGE_BUSYBOX is not set
BR2_PACKAGE_GDB=y
# BR2_TARGET_ROOTFS_TAR is not set

which uses gdb 10.x, then indeed, the gdbserver configure script recognizes RISC-V as a supported CPU architecture, but it fails to build with:

../../gdbserver/linux-riscv-low.cc: In function ?void riscv_fill_fpregset(regcache*, void*)?:
../../gdbserver/linux-riscv-low.cc:140:19: error: ?ELF_NFPREG? was not declared in this scope; did you mean ?ELF_NGREG??

   140 |   for (i = 0; i < ELF_NFPREG - 1; i++, regbuf += flen)
       |                   ^~~~~~~~~~
       |                   ELF_NGREG
../../gdbserver/linux-riscv-low.cc: In function ?void riscv_store_fpregset(regcache*, const void*)?:
../../gdbserver/linux-riscv-low.cc:156:19: error: ?ELF_NFPREG? was not declared in this scope; did you mean ?ELF_NGREG??
   156 |   for (i = 0; i < ELF_NFPREG - 1; i++, regbuf += flen)
       |                   ^~~~~~~~~~
       |                   ELF_NGREG
Quoted 8 lines

Note: this is with a musl toolchain, it is possible that it builds fine with a glibc toolchain.

But regardless of that, RISC-V support in gdbserver only appeared in gdb 10.x, so I don't see how your patch could have worked, as we only introduced gdb 10.x support in Buildroot yesterday.

Could you clarify ?

I never tried building gdbserver. My mistake was doing a full revert of the commit 44a9babcc67cd01.? I only needed the following change to get host gdb working for riscv

package/gdb/Config.in.host +0 -1
@@ -7,6 +7,7 @@ config BR2_PACKAGE_HOST_GDB_ARCH_SUPPORTS
-?????? depends on !BR2_riscv
 

In the end my config had following GDB related items:

BR2_PACKAGE_GDB_ARCH_SUPPORTS=y
BR2_PACKAGE_GDB=y
# BR2_PACKAGE_GDB_SERVER is not set
BR2_PACKAGE_GDB_DEBUGGER=y
# BR2_PACKAGE_GDB_TUI is not set

And with that I got the host gdb to build and actually connect to qemu which I captured in [1]

As for the issue at hand, guess the patch needs to be adjusted to not touch gdbserver fragment. Or perhaps it is all moot point now given enabling gdbserver would do that anyways (or already did).

Thx,
-Vineet

[1] http://lists.busybox.net/pipermail/buildroot/2020-December/297825.html