Skip to contentSkip to conversation

gdb: convert to the package infrastructure

PATCH New Thomas Petazzoni 3 participants 9 messages Feb 26, 2013 – Mar 1, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gdb: convert to the package infrastructure

This commit converts gdb to the package infrastructure, and therefore moves it from toolchain/gdb to package/gdb.

The target package is now visible in "Package selection for the target" => "Debugging, profiling and benchmark". The main option, "gdb", forcefully selects the "gdbserver" sub-option by default. Another sub-option, "full debugger" allows to install the complete gdb on the target. When this option is enabled, then "gdbserver" is no longer forcefully selected. This ensures that at least gdbserver or the full debugger gets built/installed, so that the package is not a no-op.

The host debugger is still enabled through a configuration option in "Toolchain". It is now visible regardless of the toolchain type (it used to be hidden for External Toolchains). The configuration options relative to the host debugger are now in package/gdb/Config.in.host, similar to how we have package/binutils/Config.in.host.

---
It would be good to have a few people testing this before committing.

---
 Config.in.legacy                                   |   11 +
 package/Config.in                                  |    1 +
 .../gdb/6.6a/100-uclibc-conf.patch                 |    0
 .../gdb/6.6a/600-fix-compile-flag-mismatch.patch   |    0
 .../gdb/6.6a/gdb-6.6-bfin-gdbserver.patch          |    0
 .../gdb/7.4.1/00_all_ptrace_setsiginfo.patch       |    0
 .../gdb/7.4.1/05_all_readline-headers.patch        |    0
 .../gdb/7.4.1/xtensa-asm-ptrace-h.patch            |    0
 .../gdb/7.4.1/xtensa-gdb-regsize.patch             |    0
 package/gdb/Config.in                              |   38 ++++
 package/gdb/Config.in.host                         |   56 +++++
 package/gdb/gdb.mk                                 |  100 +++++++++
 toolchain/gdb/Config.in                            |   99 ---------
 toolchain/gdb/gdb.mk                               |  234 --------------------
 toolchain/toolchain-buildroot.mk                   |    1 -
 toolchain/toolchain-common.in                      |    2 +-
 toolchain/toolchain-crosstool-ng.mk                |    1 -
 toolchain/toolchain-external.mk                    |    1 -
 toolchain/toolchain-external/Config.in             |    7 +
 19 files changed, 214 insertions(+), 337 deletions(-)
 rename {toolchain => package}/gdb/6.6a/100-uclibc-conf.patch (100%)
 rename {toolchain => package}/gdb/6.6a/600-fix-compile-flag-mismatch.patch (100%)
 rename {toolchain => package}/gdb/6.6a/gdb-6.6-bfin-gdbserver.patch (100%)
 rename {toolchain => package}/gdb/7.4.1/00_all_ptrace_setsiginfo.patch (100%)
 rename {toolchain => package}/gdb/7.4.1/05_all_readline-headers.patch (100%)
 rename {toolchain => package}/gdb/7.4.1/xtensa-asm-ptrace-h.patch (100%)
 rename {toolchain => package}/gdb/7.4.1/xtensa-gdb-regsize.patch (100%)
 create mode 100644 package/gdb/Config.in
 create mode 100644 package/gdb/Config.in.host
 create mode 100644 package/gdb/gdb.mk
 delete mode 100644 toolchain/gdb/Config.in
 delete mode 100644 toolchain/gdb/gdb.mk
Config.in.legacy +11 -0
index d90132c..00654b5 100644
@@ -40,6 +40,17 @@ comment "As long as these options stay selected, the build   "
 comment "will fail.                                          "
 endif
 
+#
+# Legacy options since 2013.02
+#
+config BR2_PACKAGE_GDB_HOST
+	bool "gdb for the host option has been renamed"
+	select BR2_PACKAGE_HOST_GDB
+	select BR2_LEGACY
+	help
+	  Due to the conversion of gdb to the package infrastructure,
+	  the BR2_PACKAGE_GDB_HOST option has been renamed
+	  BR2_PACKAGE_HOST_GDB.
 
 #
 # Legacy options since 2012.11
package/Config.in +1 -0
index 2fad94d..3266c37 100644
@@ -22,6 +22,7 @@ source "package/cache-calibrator/Config.in"
 source "package/dhrystone/Config.in"
 source "package/dstat/Config.in"
 source "package/dmalloc/Config.in"
+source "package/gdb/Config.in"
 source "package/kexec/Config.in"
 source "package/latencytop/Config.in"
 source "package/lmbench/Config.in"
