Skip to contentSkip to conversation

gdb: enable simulator support for host build

PATCH Superseded Waldemar Brodkorb 2 participants 2 messages May 28, 2016 – May 31, 2016

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 gdb: enable simulator support for host build

Add an option to enable simulator support, so
it can be used to test some no-MMU systems.

Newer GDB need a workaround for in-tree compile.

---
v2 -> v3:
- add workaround for GDB bug when in-tree compile is used, problem reported by Thomas Petazzoni
- tested with GDB 7.9, 7.10.1, 7.11
v1 -> v2:
- no changes

---
 package/gdb/Config.in.host |  5 +++++
 package/gdb/gdb.mk         | 15 +++++++++++++--
 2 files changed, 18 insertions(+), 2 deletions(-)
package/gdb/Config.in.host +5 -0
index 257d68a..dc149b6 100644
@@ -23,6 +23,11 @@ config BR2_PACKAGE_HOST_GDB_PYTHON
 	help
 	  This option enables the Python support in the cross gdb.
 
+config BR2_PACKAGE_HOST_GDB_SIM
+	bool "Simulator support"
+	help
+	  This option enables the simulator support in the cross gdb.
+
 choice
 	prompt "GDB debugger Version"
 	depends on !BR2_arc
package/gdb/gdb.mk +13 -2
index 0a7af1e..83b1701 100644
@@ -163,8 +163,7 @@ HOST_GDB_CONF_OPTS = \
 	--enable-threads \
 	--disable-werror \
 	--without-included-gettext \
-	$(GDB_DISABLE_BINUTILS_CONF_OPTS) \
-	--disable-sim
+	$(GDB_DISABLE_BINUTILS_CONF_OPTS)
 
 ifeq ($(BR2_PACKAGE_HOST_GDB_TUI),y)
 HOST_GDB_CONF_OPTS += --enable-tui
@@ -179,6 +178,18 @@ else
 HOST_GDB_CONF_OPTS += --without-python
 endif
 
+# workaround a bug if in-tree build is used
+define GDB_SIM_WORKAROUND
+	$(RM) $(@D)/sim/common/tconfig.h
+endef
+
+ifeq ($(BR2_PACKAGE_HOST_GDB_SIM),y)
+HOST_GDB_CONF_OPTS += --enable-sim
+HOST_GDB_PRE_CONFIGURE_HOOKS += GDB_SIM_WORKAROUND
+else
+HOST_GDB_CONF_OPTS += --disable-sim
+endif
+
 # legacy $arch-linux-gdb symlink
 define HOST_GDB_ADD_SYMLINK
 	cd $(HOST_DIR)/usr/bin && \
Signature · 1 line
2.1.4
#1 lore raw

PATCH v3 1/1 gdb: enable simulator support for host build

Hello,

Quoted 6 lines · Waldemar Brodkorb

Add an option to enable simulator support, so
it can be used to test some no-MMU systems.

Newer GDB need a workaround for in-tree compile.

This new version still doesn't build with gdb 7.10 (i.e the default). It fails with:

In file included from ./../common/callback.c:24:0:
./../common/cconfig.h:212:21: fatal error: tconfig.h: No such file or directory
compilation terminated.
Makefile:531: recipe for target 'callback.o' failed
make[5]: *** [callback.o] Error 1
make[5]: *** Waiting for unfinished jobs....
In file included from ./../common/syscall.c:27:0:
./../common/cconfig.h:212:21: fatal error: tconfig.h: No such file or directory
compilation terminated.
In file included from wrapper.c:23:0:
config.h:161:21: fatal error: tconfig.h: No such file or directory
compilation terminated.
In file included from targ-map.c:4:0:
config.h:161:21: fatal error: tconfig.h: No such file or directory
Makefile:531: recipe for target 'syscall.o' failed
compilation terminated.
make[5]: *** [syscall.o] Error 1
Makefile:531: recipe for target 'targ-map.o' failed
make[5]: *** [targ-map.o] Error 1
Makefile:531: recipe for target 'wrapper.o' failed
make[5]: *** [wrapper.o] Error 1
Makefile:129: recipe for target 'all' failed
make[4]: *** [all] Error 1
Makefile:8201: recipe for target 'all-sim' failed
make[3]: *** [all-sim] Error 2
Makefile:845: recipe for target 'all' failed
make[2]: *** [all] Error 2
package/pkg-generic.mk:195: recipe for target '/home/thomas/projets/buildroot/output/build/host-gdb-7.10.1/.stamp_built' failed make[1]: *** [/home/thomas/projets/buildroot/output/build/host-gdb-7.10.1/.stamp_built] Error 2 Makefile:36: recipe for target '_all' failed
make: *** [_all] Error 2

Using the following defconfig:

BR2_arm=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y BR2_TOOLCHAIN_EXTERNAL_URL="http://autobuild.buildroot.org/toolchains/tarballs/br-arm-full-2016.05-rc2-3-g011d4e2.tar.bz2" BR2_TOOLCHAIN_EXTERNAL_GCC_4_8=y
BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_10=y
BR2_TOOLCHAIN_EXTERNAL_LOCALE=y
# BR2_TOOLCHAIN_EXTERNAL_HAS_THREADS_DEBUG is not set
BR2_TOOLCHAIN_EXTERNAL_INET_RPC=y
BR2_TOOLCHAIN_EXTERNAL_CXX=y
BR2_PACKAGE_HOST_GDB=y
BR2_PACKAGE_HOST_GDB_SIM=y
BR2_INIT_NONE=y
BR2_SYSTEM_BIN_SH_NONE=y
# BR2_PACKAGE_BUSYBOX is not set
# BR2_TARGET_ROOTFS_TAR is not set

Quoted 1 line

+# workaround a bug if in-tree build is used

If I understood correctly, it has been fixed in newer versions of gdb, right? If that's the case, please indicate here in which version it has been fixed, so that we can remove this workaround at some point in the future.

Quoted 1 line

+define GDB_SIM_WORKAROUND

It would be better named HOST_GDB_SIM_WORKAROUND.

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com