Skip to contentSkip to conversation

gdb support improvements

PATCH Superseded Thomas Petazzoni 2 participants 7 messages Mar 24, 2013 – Mar 27, 2013

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover gdb support improvements

Hello,

This patch series makes a number of improvements to gdb handling.

The first patch converts gdb to the package infrastructure and has already been sent to the list in two successive versions. There is no additional change to this patch in this version 3.

The second patch implements a suggestion from Yann E. Morin that we should allow to build gdbserver/cross-gdb if the external toolchain gdbserver is copied to the target. The idea is that if the user chooses to copy the external toolchain gdbserver to the target, then (s)he should be using the cross-gdb of the external toolchain in order to avoid any incompatibility.

The third patch makes sure that we install the gdbserver binary somewhere in the SDK, so that the Buildroot toolchain can later be used as an external toolchain. It replaces the patch proposed by Kevin Worth at http://patchwork.ozlabs.org/patch/229438/.

Thomas Petazzoni (3):
gdb: convert to the package infrastructure
gdb: do not allow gdbserver/cross-gdb build in some cases
gdb: install gdbserver into the SDK

 Config.in.legacy                                   |    9 +
 package/Config.in                                  |    1 +
 package/gdb/6.6a/100-uclibc-conf.patch             |   82 +++++
 .../gdb/6.6a/600-fix-compile-flag-mismatch.patch   |   69 +++++
 package/gdb/6.6a/gdb-6.6-bfin-gdbserver.patch      |  238 +++++++++++++++
 package/gdb/7.4.1/00_all_ptrace_setsiginfo.patch   |  314 ++++++++++++++++++++
 package/gdb/7.4.1/05_all_readline-headers.patch    |   42 +++
 package/gdb/7.4.1/xtensa-asm-ptrace-h.patch        |   22 ++
 package/gdb/7.4.1/xtensa-gdb-regsize.patch         |   19 ++
 package/gdb/Config.in                              |   46 +++
 package/gdb/Config.in.host                         |   60 ++++
 package/gdb/gdb.mk                                 |  115 +++++++
 toolchain/Config.in                                |    2 -
 toolchain/gdb/6.6a/100-uclibc-conf.patch           |   82 -----
 .../gdb/6.6a/600-fix-compile-flag-mismatch.patch   |   69 -----
 toolchain/gdb/6.6a/gdb-6.6-bfin-gdbserver.patch    |  238 ---------------
 toolchain/gdb/7.4.1/00_all_ptrace_setsiginfo.patch |  314 --------------------
 toolchain/gdb/7.4.1/05_all_readline-headers.patch  |   42 ---
 toolchain/gdb/7.4.1/xtensa-asm-ptrace-h.patch      |   22 --
 toolchain/gdb/7.4.1/xtensa-gdb-regsize.patch       |   19 --
 toolchain/gdb/Config.in                            |   99 ------
 toolchain/gdb/gdb.mk                               |  234 ---------------
 toolchain/toolchain-buildroot.mk                   |    1 -
 toolchain/toolchain-buildroot/Config.in.2          |    7 +
 toolchain/toolchain-common.in                      |    7 +-
 toolchain/toolchain-crosstool-ng.mk                |    1 -
 toolchain/toolchain-crosstool-ng/Config.in         |    3 +
 toolchain/toolchain-external.mk                    |    1 -
 toolchain/toolchain-external/Config.in             |    7 +
 toolchain/uClibc/Config.in                         |    6 -
 30 files changed, 1035 insertions(+), 1136 deletions(-)
 create mode 100644 package/gdb/6.6a/100-uclibc-conf.patch
 create mode 100644 package/gdb/6.6a/600-fix-compile-flag-mismatch.patch
 create mode 100644 package/gdb/6.6a/gdb-6.6-bfin-gdbserver.patch
 create mode 100644 package/gdb/7.4.1/00_all_ptrace_setsiginfo.patch
 create mode 100644 package/gdb/7.4.1/05_all_readline-headers.patch
 create mode 100644 package/gdb/7.4.1/xtensa-asm-ptrace-h.patch
 create mode 100644 package/gdb/7.4.1/xtensa-gdb-regsize.patch
 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/6.6a/100-uclibc-conf.patch
 delete mode 100644 toolchain/gdb/6.6a/600-fix-compile-flag-mismatch.patch
 delete mode 100644 toolchain/gdb/6.6a/gdb-6.6-bfin-gdbserver.patch
 delete mode 100644 toolchain/gdb/7.4.1/00_all_ptrace_setsiginfo.patch
 delete mode 100644 toolchain/gdb/7.4.1/05_all_readline-headers.patch
 delete mode 100644 toolchain/gdb/7.4.1/xtensa-asm-ptrace-h.patch
 delete mode 100644 toolchain/gdb/7.4.1/xtensa-gdb-regsize.patch
 delete mode 100644 toolchain/gdb/Config.in
 delete mode 100644 toolchain/gdb/gdb.mk
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v3 1/3 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.

Since gdb is now a proper package, it is no longer allowed to 'select BR2_PTHREADS_DEBUG' to ensure thread debugging is available when needed. Instead, it now 'depends on BR2_TOOLCHAIN_HAS_THREADS_DEBUG'. This option, in turn, is select by the different toolchain backends when appropriate. The 'BR2_TOOLCHAIN_HAS_THREADS_DEBUG_IF_NEEDED' option is removed, since we no longer need to know when it is allowed to 'select BR2_PTHREADS_DEBUG'. Also, the 'BR2_PTHREADS_DEBUG' option is moved to appear right below the thread implementation selection (in the case of the Buildroot toolchain backend).