package/gdb/6.6a/100-uclibc-conf.patch renamed from toolchain/gdb/6.6a/100-uclibc-conf.patch +0 -0
similarity index 100%
rename from toolchain/gdb/6.6a/100-uclibc-conf.patch
rename to package/gdb/6.6a/100-uclibc-conf.patch
package/gdb/6.6a/600-fix-compile-flag-mismatch.patch renamed from toolchain/gdb/6.6a/600-fix-compile-flag-mismatch.patch +0 -0
similarity index 100%
rename from toolchain/gdb/6.6a/600-fix-compile-flag-mismatch.patch
rename to package/gdb/6.6a/600-fix-compile-flag-mismatch.patch
package/gdb/6.6a/gdb-6.6-bfin-gdbserver.patch renamed from toolchain/gdb/6.6a/gdb-6.6-bfin-gdbserver.patch +0 -0
similarity index 100%
rename from toolchain/gdb/6.6a/gdb-6.6-bfin-gdbserver.patch
rename to package/gdb/6.6a/gdb-6.6-bfin-gdbserver.patch
package/gdb/7.4.1/00_all_ptrace_setsiginfo.patch renamed from toolchain/gdb/7.4.1/00_all_ptrace_setsiginfo.patch +0 -0
similarity index 100%
rename from toolchain/gdb/7.4.1/00_all_ptrace_setsiginfo.patch
rename to package/gdb/7.4.1/00_all_ptrace_setsiginfo.patch
package/gdb/7.4.1/05_all_readline-headers.patch renamed from toolchain/gdb/7.4.1/05_all_readline-headers.patch +0 -0
similarity index 100%
rename from toolchain/gdb/7.4.1/05_all_readline-headers.patch
rename to package/gdb/7.4.1/05_all_readline-headers.patch
package/gdb/7.4.1/xtensa-asm-ptrace-h.patch renamed from toolchain/gdb/7.4.1/xtensa-asm-ptrace-h.patch +0 -0
similarity index 100%
rename from toolchain/gdb/7.4.1/xtensa-asm-ptrace-h.patch
rename to package/gdb/7.4.1/xtensa-asm-ptrace-h.patch
package/gdb/7.4.1/xtensa-gdb-regsize.patch renamed from toolchain/gdb/7.4.1/xtensa-gdb-regsize.patch +0 -0
similarity index 100%
rename from toolchain/gdb/7.4.1/xtensa-gdb-regsize.patch
rename to package/gdb/7.4.1/xtensa-gdb-regsize.patch
package/gdb/Config.in new file +38 -0
new file mode 100644
index 0000000..958a64a
@@ -0,0 +1,38 @@
+config BR2_PACKAGE_GDB
+	bool "gdb"
+	select BR2_PACKAGE_GDB_SERVER if !BR2_PACKAGE_GDB_DEBUGGER
+	help
+	  GDB, the GNU Project debugger, allows you to see what is
+	  going on `inside' another program while it executes -- or
+	  what another program was doing at the moment it crashed.
+
+	  This option allows to build gdbserver and/or the gdb
+	  debugger for the target.
+
+	  For embedded development, the most common solution is to
+	  build only 'gdbserver' for the target, and use a cross-gdb
+	  on the host. See BR2_PACKAGE_HOST_GDB to enable one.
+
+	  http://www.gnu.org/software/gdb/
+
+if BR2_PACKAGE_GDB
+
+config BR2_PACKAGE_GDB_SERVER
+	bool "gdbserver"
+	help
+	  Build the gdbserver stub to run on the target.
+	  A full gdb is needed to debug the progam.
+
+config BR2_PACKAGE_GDB_DEBUGGER
+	bool "full debugger"
+	select BR2_PACKAGE_NCURSES
+	depends on BR2_USE_WCHAR
+	depends on BR2_TOOLCHAIN_HAS_THREADS
+	depends on !BR2_sh && !BR2_sh64 && !BR2_avr32 && !BR2_microblaze && !BR2_bfin && !BR2_aarch64
+	depends on BR2_TOOLCHAIN_HAS_THREADS_DEBUG_IF_NEEDED
+	select BR2_PTHREAD_DEBUG if (BR2_TOOLCHAIN_BUILDROOT && !BR2_PTHREADS_NONE)
+
+comment "full gdb on target needs WCHAR and threads support in toolchain"
+	depends on !BR2_USE_WCHAR || !BR2_TOOLCHAIN_HAS_THREADS
+
+endif
package/gdb/Config.in.host new file +56 -0

56 lines not on this page · raw message

package/gdb/gdb.mk new file +100 -0

100 lines not on this page · raw message

toolchain/gdb/Config.in deleted +0 -99

99 lines not on this page · raw message

toolchain/gdb/gdb.mk deleted +0 -234

234 lines not on this page · raw message

toolchain/toolchain-buildroot.mk +0 -1
index adab0f7..5493177 100644
@@ -2,6 +2,5 @@
 
 include toolchain/elf2flt/elf2flt.mk
 include toolchain/gcc/gcc-uclibc-4.x.mk
-include toolchain/gdb/gdb.mk
 include toolchain/kernel-headers/kernel-headers.mk
 include toolchain/uClibc/uclibc.mk
toolchain/toolchain-common.in +1 -1
index f6905ae..8e69432 100644
@@ -3,7 +3,7 @@
 # we want gdb config in the middle of both source and external
 # toolchains, but mconf won't let us source the same file twice,
 # so put it here instead
-source "toolchain/gdb/Config.in"
+source "package/gdb/Config.in.host"
 
 config BR2_LARGEFILE
 	bool
toolchain/toolchain-crosstool-ng.mk +0 -1
index d677256..d1e7552 100644
@@ -4,6 +4,5 @@
 include toolchain/helpers.mk
 include toolchain/elf2flt/elf2flt.mk
 include toolchain/gcc/gcc-uclibc-4.x.mk
-include toolchain/gdb/gdb.mk
 include toolchain/toolchain-crosstool-ng/crosstool-ng.mk
 include toolchain/uClibc/uclibc.mk
toolchain/toolchain-external.mk +0 -1
index 4292d85..9999aa2 100644
@@ -3,7 +3,6 @@
 include toolchain/helpers.mk
 include toolchain/elf2flt/elf2flt.mk
 include toolchain/gcc/gcc-uclibc-4.x.mk
-include toolchain/gdb/gdb.mk
 include toolchain/kernel-headers/kernel-headers.mk
 include toolchain/toolchain-external/ext-tool.mk
 include toolchain/uClibc/uclibc.mk
toolchain/toolchain-external/Config.in +7 -0
index 5b26aa9..f28c999 100644
@@ -887,5 +887,12 @@ config BR2_TOOLCHAIN_EXTRA_EXTERNAL_LIBS
 
 endif # BR2_TOOLCHAIN_EXTERNAL_CUSTOM
 
+config BR2_TOOLCHAIN_EXTERNAL_GDB_SERVER_COPY
+	bool "Copy gdb server to the Target"
+	depends on BR2_TOOLCHAIN_EXTERNAL
+	help
+	  Copy the gdbserver provided by the external toolchain to the
+	  target.
+
 endif # BR2_TOOLCHAIN_EXTERNAL
 
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/1 gdb: convert to the package infrastructure

Quoted 12 lines · Thomas Petazzoni

This commit converts gdb to the package infrastructure, and therefore moves it from toolchain/gdb to package/gdb.

The target package is now visible in "Package selection for the target" => "Debugging, profiling and benchmark". The main option, "gdb", forcefully selects the "gdbserver" sub-option by default. Another sub-option, "full debugger" allows to install the complete gdb on the target. When this option is enabled, then "gdbserver" is no longer forcefully selected. This ensures that at least gdbserver or the full debugger gets built/installed, so that the package is not a no-op.

Quoted 7 lines

The host debugger is still enabled through a configuration option in "Toolchain". It is now visible regardless of the toolchain type (it used to be hidden for External Toolchains). The configuration options relative to the host debugger are now in package/gdb/Config.in.host, similar to how we have package/binutils/Config.in.host.

This looks like a great idea!

Just a couple of generic remarks, and then a few specific ones below.
The generic remarks are probably for follow-up patches.

* It really doesn't make sense to build host-gdb without a gdbserver for the target. So I would auto-select gdbserver from host-gdb.

* Does it really make sense to keep options for four different gdb versions? Can't we just remove the user-selectable version completely?

* Do gdb-7.2+ actually work for avr32? If yes, why keep the 6.7.1 around?

Quoted 2 lines

---
It would be good to have a few people testing this before committing.

Nah, just let the autobuilders do it :-)

[snip]

Quoted 10 lines
package/gdb/Config.in new file +4 -0
new file mode 100644
index 0000000..958a64a
@@ -0,0 +1,38 @@
+config BR2_PACKAGE_GDB
+	bool "gdb"
+	select BR2_PACKAGE_GDB_SERVER if !BR2_PACKAGE_GDB_DEBUGGER
+	help

package/gdb/Config.in line 14

Quoted 10 lines
package/gdb/Config.in new file +10 -0
+	  GDB, the GNU Project debugger, allows you to see what is
+	  going on `inside' another program while it executes -- or
+	  what another program was doing at the moment it crashed.
+
+	  This option allows to build gdbserver and/or the gdb
+	  debugger for the target.
+
+	  For embedded development, the most common solution is to
+	  build only 'gdbserver' for the target, and use a cross-gdb
+	  on the host. See BR2_PACKAGE_HOST_GDB to enable one.

