# HG changeset patch # User "Yann E. MORIN" # Date 1213889613 0 # Node ID 44b87fb3f0d388c7ad62b8623590a0185492a5db # Parent 522e4fe1ca75325acaa27f5e2a2a6571ce4055d8 A bunch of fixes/improvements to the gdb build: - allow native builds (both shared and static) - fix enabling threads - better handle the gdbserver case - introduce the ncurses library to allow native builds - re-order config options adequately /trunk/scripts/build/debug/300-gdb.sh | 126 79 47 0 ++++++++++++++++++++++++++--------------- /trunk/config/debug/gdb.in | 45 33 12 0 +++++++++++---- 2 files changed, 112 insertions(+), 59 deletions(-) diff -r 522e4fe1ca75 -r 44b87fb3f0d3 config/debug/gdb.in --- a/config/debug/gdb.in Thu Jun 19 15:31:04 2008 +0000 +++ b/config/debug/gdb.in Thu Jun 19 15:33:33 2008 +0000 @@ -13,38 +13,59 @@ bool prompt "Cross-gdb" default y + select GDB_GDBSERVER help - Build and install a cross-gdb for the target, and to run on host. + Build and install a cross-gdb for the target, to run on host. -config GDB_CROSS_STATIC_GDB +config GDB_CROSS_STATIC bool prompt "Build a static cross gdb" default n depends on GDB_CROSS help A static cross gdb can be usefull if you debug on a machine that is - not the one that is used to compile. + not the one that is used to compile the toolchain. -config GDB_CROSS_STATIC_GDBSERVER + That way, you can share the cross-gdb without installing a toolchain + on every machine that will be used to debug target programs. + +config GDB_NATIVE + bool + prompt "Native gdb" + default n + select GDB_GDBSERVER + help + Build and install a native gdb for the target, to run on the target. + +config GDB_NATIVE_STATIC + bool + prompt "Build a static native gdb" + default n + depends on GDB_NATIVE + help + In case you have trouble with dynamic loading of shared libraries, + you will find that a static gdb comes in handy. + +config GDB_GDBSERVER + bool + prompt "gdbserver" + default n + help + Build and install a gdbserver for the target, to run on the target. + +config GDB_GDBSERVER_STATIC bool prompt "Build a static gdbserver" default n - depends on GDB_CROSS + depends on GDB_GDBSERVER help In case you have trouble with dynamic loading of shared libraries, you will find that a static gdbserver comes in handy. -config GDB_NATIVE - bool - prompt "Native gdb (EXPERIMENTAL)" - default n - depends on EXPERIMENTAL - help - Build and install a native gdb for the target, to run on the target. - choice bool prompt "gdb version" + depends on GDB_CROSS || GDB_NATIVE || GDB_GDBSERVER config GDB_V_snapshot bool @@ -118,6 +139,6 @@ default "4.2" if NCURSES_V_4_2 default "5.6" if NCURSES_V_5_6 -endif # ncurses +endif # GDB_NATIVE --> ncurses endif diff -r 522e4fe1ca75 -r 44b87fb3f0d3 scripts/build/debug/300-gdb.sh --- a/scripts/build/debug/300-gdb.sh Thu Jun 19 15:31:04 2008 +0000 +++ b/scripts/build/debug/300-gdb.sh Thu Jun 19 15:33:33 2008 +0000 @@ -47,22 +47,29 @@ mkdir -p "${CT_BUILD_DIR}/build-gdb-cross" cd "${CT_BUILD_DIR}/build-gdb-cross" + if [ "${CT_CC_GCC_GMP_MPFR}" = "y" ]; then + extra_config="${extra_config} --with-gmp=${CT_PREFIX_DIR} --with-mpfr=${CT_PREFIX_DIR}" + fi + case "${CT_THREADS}" in + none) extra_config="${extra_config} --disable-threads";; + *) extra_config="${extra_config} --enable-threads";; + esac + CC_for_gdb= LD_for_gdb= - if [ "${CT_GDB_CROSS_STATIC_GDBSERVER}" = "y" ]; then + if [ "${CT_GDB_CROSS_STATIC}" = "y" ]; then CC_for_gdb="gcc -static" LD_for_gdb="ld -static" fi CC="${CC_for_gdb}" \ - LD="${LD_forgdb}" \ + LD="${LD_for_gdb}" \ "${gdb_src_dir}/configure" \ --build=${CT_BUILD} \ --host=${CT_HOST} \ --target=${CT_TARGET} \ --prefix="${CT_PREFIX_DIR}" \ --with-build-sysroot="${CT_SYSROOT_DIR}" \ - --enable-threads \ ${extra_config} 2>&1 |CT_DoLog ALL CT_DoLog EXTRA "Building cross-gdb" @@ -72,48 +79,6 @@ make install 2>&1 |CT_DoLog ALL CT_EndStep - - CT_DoStep INFO "Installing gdbserver" - CT_DoLog EXTRA "Configuring gdbserver" - - mkdir -p "${CT_BUILD_DIR}/build-gdb-gdbserver" - cd "${CT_BUILD_DIR}/build-gdb-gdbserver" - - # Workaround for bad versions, where the configure - # script for gdbserver is not executable... - # Bah, GNU folks strike again... :-( - chmod +x "${gdb_src_dir}/gdb/gdbserver/configure" - - gdbserver_LDFLAGS= - if [ "${CT_GDB_CROSS_STATIC_GDBSERVER}" = "y" ]; then - gdbserver_LDFLAGS=-static - fi - - LDFLAGS="${gdbserver_LDFLAGS}" \ - "${gdb_src_dir}/gdb/gdbserver/configure" \ - --build=${CT_BUILD} \ - --host=${CT_TARGET} \ - --target=${CT_TARGET} \ - --prefix=/usr \ - --sysconfdir=/etc \ - --localstatedir=/var \ - --includedir="${CT_HEADERS_DIR}" \ - --with-build-sysroot="${CT_SYSROOT_DIR}" \ - --program-prefix= \ - --without-uiout \ - --disable-tui \ - --disable-gdbtk \ - --without-x \ - --without-included-gettext \ - ${extra_config} 2>&1 |CT_DoLog ALL - - CT_DoLog EXTRA "Building gdbserver" - make ${PARALLELMFLAGS} CC=${CT_TARGET}-${CT_CC} 2>&1 |CT_DoLog ALL - - CT_DoLog EXTRA "Installing gdbserver" - make DESTDIR="${CT_DEBUG_INSTALL_DIR}" install 2>&1 |CT_DoLog ALL - - CT_EndStep fi if [ "${CT_GDB_NATIVE}" = "y" ]; then @@ -138,7 +103,6 @@ --without-sysmouse \ --without-progs \ --enable-termcap \ - --without-develop \ ${ncurses_opts} 2>&1 |CT_DoLog ALL CT_DoLog EXTRA "Building ncurses" @@ -155,6 +119,22 @@ mkdir -p "${CT_BUILD_DIR}/build-gdb-native" cd "${CT_BUILD_DIR}/build-gdb-native" + case "${CT_THREADS}" in + none) extra_config="${extra_config} --disable-threads";; + *) extra_config="${extra_config} --enable-threads";; + esac + + CC_for_gdb= + LD_for_gdb= + if [ "${CT_GDB_NATIVE_STATIC}" = "y" ]; then + CC_for_gdb="${CT_TARGET}-gcc -static" + LD_for_gdb="${CT_TARGET}-ld -static" + fi + + export ac_cv_func_strncmp_works=yes + + CC="${CC_for_gdb}" \ + LD="${LD_for_gdb}" \ "${gdb_src_dir}/configure" \ --build=${CT_BUILD} \ --host=${CT_TARGET} \ @@ -166,8 +146,9 @@ --disable-gdbtk \ --without-x \ --disable-sim \ - --disable-gdbserver \ + --disable-werror \ --without-included-gettext \ + --without-develop \ ${extra_config} 2>&1 |CT_DoLog ALL CT_DoLog EXTRA "Building native gdb" @@ -176,6 +157,57 @@ CT_DoLog EXTRA "Installing native gdb" make DESTDIR="${CT_DEBUG_INSTALL_DIR}" install 2>&1 |CT_DoLog ALL + # Building a native gdb also builds a gdbserver + CT_DoLog DEBUG "Removing spurious gdbserver" + find "${CT_DEBUG_INSTALL_DIR}" -type f -name gdbserver -exec rm -fv {} + 2>&1 |CT_DoLog ALL + + unset ac_cv_func_strncmp_works + + CT_EndStep + fi + + if [ "${CT_GDB_GDBSERVER}" = "y" ]; then + CT_DoStep INFO "Installing gdbserver" + CT_DoLog EXTRA "Configuring gdbserver" + + mkdir -p "${CT_BUILD_DIR}/build-gdb-gdbserver" + cd "${CT_BUILD_DIR}/build-gdb-gdbserver" + + # Workaround for bad versions, where the configure + # script for gdbserver is not executable... + # Bah, GNU folks strike again... :-( + chmod +x "${gdb_src_dir}/gdb/gdbserver/configure" + + gdbserver_LDFLAGS= + if [ "${CT_GDB_GDBSERVER_STATIC}" = "y" ]; then + gdbserver_LDFLAGS=-static + fi + + LDFLAGS="${gdbserver_LDFLAGS}" \ + "${gdb_src_dir}/gdb/gdbserver/configure" \ + --build=${CT_BUILD} \ + --host=${CT_TARGET} \ + --target=${CT_TARGET} \ + --prefix=/usr \ + --sysconfdir=/etc \ + --localstatedir=/var \ + --includedir="${CT_HEADERS_DIR}" \ + --with-build-sysroot="${CT_SYSROOT_DIR}" \ + --program-prefix= \ + --without-uiout \ + --disable-tui \ + --disable-gdbtk \ + --without-x \ + --without-included-gettext \ + --without-develop \ + ${extra_config} 2>&1 |CT_DoLog ALL + + CT_DoLog EXTRA "Building gdbserver" + make ${PARALLELMFLAGS} CC=${CT_TARGET}-${CT_CC} 2>&1 |CT_DoLog ALL + + CT_DoLog EXTRA "Installing gdbserver" + make DESTDIR="${CT_DEBUG_INSTALL_DIR}" install 2>&1 |CT_DoLog ALL + CT_EndStep fi }