---
Changes from v1 to v2:

* Fixup the help text of BR2_PACKAGE_GDB to mention in which menu the cross-gdb can be enable, and the fact that external toolchains often provide their own pre-built versions of cross-gdb and gdbserver. Suggested by Arnout.

* No longer 'select BR2_PTHREAD_DEBUG' from the gdb package. As Arnout noticed, now that gdb is a normal package, it should not forcefully select a toolchain configuration option. Instead, it should depend on it being available. This allows to remove the BR2_TOOLCHAIN_HAS_THREADS_DEBUG_IF_NEEDED option: we now only have the BR2_TOOLCHAIN_HAS_THREADS_DEBUG, which gets selected by the various toolchain backends when appropriate, and the gdb package depends on it.

* Factorize the definition of GDB_SITE. Suggested by Arnout.

* Add a small comment that explains why we remove /usr/share/gdb from the target. Suggested by Arnout.

---
 Config.in.legacy                                   |    9 +
 package/Config.in                                  |    1 +
 package/gdb/6.6a/100-uclibc-conf.patch             |   82 +++++
 .../gdb/6.6a/600-fix-compile-flag-mismatch.patch   |   69 +++++
 package/gdb/6.6a/gdb-6.6-bfin-gdbserver.patch      |  238 +++++++++++++++
 package/gdb/7.4.1/00_all_ptrace_setsiginfo.patch   |  314 ++++++++++++++++++++
 package/gdb/7.4.1/05_all_readline-headers.patch    |   42 +++
 package/gdb/7.4.1/xtensa-asm-ptrace-h.patch        |   22 ++
 package/gdb/7.4.1/xtensa-gdb-regsize.patch         |   19 ++
 package/gdb/Config.in                              |   40 +++
 package/gdb/Config.in.host                         |   56 ++++
 package/gdb/gdb.mk                                 |  101 +++++++
 toolchain/Config.in                                |    2 -
 toolchain/gdb/6.6a/100-uclibc-conf.patch           |   82 -----
 .../gdb/6.6a/600-fix-compile-flag-mismatch.patch   |   69 -----
 toolchain/gdb/6.6a/gdb-6.6-bfin-gdbserver.patch    |  238 ---------------
 toolchain/gdb/7.4.1/00_all_ptrace_setsiginfo.patch |  314 --------------------
 toolchain/gdb/7.4.1/05_all_readline-headers.patch  |   42 ---
 toolchain/gdb/7.4.1/xtensa-asm-ptrace-h.patch      |   22 --
 toolchain/gdb/7.4.1/xtensa-gdb-regsize.patch       |   19 --
 toolchain/gdb/Config.in                            |   99 ------
 toolchain/gdb/gdb.mk                               |  234 ---------------
 toolchain/toolchain-buildroot.mk                   |    1 -
 toolchain/toolchain-buildroot/Config.in.2          |    7 +
 toolchain/toolchain-common.in                      |    7 +-
 toolchain/toolchain-crosstool-ng.mk                |    1 -
 toolchain/toolchain-crosstool-ng/Config.in         |    3 +
 toolchain/toolchain-external.mk                    |    1 -
 toolchain/toolchain-external/Config.in             |    7 +
 toolchain/uClibc/Config.in                         |    6 -
 30 files changed, 1011 insertions(+), 1136 deletions(-)
 create mode 100644 package/gdb/6.6a/100-uclibc-conf.patch
 create mode 100644 package/gdb/6.6a/600-fix-compile-flag-mismatch.patch
 create mode 100644 package/gdb/6.6a/gdb-6.6-bfin-gdbserver.patch
 create mode 100644 package/gdb/7.4.1/00_all_ptrace_setsiginfo.patch
 create mode 100644 package/gdb/7.4.1/05_all_readline-headers.patch
 create mode 100644 package/gdb/7.4.1/xtensa-asm-ptrace-h.patch
 create mode 100644 package/gdb/7.4.1/xtensa-gdb-regsize.patch
 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/6.6a/100-uclibc-conf.patch
 delete mode 100644 toolchain/gdb/6.6a/600-fix-compile-flag-mismatch.patch
 delete mode 100644 toolchain/gdb/6.6a/gdb-6.6-bfin-gdbserver.patch
 delete mode 100644 toolchain/gdb/7.4.1/00_all_ptrace_setsiginfo.patch
 delete mode 100644 toolchain/gdb/7.4.1/05_all_readline-headers.patch
 delete mode 100644 toolchain/gdb/7.4.1/xtensa-asm-ptrace-h.patch
 delete mode 100644 toolchain/gdb/7.4.1/xtensa-gdb-regsize.patch
 delete mode 100644 toolchain/gdb/Config.in
 delete mode 100644 toolchain/gdb/gdb.mk
Config.in.legacy +9 -0
index 43e2afe..2bdef1f 100644
@@ -67,6 +67,15 @@ config BR2_PACKAGE_GDISK_SGDISK
 	help
 	  The option has been renamed BR2_PACKAGE_GPTFDISK_SGDISK.
 
+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 94e279b..2cfb4b4 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 new file +82 -0