"See BR2_PACKAGE_HOST_GDB in the Toolchain menu to enable one."

It could be useful to add a comment that external toolchains often
provide gdb/gdbserver.

Quoted 9 lines
package/gdb/Config.in new file +9 -0
+
+	  http://www.gnu.org/software/gdb/
+
+if BR2_PACKAGE_GDB
+
+config BR2_PACKAGE_GDB_SERVER
+	bool "gdbserver"
+	help
+	  Build the gdbserver stub to run on the target.

package/gdb/Config.in line 33

Quoted 10 lines
package/gdb/Config.in new file +10 -0
+	  A full gdb is needed to debug the progam.
+
+config BR2_PACKAGE_GDB_DEBUGGER
+	bool "full debugger"
+	select BR2_PACKAGE_NCURSES
+	depends on BR2_USE_WCHAR
+	depends on BR2_TOOLCHAIN_HAS_THREADS
+	depends on !BR2_sh && !BR2_sh64 && !BR2_avr32 && !BR2_microblaze && !BR2_bfin && !BR2_aarch64
+	depends on BR2_TOOLCHAIN_HAS_THREADS_DEBUG_IF_NEEDED
+	select BR2_PTHREAD_DEBUG if (BR2_TOOLCHAIN_BUILDROOT && !BR2_PTHREADS_NONE)

It feels pretty strange to modify a toolchain option from a package
Config.in. Remember, the user may add gdb in a second run and try to do an incremental build... So I would say: move it to a depends like we usually do.

Quoted 11 lines
package/gdb/Config.in new file +5 -0
+
+comment "full gdb on target needs WCHAR and threads support in toolchain"
+	depends on !BR2_USE_WCHAR || !BR2_TOOLCHAIN_HAS_THREADS
+
+endif
package/gdb/Config.in.host new file +0 -0
new file mode 100644
index 0000000..6ee1d26

package/gdb/Config.in.host line 7

Quoted 7 lines
package/gdb/Config.in.host new file +7 -0
@@ -0,0 +1,56 @@
+config BR2_PACKAGE_HOST_GDB
+	bool "Build cross gdb for the host"
+	help
+	    Build a cross gdb that runs on the host machine and debugs
+	    programs running on the target. It requires 'gdbserver'
+	    installed on the target, see BR2_PACKAGE_GDB_SERVER to
+	    enable it.

As I said, I would just auto-select BR2_PACKAGE_GDB, which will select
BR2_PACKAGE_GDB_SERVER

[snip]

Quoted 12 lines
package/gdb/gdb.mk new file +6 -0
new file mode 100644
index 0000000..c102cc9
@@ -0,0 +1,100 @@
+#############################################################
+#
+# gdb
+#
+#############################################################
+

package/gdb/gdb.mk line 16

Quoted 10 lines
package/gdb/gdb.mk new file +10 -0
+GDB_VERSION = $(call qstrip,$(BR2_GDB_VERSION))
+
+# When no version is defined, it means that cross-gdb for the host has
+# not been enabled, and we will only build gdbserver or gdb for the
+# target. In this case, use the latest available version
+# automatically.
+ifeq ($(GDB_VERSION),)
+ifeq ($(BR2_bfin),y)
+GDB_VERSION = 6.6a
+GDB_SITE    = $(BR2_GNU_MIRROR)/gdb

Just define this once, either before the condition (and override it for
avr32), or after the condition (and use ?=).

Quoted 14 lines
package/gdb/gdb.mk new file +14 -0
+else ifeq ($(BR2_avr32),y)
+GDB_VERSION = 6.7.1-avr32-2.1.5
+GDB_SITE    = ftp://www.at91.com/pub/buildroot/
+else
+GDB_VERSION = 7.5.1
+GDB_SITE    = $(BR2_GNU_MIRROR)/gdb
+endif
+endif
+
+GDB_SOURCE = gdb-$(GDB_VERSION).tar.bz2
+GDB_LICENSE = GPLv2+ LGPLv2+ GPLv3+ LGPLv3+
+GDB_LICENSE_FILES = COPYING COPYING.LIB COPYING3 COPYING3.LIB
+
+# We only want gdbserver and not the entire debugger.

package/gdb/gdb.mk line 40

Quoted 10 lines
package/gdb/gdb.mk new file +10 -0
+ifeq ($(BR2_PACKAGE_GDB_DEBUGGER),)
+GDB_SUBDIR = gdb/gdbserver
+HOST_GDB_SUBDIR = .
+else
+GDB_DEPENDENCIES = ncurses
+endif
+
+# For the host variant, we really want to build with XML support,
+# which is needed to read XML descriptions of target architectures.
+HOST_GDB_DEPENDENCIES = host-expat

Can we rely on host-nurses being present? It is not checked in
dependencies.sh AFAIK. Admittedly, it is not a dependency of host-gdb now, but most people have ncurses installed anyway for menuconfig...

[snip]

package/gdb/gdb.mk line 76

Quoted 3 lines
package/gdb/gdb.mk new file +3 -0
+define GDB_REMOVE_UNNEEDED_FILES
+	$(RM) -rf $(TARGET_DIR)/usr/share/gdb
+endef

Perhaps a comment why this is needed? Or is it just to keep it
consistent with the current behaviour?

Regards,
Arnout