82 lines not on this page · raw message

package/gdb/6.6a/600-fix-compile-flag-mismatch.patch new file +69 -0

69 lines not on this page · raw message

package/gdb/6.6a/gdb-6.6-bfin-gdbserver.patch new file +238 -0

238 lines not on this page · raw message

package/gdb/7.4.1/00_all_ptrace_setsiginfo.patch new file +314 -0

314 lines not on this page · raw message

package/gdb/7.4.1/05_all_readline-headers.patch new file +42 -0

42 lines not on this page · raw message

package/gdb/7.4.1/xtensa-asm-ptrace-h.patch new file +22 -0
new file mode 100644
index 0000000..3d1b07c
@@ -0,0 +1,22 @@
+--- gdb-7.4.1/gdb/xtensa-linux-nat.c.orig	2012-10-19 16:23:06.908165323 -0700
++++ gdb-7.4.1/gdb/xtensa-linux-nat.c	2012-10-19 16:35:30.792134876 -0700
+@@ -36,7 +36,7 @@
+ #include "gdb_wait.h"
+ #include <fcntl.h>
+ #include <sys/procfs.h>
+-#include <sys/ptrace.h>
++#include <asm/ptrace.h>
+ 
+ #include "gregset.h"
+ #include "xtensa-tdep.h"
+--- gdb-7.4.1/gdb/gdbserver/linux-xtensa-low.c.orig	2012-10-19 16:24:06.260162894 -0700
++++ gdb-7.4.1/gdb/gdbserver/linux-xtensa-low.c	2012-10-19 16:36:07.920133357 -0700
+@@ -23,7 +23,7 @@
+ /* Defined in auto-generated file reg-xtensa.c.  */
+ void init_registers_xtensa (void);
+ 
+-#include <sys/ptrace.h>
++#include <asm/ptrace.h>
+ #include <xtensa-config.h>
+ 
+ #include "xtensa-xtregs.c"
package/gdb/7.4.1/xtensa-gdb-regsize.patch new file +19 -0
new file mode 100644
index 0000000..e10bb8f
@@ -0,0 +1,19 @@
+--- gdb-7.4.1/gdb/xtensa-tdep.h.orig	2012-10-30 11:40:23.546448594 -0700
++++ gdb-7.4.1/gdb/xtensa-tdep.h	2012-10-30 11:41:43.078445337 -0700
+@@ -17,6 +17,7 @@
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+ 
++#include <stdint.h>
+ 
+ /* XTENSA_TDEP_VERSION can/should be changed along with XTENSA_CONFIG_VERSION
+    whenever the "tdep" structure changes in an incompatible way.  */
+@@ -84,7 +85,7 @@
+ /* Xtensa ELF core file register set representation ('.reg' section).
+    Copied from target-side ELF header <xtensa/elf.h>.  */
+ 
+-typedef unsigned long xtensa_elf_greg_t;
++typedef uint32_t xtensa_elf_greg_t;
+ 
+ typedef struct
+ {
package/gdb/Config.in new file +40 -0
new file mode 100644
index 0000000..10ac7aa
@@ -0,0 +1,40 @@
+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 in the Toolchain menu
+	  to enable one. Notice that external toolchains often provide
+	  their own pre-built cross-gdb and gdbserver binaries.
+
+	  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_TOOLCHAIN_HAS_THREADS_DEBUG
+	depends on !BR2_sh && !BR2_sh64 && !BR2_avr32 && !BR2_microblaze && !BR2_bfin && !BR2_aarch64
+
+comment "full gdb on target needs WCHAR, thread and thread debugging support in toolchain"
+	depends on !BR2_USE_WCHAR || !BR2_TOOLCHAIN_HAS_THREADS || \
+		!BR2_TOOLCHAIN_HAS_THREADS_DEBUG
+
+endif
package/gdb/Config.in.host new file +56 -0

56 lines not on this page · raw message

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

101 lines not on this page · raw message

toolchain/Config.in +0 -2
index 7edf82b..6311349 100644
@@ -12,7 +12,6 @@ config BR2_TOOLCHAIN_BUILDROOT
 	bool "Buildroot toolchain"
 	depends on !BR2_microblaze && !BR2_aarch64
 	select BR2_TOOLCHAIN_HAS_SHADOW_PASSWORDS
-	select BR2_TOOLCHAIN_HAS_THREADS_DEBUG_IF_NEEDED
 
 config BR2_TOOLCHAIN_EXTERNAL
 	bool "External toolchain"
@@ -25,7 +24,6 @@ config BR2_TOOLCHAIN_CTNG
 	bool "Crosstool-NG toolchain"
 	depends on !BR2_microblaze && !BR2_aarch64 && !BR2_xtensa
 	select BR2_TOOLCHAIN_HAS_SHADOW_PASSWORDS
-	select BR2_TOOLCHAIN_HAS_THREADS_DEBUG_IF_NEEDED
 	help
 	  Say 'y' if you want to generate the toolchain with crosstool-NG
 	  ( http://ymorin.is-a-geek.org/projects/crosstool )
toolchain/gdb/6.6a/100-uclibc-conf.patch deleted +0 -82

82 lines not on this page · raw message

toolchain/gdb/6.6a/600-fix-compile-flag-mismatch.patch deleted +0 -69

69 lines not on this page · raw message

toolchain/gdb/6.6a/gdb-6.6-bfin-gdbserver.patch deleted +0 -238

238 lines not on this page · raw message

toolchain/gdb/7.4.1/00_all_ptrace_setsiginfo.patch deleted +0 -314

314 lines not on this page · raw message

toolchain/gdb/7.4.1/05_all_readline-headers.patch deleted +0 -42

42 lines not on this page · raw message

toolchain/gdb/7.4.1/xtensa-asm-ptrace-h.patch deleted +0 -22
deleted file mode 100644
index 3d1b07c..0000000
@@ -1,22 +0,0 @@
---- gdb-7.4.1/gdb/xtensa-linux-nat.c.orig	2012-10-19 16:23:06.908165323 -0700
-+++ gdb-7.4.1/gdb/xtensa-linux-nat.c	2012-10-19 16:35:30.792134876 -0700
-@@ -36,7 +36,7 @@
- #include "gdb_wait.h"
- #include <fcntl.h>
- #include <sys/procfs.h>
--#include <sys/ptrace.h>
-+#include <asm/ptrace.h>
- 
- #include "gregset.h"
- #include "xtensa-tdep.h"
---- gdb-7.4.1/gdb/gdbserver/linux-xtensa-low.c.orig	2012-10-19 16:24:06.260162894 -0700
-+++ gdb-7.4.1/gdb/gdbserver/linux-xtensa-low.c	2012-10-19 16:36:07.920133357 -0700
-@@ -23,7 +23,7 @@
- /* Defined in auto-generated file reg-xtensa.c.  */
- void init_registers_xtensa (void);
- 
--#include <sys/ptrace.h>
-+#include <asm/ptrace.h>
- #include <xtensa-config.h>
- 
- #include "xtensa-xtregs.c"
toolchain/gdb/7.4.1/xtensa-gdb-regsize.patch deleted +0 -19
deleted file mode 100644
index e10bb8f..0000000
@@ -1,19 +0,0 @@
---- gdb-7.4.1/gdb/xtensa-tdep.h.orig	2012-10-30 11:40:23.546448594 -0700
-+++ gdb-7.4.1/gdb/xtensa-tdep.h	2012-10-30 11:41:43.078445337 -0700
-@@ -17,6 +17,7 @@
-    You should have received a copy of the GNU General Public License
-    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
- 
-+#include <stdint.h>
- 
- /* XTENSA_TDEP_VERSION can/should be changed along with XTENSA_CONFIG_VERSION
-    whenever the "tdep" structure changes in an incompatible way.  */
-@@ -84,7 +85,7 @@
- /* Xtensa ELF core file register set representation ('.reg' section).
-    Copied from target-side ELF header <xtensa/elf.h>.  */
- 
--typedef unsigned long xtensa_elf_greg_t;
-+typedef uint32_t xtensa_elf_greg_t;
- 
- typedef struct
- {
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-buildroot/Config.in.2 +7 -0
index a713727..7f19b09 100644
@@ -99,6 +99,13 @@ choice
 		depends on !BR2_xtensa
 endchoice
 
+config BR2_PTHREAD_DEBUG
+	bool "Thread library debugging"
+	depends on BR2_PTHREADS || BR2_PTHREADS_OLD || BR2_PTHREADS_NATIVE
+	select BR2_TOOLCHAIN_HAS_THREADS_DEBUG
+	help
+	  Build the thread library with debugging enabled.
+
 source "toolchain/elf2flt/Config.in"
 
 config BR2_VFP_FLOAT
toolchain/toolchain-common.in +1 -6
index f6905ae..208ccac 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
@@ -27,11 +27,6 @@ config BR2_TOOLCHAIN_HAS_THREADS
 	bool
 
 config BR2_TOOLCHAIN_HAS_THREADS_DEBUG
-	select BR2_TOOLCHAIN_HAS_THREADS_DEBUG_IF_NEEDED
-	bool
-
-config BR2_TOOLCHAIN_HAS_THREADS_DEBUG_IF_NEEDED
-	default y if !BR2_TOOLCHAIN_HAS_THREADS
 	bool
 
 config BR2_TOOLCHAIN_HAS_SHADOW_PASSWORDS
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-crosstool-ng/Config.in +3 -0
index df4e9b1..93c12e9 100644
@@ -121,15 +121,18 @@ choice
 	config BR2_TOOLCHAIN_CTNG_THREADS_PTHREADS
 		bool "linuxthreads"
 		select BR2_TOOLCHAIN_HAS_THREADS
+		select BR2_TOOLCHAIN_HAS_THREADS_DEBUG
 
 	config BR2_TOOLCHAIN_CTNG_THREADS_PTHREADS_OLD
 		bool "linuxthreads (stable/old)"
 		select BR2_TOOLCHAIN_HAS_THREADS
+		select BR2_TOOLCHAIN_HAS_THREADS_DEBUG
 		depends on BR2_TOOLCHAIN_CTNG_uClibc
 
 	config BR2_TOOLCHAIN_CTNG_THREADS_NPTL
 		bool "Native POSIX Threading (NPTL)"
 		select BR2_TOOLCHAIN_HAS_THREADS
+		select BR2_TOOLCHAIN_HAS_THREADS_DEBUG
 endchoice
 
 endif # BR2_TOOLCHAIN_CTNG
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 d2f3926..e61378b 100644
@@ -913,5 +913,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
 
toolchain/uClibc/Config.in +0 -6
index 57c9933..cebad45 100644
@@ -53,12 +53,6 @@ config BR2_UCLIBC_CONFIG
 	  See also docs/README in this package.
 	  If unsure, use the default.
 
-config BR2_PTHREAD_DEBUG
-	bool "Thread library debugging"
-	depends on BR2_PTHREADS || BR2_PTHREADS_OLD || BR2_PTHREADS_NATIVE
-	help
-	  Build the thread library with debugging enabled.
-
 config BR2_UCLIBC_INSTALL_TEST_SUITE
 	bool "Compile and install uClibc tests"
 	select BR2_PACKAGE_MAKE
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH v3 1/3 gdb: convert to the package infrastructure

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni <[email protected]> writes:

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

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

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

Thomas> Since gdb is now a proper package, it is no longer allowed to 'select Thomas> BR2_PTHREADS_DEBUG' to ensure thread debugging is available when Thomas> needed. Instead, it now 'depends on
Thomas> BR2_TOOLCHAIN_HAS_THREADS_DEBUG'. This option, in turn, is select by Thomas> the different toolchain backends when appropriate. The Thomas> 'BR2_TOOLCHAIN_HAS_THREADS_DEBUG_IF_NEEDED' option is removed, since Thomas> we no longer need to know when it is allowed to 'select Thomas> BR2_PTHREADS_DEBUG'. Also, the 'BR2_PTHREADS_DEBUG' option is moved to Thomas> appear right below the thread implementation selection (in the case of Thomas> the Buildroot toolchain backend).

Thanks, I like it - Unfortunately there's some issues (see below)

 Thomas>  Config.in.legacy                                   |    9 +
 Thomas>  package/Config.in                                  |    1 +
 Thomas>  package/gdb/6.6a/100-uclibc-conf.patch             |   82 +++++
 Thomas>  .../gdb/6.6a/600-fix-compile-flag-mismatch.patch   |   69 +++++
 Thomas>  package/gdb/6.6a/gdb-6.6-bfin-gdbserver.patch      |  238 +++++++++++++++
 Thomas>  package/gdb/7.4.1/00_all_ptrace_setsiginfo.patch   |  314 ++++++++++++++++++++
 Thomas>  package/gdb/7.4.1/05_all_readline-headers.patch    |   42 +++
 Thomas>  package/gdb/7.4.1/xtensa-asm-ptrace-h.patch        |   22 ++
 Thomas>  package/gdb/7.4.1/xtensa-gdb-regsize.patch         |   19 ++
 Thomas>  package/gdb/Config.in                              |   40 +++
 Thomas>  package/gdb/Config.in.host                         |   56 ++++
 Thomas>  package/gdb/gdb.mk                                 |  101 +++++++
 Thomas>  toolchain/Config.in                                |    2 -
 Thomas>  toolchain/gdb/6.6a/100-uclibc-conf.patch           |   82 -----
 Thomas>  .../gdb/6.6a/600-fix-compile-flag-mismatch.patch   |   69 -----
 Thomas>  toolchain/gdb/6.6a/gdb-6.6-bfin-gdbserver.patch    |  238 ---------------
 Thomas>  toolchain/gdb/7.4.1/00_all_ptrace_setsiginfo.patch |  314 --------------------
 Thomas>  toolchain/gdb/7.4.1/05_all_readline-headers.patch  |   42 ---
 Thomas>  toolchain/gdb/7.4.1/xtensa-asm-ptrace-h.patch      |   22 --
 Thomas>  toolchain/gdb/7.4.1/xtensa-gdb-regsize.patch       |   19 --
 Thomas>  toolchain/gdb/Config.in                            |   99 ------
 Thomas>  toolchain/gdb/gdb.mk                               |  234 ---------------
 Thomas>  toolchain/toolchain-buildroot.mk                   |    1 -
 Thomas>  toolchain/toolchain-buildroot/Config.in.2          |    7 +
 Thomas>  toolchain/toolchain-common.in                      |    7 +-
 Thomas>  toolchain/toolchain-crosstool-ng.mk                |    1 -
 Thomas>  toolchain/toolchain-crosstool-ng/Config.in         |    3 +
 Thomas>  toolchain/toolchain-external.mk                    |    1 -
 Thomas>  toolchain/toolchain-external/Config.in             |    7 +
 Thomas>  toolchain/uClibc/Config.in                         |    6 -
 Thomas>  30 files changed, 1011 insertions(+), 1136 deletions(-)
 Thomas>  create mode 100644 package/gdb/6.6a/100-uclibc-conf.patch
 Thomas>  create mode 100644 package/gdb/6.6a/600-fix-compile-flag-mismatch.patch
 Thomas>  create mode 100644 package/gdb/6.6a/gdb-6.6-bfin-gdbserver.patch
 Thomas>  create mode 100644 package/gdb/7.4.1/00_all_ptrace_setsiginfo.patch
 Thomas>  create mode 100644 package/gdb/7.4.1/05_all_readline-headers.patch
 Thomas>  create mode 100644 package/gdb/7.4.1/xtensa-asm-ptrace-h.patch
 Thomas>  create mode 100644 package/gdb/7.4.1/xtensa-gdb-regsize.patch
 Thomas>  create mode 100644 package/gdb/Config.in
 Thomas>  create mode 100644 package/gdb/Config.in.host
 Thomas>  create mode 100644 package/gdb/gdb.mk
 Thomas>  delete mode 100644 toolchain/gdb/6.6a/100-uclibc-conf.patch
 Thomas>  delete mode 100644 toolchain/gdb/6.6a/600-fix-compile-flag-mismatch.patch
 Thomas>  delete mode 100644 toolchain/gdb/6.6a/gdb-6.6-bfin-gdbserver.patch
 Thomas>  delete mode 100644 toolchain/gdb/7.4.1/00_all_ptrace_setsiginfo.patch
 Thomas>  delete mode 100644 toolchain/gdb/7.4.1/05_all_readline-headers.patch
 Thomas>  delete mode 100644 toolchain/gdb/7.4.1/xtensa-asm-ptrace-h.patch
 Thomas>  delete mode 100644 toolchain/gdb/7.4.1/xtensa-gdb-regsize.patch
 Thomas>  delete mode 100644 toolchain/gdb/Config.in
 Thomas>  delete mode 100644 toolchain/gdb/gdb.mk

Rename detection would have made this significantly easier to review :/

Thomas> +++ b/package/gdb/Config.in
Thomas> @@ -0,0 +1,40 @@
Thomas> +config BR2_PACKAGE_GDB
Thomas> + bool "gdb"
Thomas> + select BR2_PACKAGE_GDB_SERVER if !BR2_PACKAGE_GDB_DEBUGGER
Thomas> + help

 Thomas> +	  GDB, the GNU Project debugger, allows you to see what is
 Thomas> +	  going on `inside' another program while it executes -- or
 Thomas> +	  what another program was doing at the moment it crashed.
 Thomas> +
 Thomas> +	  This option allows to build gdbserver and/or the gdb
 Thomas> +	  debugger for the target.
 Thomas> +
 Thomas> +	  For embedded development, the most common solution is to
 Thomas> +	  build only 'gdbserver' for the target, and use a cross-gdb
 Thomas> +	  on the host. See BR2_PACKAGE_HOST_GDB in the Toolchain menu
 Thomas> +	  to enable one. Notice that external toolchains often provide
 Thomas> +	  their own pre-built cross-gdb and gdbserver binaries.

Thomas> +
Thomas> + http://www.gnu.org/software/gdb/
Thomas> +
Thomas> +if BR2_PACKAGE_GDB
Thomas> +
Thomas> +config BR2_PACKAGE_GDB_SERVER
Thomas> + bool "gdbserver"
Thomas> + help
Thomas> + Build the gdbserver stub to run on the target.
Thomas> + A full gdb is needed to debug the progam.
Thomas> +
Thomas> +config BR2_PACKAGE_GDB_DEBUGGER
Thomas> + bool "full debugger"
Thomas> + select BR2_PACKAGE_NCURSES
Thomas> + depends on BR2_USE_WCHAR
Thomas> + depends on BR2_TOOLCHAIN_HAS_THREADS
Thomas> + depends on BR2_TOOLCHAIN_HAS_THREADS_DEBUG
Thomas> + depends on !BR2_sh && !BR2_sh64 && !BR2_avr32 && !BR2_microblaze && !BR2_bfin && !BR2_aarch64
Thomas> +
Thomas> +comment "full gdb on target needs WCHAR, thread and thread debugging support in toolchain"
Thomas> + depends on !BR2_USE_WCHAR || !BR2_TOOLCHAIN_HAS_THREADS || \
Thomas> + !BR2_TOOLCHAIN_HAS_THREADS_DEBUG
Thomas> +
Thomas> +endif

This is afaik not correct (and now how it was before). Both gdbserver and full gdb need thread / thread debugging support for gdb 7.x.

It becomes a bit complicated as we only have the version selection if we're building gdb for the host though ..

From a usability POV, it's also a bit less handy when using the internal toolchain that you now need to go and enable the _HAS_THREADS_DEBUG option, but ok.

Signature · 1 line
Bye, Peter Korsgaard
#3 lore raw

PATCH v3 1/3 gdb: convert to the package infrastructure

Dear Peter Korsgaard,

Quoted 11 lines · Peter Korsgaard

Thomas> Since gdb is now a proper package, it is no longer allowed to 'select Thomas> BR2_PTHREADS_DEBUG' to ensure thread debugging is available when Thomas> needed. Instead, it now 'depends on
Thomas> BR2_TOOLCHAIN_HAS_THREADS_DEBUG'. This option, in turn, is select by Thomas> the different toolchain backends when appropriate. The Thomas> 'BR2_TOOLCHAIN_HAS_THREADS_DEBUG_IF_NEEDED' option is removed, since Thomas> we no longer need to know when it is allowed to 'select Thomas> BR2_PTHREADS_DEBUG'. Also, the 'BR2_PTHREADS_DEBUG' option is moved to Thomas> appear right below the thread implementation selection (in the case of Thomas> the Buildroot toolchain backend).

Quoted 1 line

Thanks, I like it - Unfortunately there's some issues (see below)

Goodness doesn't come without a little bit of effort :-)

Quoted 20 lines
 Thomas>  create mode 100644 package/gdb/6.6a/100-uclibc-conf.patch
 Thomas>  create mode 100644 package/gdb/6.6a/600-fix-compile-flag-mismatch.patch
 Thomas>  create mode 100644 package/gdb/6.6a/gdb-6.6-bfin-gdbserver.patch
 Thomas>  create mode 100644 package/gdb/7.4.1/00_all_ptrace_setsiginfo.patch
 Thomas>  create mode 100644 package/gdb/7.4.1/05_all_readline-headers.patch
 Thomas>  create mode 100644 package/gdb/7.4.1/xtensa-asm-ptrace-h.patch
 Thomas>  create mode 100644 package/gdb/7.4.1/xtensa-gdb-regsize.patch
 Thomas>  create mode 100644 package/gdb/Config.in
 Thomas>  create mode 100644 package/gdb/Config.in.host
 Thomas>  create mode 100644 package/gdb/gdb.mk
 Thomas>  delete mode 100644 toolchain/gdb/6.6a/100-uclibc-conf.patch
 Thomas>  delete mode 100644 toolchain/gdb/6.6a/600-fix-compile-flag-mismatch.patch
 Thomas>  delete mode 100644 toolchain/gdb/6.6a/gdb-6.6-bfin-gdbserver.patch
 Thomas>  delete mode 100644 toolchain/gdb/7.4.1/00_all_ptrace_setsiginfo.patch
 Thomas>  delete mode 100644 toolchain/gdb/7.4.1/05_all_readline-headers.patch
 Thomas>  delete mode 100644 toolchain/gdb/7.4.1/xtensa-asm-ptrace-h.patch
 Thomas>  delete mode 100644 toolchain/gdb/7.4.1/xtensa-gdb-regsize.patch
 Thomas>  delete mode 100644 toolchain/gdb/Config.in
 Thomas>  delete mode 100644 toolchain/gdb/gdb.mk
Quoted 1 line

Rename detection would have made this significantly easier to review :/

Yes I should really find out how to tell git send-email to *always* use -M. I don't even understand why this isn't the default.

Does anyone knows what the right ~/.gitconfig invocation to tell git send-email/format-patch to always enable rename detection?

Quoted 14 lines

Thomas> +config BR2_PACKAGE_GDB_DEBUGGER
Thomas> + bool "full debugger"
Thomas> + select BR2_PACKAGE_NCURSES
Thomas> + depends on BR2_USE_WCHAR
Thomas> + depends on BR2_TOOLCHAIN_HAS_THREADS
Thomas> + depends on BR2_TOOLCHAIN_HAS_THREADS_DEBUG
Thomas> + depends on !BR2_sh && !BR2_sh64 && !BR2_avr32 && !BR2_microblaze && !BR2_bfin && !BR2_aarch64
Thomas> +
Thomas> +comment "full gdb on target needs WCHAR, thread and thread debugging support in toolchain"
Thomas> + depends on !BR2_USE_WCHAR || !BR2_TOOLCHAIN_HAS_THREADS || \
Thomas> + !BR2_TOOLCHAIN_HAS_THREADS_DEBUG
Thomas> +
Thomas> +endif

Quoted 2 lines

This is afaik not correct (and now how it was before). Both gdbserver and full gdb need thread / thread debugging support for gdb 7.x.

Right, I'll add that.

Quoted 2 lines

It becomes a bit complicated as we only have the version selection if we're building gdb for the host though ..

For most architectures, 7.x is available, so I think we can decide to just assume that threads debug support is needed, if thread support is enabled.

Quoted 3 lines

From a usability POV, it's also a bit less handy when using the internal toolchain that you now need to go and enable the _HAS_THREADS_DEBUG option, but ok.

Yes, but there isn't much choice: now that gdb is a package, it has to comply with the policy we apply for all packages. "You don't select toolchain options, you depend on them".

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
#4 lore raw

PATCH v3 1/3 gdb: convert to the package infrastructure

Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni <[email protected]> writes:

Thanks, I like it - Unfortunately there's some issues (see below)

Thomas> Goodness doesn't come without a little bit of effort :-)

;)

Quoted 1 line
Quoted 1 line

Rename detection would have made this significantly easier to review :/

Thomas> Yes I should really find out how to tell git send-email to *always* use Thomas> -M. I don't even understand why this isn't the default.

Thomas> Does anyone knows what the right ~/.gitconfig invocation to tell git Thomas> send-email/format-patch to always enable rename detection?

I believe it's simply:

git config --global diff.renames copy

Thomas> +config BR2_PACKAGE_GDB_DEBUGGER
Thomas> + bool "full debugger"
Thomas> + select BR2_PACKAGE_NCURSES
Thomas> + depends on BR2_USE_WCHAR
Thomas> + depends on BR2_TOOLCHAIN_HAS_THREADS
Thomas> + depends on BR2_TOOLCHAIN_HAS_THREADS_DEBUG
Thomas> + depends on !BR2_sh && !BR2_sh64 && !BR2_avr32 && !BR2_microblaze && !BR2_bfin && !BR2_aarch64
Thomas> +
Thomas> +comment "full gdb on target needs WCHAR, thread and thread debugging support in toolchain"
Thomas> + depends on !BR2_USE_WCHAR || !BR2_TOOLCHAIN_HAS_THREADS || \
Thomas> + !BR2_TOOLCHAIN_HAS_THREADS_DEBUG
Thomas> +
Thomas> +endif

Quoted 3 lines
Quoted 3 lines

This is afaik not correct (and now how it was before). Both gdbserver and full gdb need thread / thread debugging support for gdb 7.x.

Thomas> Right, I'll add that.

Great!

Quoted 2 lines
Quoted 2 lines

It becomes a bit complicated as we only have the version selection if we're building gdb for the host though ..

Thomas> For most architectures, 7.x is available, so I think we can decide to Thomas> just assume that threads debug support is needed, if thread support is Thomas> enabled.

Indeed, possibly with an exception for avr32/bfin.

Quoted 3 lines
Quoted 3 lines

From a usability POV, it's also a bit less handy when using the internal toolchain that you now need to go and enable the _HAS_THREADS_DEBUG option, but ok.

Thomas> Yes, but there isn't much choice: now that gdb is a package, it Thomas> has to comply with the policy we apply for all packages. "You Thomas> don't select toolchain options, you depend on them".

Indeed, hence my "ok".

Signature · 1 line
Bye, Peter Korsgaard
#5 lore raw

PATCH v3 2/3 gdb: do not allow gdbserver/cross-gdb build in some cases

In reply to Thomas Petazzoni

When an external toolchain is used, and the user has chosen to copy the external toolchain gdbserver to the target, then we should allow the user to build a gdbserver and/or a cross-gdb: the ones of the external toolchain should be used.

The reasoning is that one must use a gdbserver and cross-gdb of identical versions to be sure that debugging will work properly.

Change suggested by Yann E. Morin.

---
 package/gdb/Config.in      |    8 +++++++-
 package/gdb/Config.in.host |    4 ++++
 2 files changed, 11 insertions(+), 1 deletion(-)
package/gdb/Config.in +7 -1
index 10ac7aa..3bf5827 100644
@@ -1,6 +1,11 @@
 config BR2_PACKAGE_GDB
 	bool "gdb"
-	select BR2_PACKAGE_GDB_SERVER if !BR2_PACKAGE_GDB_DEBUGGER
+	# When the external toolchain gdbserver is copied to the
+	# target, we don't allow building a sepaate gdbserver. The one
+	# from the external toolchain should be used.
+	select BR2_PACKAGE_GDB_SERVER if \
+	       (!BR2_PACKAGE_GDB_DEBUGGER && !BR2_TOOLCHAIN_EXTERNAL_GDB_SERVER_COPY)
+	select BR2_PACKAGE_GDB_DEBUGGER if BR2_TOOLCHAIN_EXTERNAL_GDB_SERVER_COPY
 	help
 	  GDB, the GNU Project debugger, allows you to see what is
 	  going on `inside' another program while it executes -- or
@@ -21,6 +26,7 @@ if BR2_PACKAGE_GDB
 
 config BR2_PACKAGE_GDB_SERVER
 	bool "gdbserver"
+	depends on !BR2_TOOLCHAIN_EXTERNAL_GDB_SERVER_COPY
 	help
 	  Build the gdbserver stub to run on the target.
 	  A full gdb is needed to debug the progam.
package/gdb/Config.in.host +4 -0
index 223c426..1e09263 100644
@@ -1,5 +1,9 @@
 config BR2_PACKAGE_HOST_GDB
 	bool "Build cross gdb for the host"
+	# When the external toolchain gdbserver is used, we shouldn't
+	# allow to build a cross-gdb, as the one of the external
+	# toolchain should be used.
+	depends on !BR2_TOOLCHAIN_EXTERNAL_GDB_SERVER_COPY
 	help
 	  Build a cross gdb that runs on the host machine and debugs
 	  programs running on the target. It requires 'gdbserver'
Signature · 1 line
1.7.9.5
#6 lore raw

PATCH v3 3/3 gdb: install gdbserver into the SDK

In reply to Thomas Petazzoni

In order for a Buildroot toolchain to be usable as an external toolchain, we should copy the target gdbserver somewhere into $(HOST_DIR). In order to match what Crosstool-NG does (and therefore to match something the external toolchain logic already understands), we install gdbserver in $(HOST_DIR)/usr/<tuple>/debug-root/usr/bin/gdbserver.

---
This replaces http://patchwork.ozlabs.org/patch/229438/

---
 package/gdb/gdb.mk |   14 ++++++++++++++
 1 file changed, 14 insertions(+)
package/gdb/gdb.mk +14 -0
index 24ce9bf..cec64d5 100644
@@ -78,6 +78,20 @@ endef
 
 GDB_POST_INSTALL_TARGET_HOOKS += GDB_REMOVE_UNNEEDED_FILES
 
+# This installs the gdbserver somewhere into the $(HOST_DIR) so that
+# it becomes an integral part of the SDK, if the toolchain generated
+# by Buildroot is later used as an external toolchain. We install it
+# in debug-root/usr/bin/gdbserver so that it matches what Crosstool-NG
+# does.
+define GDB_SDK_INSTALL_GDBSERVER
+	$(INSTALL) -D -m 0755 $(TARGET_DIR)/usr/bin/gdbserver \
+		$(HOST_DIR)/usr/$(GNU_TARGET_NAME)/debug-root/usr/bin/gdbserver
+endef
+
+ifeq ($(BR2_PACKAGE_GDB_SERVER),y)
+GDB_POST_INSTALL_TARGET_HOOKS += GDB_SDK_INSTALL_GDBSERVER
+endif
+
 # A few notes:
 #  * --target, because we're doing a cross build rather than a real
 #    host build.
Signature · 1 line
1.7.9.5