Quoted 24 lines
package/gdb/gdb.mk new file +24 -0
+
+GDB_POST_INSTALL_TARGET_HOOKS += GDB_REMOVE_UNNEEDED_FILES
+
+# A few notes:
+#  * --target, because we're doing a cross build rather than a real
+#    host build.
+#  * --enable-static because gdb really wants to use libbfd.a
+#  * --disable-shared, otherwise the old 6.7 version specific to AVR32
+#    doesn't build because it wants to link a shared libbfd.so against
+#    non-PIC liberty.a.
+HOST_GDB_CONF_OPT = \
+	--target=$(GNU_TARGET_NAME) \
+	--enable-static --disable-shared \
+	--without-uiout \
+	--disable-tui \
+	--disable-gdbtk \
+	--without-x \
+	--enable-threads \
+	--disable-werror \
+	--without-included-gettext \
+	--disable-sim
+
+$(eval $(autotools-package))
+$(eval $(host-autotools-package))

[snip]

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
#2 lore raw

PATCH 1/1 gdb: convert to the package infrastructure

Quoted 21 lines · Arnout Vandecappelle
Quoted 12 lines · Thomas Petazzoni

This commit converts gdb to the package infrastructure, and therefore moves it from toolchain/gdb to package/gdb.

The target package is now visible in "Package selection for the target" => "Debugging, profiling and benchmark". The main option, "gdb", forcefully selects the "gdbserver" sub-option by default. Another sub-option, "full debugger" allows to install the complete gdb on the target. When this option is enabled, then "gdbserver" is no longer forcefully selected. This ensures that at least gdbserver or the full debugger gets built/installed, so that the package is not a no-op.

Quoted 7 lines

The host debugger is still enabled through a configuration option in "Toolchain". It is now visible regardless of the toolchain type (it used to be hidden for External Toolchains). The configuration options relative to the host debugger are now in package/gdb/Config.in.host, similar to how we have package/binutils/Config.in.host.

Quoted 7 lines

This looks like a great idea!

Just a couple of generic remarks, and then a few specific ones below.
The generic remarks are probably for follow-up patches.

* It really doesn't make sense to build host-gdb without a gdbserver for the target. So I would auto-select gdbserver from host-gdb.

Kgdb (kernel debugging) is one use case where you'd want host-gdb without necessarily gdbserver.

Quoted 3 lines

* Does it really make sense to keep options for four different gdb versions? Can't we just remove the user-selectable version completely?

The option is useful for arches which don't have their gdb port upstream yet, giving them a chance to update their patches.

Cheers
James

#3 lore raw

PATCH 1/1 gdb: convert to the package infrastructure

Dear James Hogan,

Quoted 6 lines · James Hogan
Quoted 3 lines

* It really doesn't make sense to build host-gdb without a gdbserver for the target. So I would auto-select gdbserver from host-gdb.

Kgdb (kernel debugging) is one use case where you'd want host-gdb without necessarily gdbserver.

Hum, correct.

Quoted 6 lines
Quoted 3 lines

* Does it really make sense to keep options for four different gdb versions? Can't we just remove the user-selectable version completely?

The option is useful for arches which don't have their gdb port upstream yet, giving them a chance to update their patches.

Not sure to follow here: Arnout mentions the choice list of gdb versions, which only have a limited number of choices already. If you need Buildroot to use some custom gdb version, then you already have to modify Buildroot anyway. Or maybe I'm missing the point you're making?

Thanks!

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#4 lore raw

PATCH 1/1 gdb: convert to the package infrastructure

Hi Thomas,

Quoted 15 lines · Thomas Petazzoni
Quoted 6 lines · James Hogan
Quoted 3 lines

* It really doesn't make sense to build host-gdb without a gdbserver for the target. So I would auto-select gdbserver from host-gdb.

Kgdb (kernel debugging) is one use case where you'd want host-gdb without necessarily gdbserver.

Hum, correct.

Quoted 4 lines
Quoted 3 lines

* Does it really make sense to keep options for four different gdb versions? Can't we just remove the user-selectable version completely?

Quoted 7 lines
Quoted 2 lines

The option is useful for arches which don't have their gdb port upstream yet, giving them a chance to update their patches.

Not sure to follow here: Arnout mentions the choice list of gdb versions, which only have a limited number of choices already. If you need Buildroot to use some custom gdb version, then you already have to modify Buildroot anyway. Or maybe I'm missing the point you're making?

Yes, but the modification is as simple as adding a patch file in the right place.

Cheers
James

#5 lore raw

PATCH 1/1 gdb: convert to the package infrastructure

Dear James Hogan,

Quoted 7 lines · James Hogan
Quoted 4 lines

Not sure to follow here: Arnout mentions the choice list of gdb versions, which only have a limited number of choices already. If you need Buildroot to use some custom gdb version, then you already have to modify Buildroot anyway. Or maybe I'm missing the point you're making?

Yes, but the modification is as simple as adding a patch file in the right place.

It's still the case here: just add your patch in package/gdb/<version>/, and that's it.

No?

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#6 lore raw

PATCH 1/1 gdb: convert to the package infrastructure

Hi Thomas,

Quoted 7 lines · Thomas Petazzoni
Quoted 5 lines · James Hogan
Quoted 4 lines

Not sure to follow here: Arnout mentions the choice list of gdb versions, which only have a limited number of choices already. If you need Buildroot to use some custom gdb version, then you already have to modify Buildroot anyway. Or maybe I'm missing the point you're making?

Quoted 5 lines
Quoted 2 lines

Yes, but the modification is as simple as adding a patch file in the right place.

It's still the case here: just add your patch in
package/gdb/<version>/, and that's it.

I may have misunderstood what Arnout meant then. I thought he was referring to removing the choice of GDB version ("Can't we just remove the user-selectable version completely?").

Anyway, no big deal.

Cheers
James

#7 lore raw

PATCH 1/1 gdb: convert to the package infrastructure

In reply to Arnout Vandecappelle

Dear Arnout Vandecappelle,

Quoted 1 line · Arnout Vandecappelle

This looks like a great idea!

Thanks :-)

Quoted 5 lines

Just a couple of generic remarks, and then a few specific ones
below. The generic remarks are probably for follow-up patches.

* It really doesn't make sense to build host-gdb without a gdbserver for the target. So I would auto-select gdbserver from host-gdb.

See the point made by James Hogan regarding kgdb. I don't have a strong opinion on this one, and we could decide that gdbserver is lightweight enough that even with James use case of kgdb, it still makes sense to have gdbserver on the target when host-gdb is enabled.

Quoted 2 lines

* Does it really make sense to keep options for four different gdb versions? Can't we just remove the user-selectable version completely?

I just kept as it was.

Quoted 2 lines

* Do gdb-7.2+ actually work for avr32? If yes, why keep the 6.7.1 around?

I also just kept it as it was. If we want to upgrade gdb for avr32, then let's do it as a follow-up. People having access to avr32 hardware should test that.

Quoted 5 lines
Quoted 3 lines

---
It would be good to have a few people testing this before committing.

Nah, just let the autobuilders do it :-)

Autobuilders are nice, but they are not yet capable of starting gdbserver on the target, connect gdb, and verify that it works :)

Quoted 9 lines

package/gdb/Config.in line 14

Quoted 4 lines
(quoted diff) +2 -0
+	  For embedded development, the most common solution is to
+	  build only 'gdbserver' for the target, and use a

cross-gdb

package/gdb/Config.in new file +1 -0
+	  on the host. See BR2_PACKAGE_HOST_GDB to enable one.

"See BR2_PACKAGE_HOST_GDB in the Toolchain menu to enable one."

It could be useful to add a comment that external toolchains often
provide gdb/gdbserver.

Indeed. I am not sure what do with external toolchains here. In the past, I was hiding the option to build host-gdb and gdbserver for the target, making the assumption that the external toolchain already have those, and instead there was the option to copy the toolchain's gdbserver to the target. Now, everything is available: host-gdb built by Buildroot, gdbserver built by Buildroot, and gdbserver copied from the external toolchain. Should I keep all this?

Also, the "gdbserver build by Buildroot" thing is in Packages -> Debugging, but the "copy gdbserver from toolchain" thing is in Toolchain. But it's not easy to put it in a package, as the code needed to copy gdbserver from the toolchain really relates to all the complex external toolchain logic.

Quoted 17 lines
Quoted 17 lines
package/gdb/Config.in new file +16 -0
+	  http://www.gnu.org/software/gdb/
+
+if BR2_PACKAGE_GDB
+
+config BR2_PACKAGE_GDB_SERVER
+	bool "gdbserver"
+	help
+	  Build the gdbserver stub to run on the target.
+	  A full gdb is needed to debug the progam.
+
+config BR2_PACKAGE_GDB_DEBUGGER
+	bool "full debugger"
+	select BR2_PACKAGE_NCURSES
+	depends on BR2_USE_WCHAR
+	depends on BR2_TOOLCHAIN_HAS_THREADS
+	depends on !BR2_sh && !BR2_sh64 && !BR2_avr32

&& !BR2_microblaze && !BR2_bfin && !BR2_aarch64

Quoted 8 lines
Quoted 3 lines
(quoted diff) +2 -0
+	depends on BR2_TOOLCHAIN_HAS_THREADS_DEBUG_IF_NEEDED
+	select BR2_PTHREAD_DEBUG if (BR2_TOOLCHAIN_BUILDROOT

&& !BR2_PTHREADS_NONE)

It feels pretty strange to modify a toolchain option from a package
Config.in. Remember, the user may add gdb in a second run and try to do an incremental build... So I would say: move it to a depends like we usually do.

Ok.

Quoted 14 lines
Quoted 14 lines

+comment "full gdb on target needs WCHAR and threads support in toolchain"

package/gdb/Config.in new file +3 -0
+	depends on !BR2_USE_WCHAR || !BR2_TOOLCHAIN_HAS_THREADS
+
+endif
package/gdb/Config.in.host new file +3 -0
new file mode 100644
index 0000000..6ee1d26
@@ -0,0 +1,56 @@
+config BR2_PACKAGE_HOST_GDB
+	bool "Build cross gdb for the host"
+	help
Quoted 8 lines

package/gdb/Config.in.host line 7

Quoted 5 lines
package/gdb/Config.in.host new file +1 -0
+	    Build a cross gdb that runs on the host machine and

debugs

package/gdb/Config.in.host new file +3 -0
+	    programs running on the target. It requires 'gdbserver'
+	    installed on the target, see BR2_PACKAGE_GDB_SERVER to
+	    enable it.

As I said, I would just auto-select BR2_PACKAGE_GDB, which will
select BR2_PACKAGE_GDB_SERVER

Hum, why not select BR2_PACKAGE_GDB and BR2_PACKAGE_GDB_SERVER? If you select BR2_PACKAGE_GDB only, it still the user the possibility to build only the target debugger, and not gdbserver.

Quoted 11 lines

package/gdb/Config.in.host

Quoted 8 lines

+# When no version is defined, it means that cross-gdb for the host has +# not been enabled, and we will only build gdbserver or gdb for the +# target. In this case, use the latest available version

package/gdb/Config.in.host new file +5 -0
+# automatically.
+ifeq ($(GDB_VERSION),)
+ifeq ($(BR2_bfin),y)
+GDB_VERSION = 6.6a
+GDB_SITE    = $(BR2_GNU_MIRROR)/gdb

Just define this once, either before the condition (and override it
for avr32), or after the condition (and use ?=).

Ok.

Quoted 21 lines
Quoted 21 lines
package/gdb/Config.in.host new file +20 -0
+else ifeq ($(BR2_avr32),y)
+GDB_VERSION = 6.7.1-avr32-2.1.5
+GDB_SITE    = ftp://www.at91.com/pub/buildroot/
+else
+GDB_VERSION = 7.5.1
+GDB_SITE    = $(BR2_GNU_MIRROR)/gdb
+endif
+endif
+
+GDB_SOURCE = gdb-$(GDB_VERSION).tar.bz2
+GDB_LICENSE = GPLv2+ LGPLv2+ GPLv3+ LGPLv3+
+GDB_LICENSE_FILES = COPYING COPYING.LIB COPYING3 COPYING3.LIB
+
+# We only want gdbserver and not the entire debugger.
+ifeq ($(BR2_PACKAGE_GDB_DEBUGGER),)
+GDB_SUBDIR = gdb/gdbserver
+HOST_GDB_SUBDIR = .
+else
+GDB_DEPENDENCIES = ncurses
+endif
Quoted 8 lines

package/gdb/Config.in.host

Quoted 4 lines
package/gdb/Config.in.host new file +4 -0
+
+# For the host variant, we really want to build with XML support,
+# which is needed to read XML descriptions of target architectures.
+HOST_GDB_DEPENDENCIES = host-expat

Can we rely on host-nurses being present? It is not checked in
dependencies.sh AFAIK. Admittedly, it is not a dependency of host-gdb now, but most people have ncurses installed anyway for menuconfig...

host-ncurses wasn't a dependency, and our host-ncurses package is only here to build a version of "tic" that works properly. Some systems had a "tic" version causing problems when building a more recent ncurses for the target. I think that other than for this "tic" program, we should really on the pre-installed ncurses library, which should already be present since the user uses menuconfig.

However, it's true we don't check it in dependencies.sh, and the user could very well be using xconfig or gconfig, neither of which require ncurses.

I'd say that's a separate matter really.

Quoted 7 lines

[snip]

package/gdb/Config.in.host

Quoted 3 lines
package/gdb/Config.in.host new file +3 -0
+define GDB_REMOVE_UNNEEDED_FILES
+	$(RM) -rf $(TARGET_DIR)/usr/share/gdb
+endef

Perhaps a comment why this is needed? Or is it just to keep it
consistent with the current behaviour?

The old gdb installation logic was to manually copy the gdb binary to the $(TARGET_DIR). In my patch, I've chosen to use 'make install' instead, which requires removing a bunch of generally useless stuff (Python scripts and XML descriptions of targets, which as per my understanding, are needed only when you do remote debugging).

Thanks for the review!

Best regards,

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#8 lore raw

PATCH 1/1 gdb: convert to the package infrastructure

Quoted 11 lines
Quoted 6 lines

Just a couple of generic remarks, and then a few specific ones
below. The generic remarks are probably for follow-up patches.

* It really doesn't make sense to build host-gdb without a gdbserver for the target. So I would auto-select gdbserver from host-gdb.

See the point made by James Hogan regarding kgdb. I don't have a strong opinion on this one, and we could decide that gdbserver is lightweight enough that even with James use case of kgdb, it still makes sense to have gdbserver on the target when host-gdb is enabled.

Running a remote kgdb is something you would need the most on a system
with little memory, so indeed the non-gdbserver use case is important. So, keep it as you have it.

Quoted 4 lines
Quoted 2 lines

* Does it really make sense to keep options for four different gdb versions? Can't we just remove the user-selectable version completely?

I just kept as it was.

As I said: for a follow-up patch.

James Hogan makes another good point that custom patches against a
specific gdb version are easier to maintain if the version is selectable. However, when the generic package infrastructure is used, changing the version number directly in gdb.mk is also easy. I think the use case of custom patches against gdb is sufficiently rare that Kconfig configuration is not needed.

Quoted 6 lines
Quoted 2 lines

* Do gdb-7.2+ actually work for avr32? If yes, why keep the 6.7.1 around?

I also just kept it as it was. If we want to upgrade gdb for avr32, then let's do it as a follow-up. People having access to avr32 hardware should test that.

Actually, I mean: there is an avr32-specific gdb version, but the 7.x
gdb versions are also enabled for avr32. It just looks strange.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

---
It would be good to have a few people testing this before committing.

Nah, just let the autobuilders do it :-)

Autobuilders are nice, but they are not yet capable of starting gdbserver on the target, connect gdb, and verify that it works :)

True, but the change you make here is not going to affect gdb runtime.
The likelihood that there is serious build breakage is much higher than that of a runtime regression, I think. Also if there is a runtime regression, the chance that it will be found is much higher if it's been committed than if the patch is just lingering on the list.

Quoted 10 lines
Quoted 9 lines

package/gdb/Config.in line 14

Quoted 4 lines
(quoted diff) +2 -0
+	  For embedded development, the most common solution is to
+	  build only 'gdbserver' for the target, and use a

cross-gdb

package/gdb/Config.in new file +1 -0
+	  on the host. See BR2_PACKAGE_HOST_GDB to enable one.

"See BR2_PACKAGE_HOST_GDB in the Toolchain menu to enable one."

It could be useful to add a comment that external toolchains often
provide gdb/gdbserver.

Quoted 7 lines

Indeed. I am not sure what do with external toolchains here. In the past, I was hiding the option to build host-gdb and gdbserver for the target, making the assumption that the external toolchain already have those, and instead there was the option to copy the toolchain's gdbserver to the target. Now, everything is available: host-gdb built by Buildroot, gdbserver built by Buildroot, and gdbserver copied from the external toolchain. Should I keep all this?

You could make the gdbserver copied from the external toolchain
mutually exclusive with the gdb package, but I'm not convinced that that is needed.

Quoted 5 lines

Also, the "gdbserver build by Buildroot" thing is in Packages -> Debugging, but the "copy gdbserver from toolchain" thing is in Toolchain. But it's not easy to put it in a package, as the code needed to copy gdbserver from the toolchain really relates to all the complex external toolchain logic.

Well, the location of the config menu is independent from where it is
used in the .mk files, of course.

Wild idea:

In Toolchain menu, under all the rest:

[ ] Cross gdb for the host

      GDB debugger version (gdb 7.5.x)  -->

[ ] gdbserver on the target
[ ] Copy external toolchain gdbserver to the target
[ ] full gdb on the target

Hm, this looks very much like the current situation :-)

Admittedly, gdb's Config.in would look pretty non-standard (e.g. a
blind BR2_PACKAGE_GDB symbol that is selected by BR2_PACKAGE_GDB_GDBSERVER and BR2_PACKAGE_GDB_DEBUGGER), but it is a fairly special case.

[snip]

Quoted 10 lines
Quoted 3 lines

Can we rely on host-nurses being present? It is not checked in
dependencies.sh AFAIK. Admittedly, it is not a dependency of host-gdb now, but most people have ncurses installed anyway for menuconfig...

host-ncurses wasn't a dependency, and our host-ncurses package is only here to build a version of "tic" that works properly. Some systems had a "tic" version causing problems when building a more recent ncurses for the target. I think that other than for this "tic" program, we should really on the pre-installed ncurses library, which should already be present since the user uses menuconfig.

I guess even better would be a build-if-missing approach like for tar
and python (when the patch gets merged).

Quoted 6 lines

However, it's true we don't check it in dependencies.sh, and the user could very well be using xconfig or gconfig, neither of which require ncurses.

I'd say that's a separate matter really.

Agreed. This patch is just an opportunity to review gdb in general.

Quoted 9 lines
Quoted 8 lines

[snip]

package/gdb/gdb.mk line 76

Quoted 3 lines
package/gdb/gdb.mk new file +3 -0
+define GDB_REMOVE_UNNEEDED_FILES
+	$(RM) -rf $(TARGET_DIR)/usr/share/gdb
+endef

Perhaps a comment why this is needed? Or is it just to keep it
consistent with the current behaviour?

Quoted 5 lines

The old gdb installation logic was to manually copy the gdb binary to the $(TARGET_DIR). In my patch, I've chosen to use 'make install' instead, which requires removing a bunch of generally useless stuff (Python scripts and XML descriptions of targets, which as per my understanding, are needed only when you do remote debugging).

Fair enough. I feel something like this is worthwhile to explain in a
comment.

Regards,
Arnout

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F