scripts/build/debug/300-gdb.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Thu Apr 15 20:00:23 2010 +0200 (2010-04-15)
changeset 1916 e5b635bb9290
parent 1901 bdb3a98e064b
child 1939 39fce98b3747
permissions -rw-r--r--
debug/gdb: remove insight

Insight seems to be very slow to follow up on mainstreram gdb.
Latest snapshots are more than 6 months old.

Moreover, I don't have time to maintain insight support in crosstool-NG;
and, because I don't use it, I am unable to find any breakage.
     1 # Build script for the gdb debug facility
     2 
     3 # The version of ncurses to use. Yes, it's hard-coded.
     4 # It's used only internally by crosstool-NG, and is
     5 # not exposed outside, so we don't care about providing
     6 # config options for this.
     7 CT_DEBUG_GDB_NCURSES_VERSION="5.7"
     8 
     9 do_debug_gdb_parts() {
    10     do_gdb=
    11     do_ncurses=
    12 
    13     if [ "${CT_GDB_CROSS}" = y ]; then
    14         do_gdb=y
    15     fi
    16 
    17     if [ "${CT_GDB_GDBSERVER}" = "y" ]; then
    18         do_gdb=y
    19     fi
    20 
    21     if [ "${CT_GDB_NATIVE}" = "y" ]; then
    22         do_gdb=y
    23         do_ncurses=y
    24     fi
    25 }
    26 
    27 do_debug_gdb_get() {
    28     do_debug_gdb_parts
    29 
    30     if [ "${do_gdb}" = "y" ]; then
    31         CT_GetFile "gdb-${CT_GDB_VERSION}"                          \
    32                    {ftp,http}://ftp.gnu.org/pub/gnu/gdb             \
    33                    ftp://sources.redhat.com/pub/gdb/{,old-}releases
    34     fi
    35 
    36     if [ "${do_ncurses}" = "y" ]; then
    37         CT_GetFile "ncurses-${CT_DEBUG_GDB_NCURSES_VERSION}" .tar.gz  \
    38                    {ftp,http}://ftp.gnu.org/pub/gnu/ncurses \
    39                    ftp://invisible-island.net/ncurses
    40     fi
    41 }
    42 
    43 do_debug_gdb_extract() {
    44     do_debug_gdb_parts
    45 
    46     if [ "${do_gdb}" = "y" ]; then
    47         CT_Extract "gdb-${CT_GDB_VERSION}"
    48         CT_Patch "gdb" "${CT_GDB_VERSION}"
    49     fi
    50 
    51     if [ "${do_ncurses}" = "y" ]; then
    52         CT_Extract "ncurses-${CT_DEBUG_GDB_NCURSES_VERSION}"
    53         CT_Patch "ncurses" "${CT_DEBUG_GDB_NCURSES_VERSION}"
    54     fi
    55 }
    56 
    57 do_debug_gdb_build() {
    58     local -a extra_config
    59 
    60     gdb_src_dir="${CT_SRC_DIR}/gdb-${CT_GDB_VERSION}"
    61 
    62     # Version 6.3 and below behave badly with gdbmi
    63     case "${CT_GDB_VERSION}" in
    64         6.2*|6.3)   extra_config+=("--disable-gdbmi");;
    65     esac
    66 
    67     if [ "${CT_GDB_CROSS}" = "y" ]; then
    68         local -a cross_extra_config
    69 
    70         CT_DoStep INFO "Installing cross-gdb"
    71         CT_DoLog EXTRA "Configuring cross-gdb"
    72 
    73         mkdir -p "${CT_BUILD_DIR}/build-gdb-cross"
    74         cd "${CT_BUILD_DIR}/build-gdb-cross"
    75 
    76         cross_extra_config=("${extra_config[@]}")
    77         if [ "${CT_GDB_CROSS_USE_GMP_MPFR}" = "y" ]; then
    78             cross_extra_config+=("--with-gmp=${CT_PREFIX_DIR}")
    79             cross_extra_config+=("--with-mpfr=${CT_PREFIX_DIR}")
    80         fi
    81         if [ "${CT_GDB_CROSS_USE_MPC}" = "y" ]; then
    82             cross_extra_config+=("--with-mpc=${CT_PREFIX_DIR}")
    83         fi
    84         case "${CT_THREADS}" in
    85             none)   cross_extra_config+=("--disable-threads");;
    86             *)      cross_extra_config+=("--enable-threads");;
    87         esac
    88 
    89         CC_for_gdb=
    90         LD_for_gdb=
    91         if [ "${CT_GDB_CROSS_STATIC}" = "y" ]; then
    92             CC_for_gdb="gcc -static"
    93             LD_for_gdb="ld -static"
    94         fi
    95 
    96         gdb_cross_configure="${gdb_src_dir}/configure"
    97 
    98         CT_DoLog DEBUG "Extra config passed: '${cross_extra_config[*]}'"
    99 
   100         CC="${CC_for_gdb}"                              \
   101         LD="${LD_for_gdb}"                              \
   102         CT_DoExecLog ALL                                \
   103         "${gdb_cross_configure}"                        \
   104             --build=${CT_BUILD}                         \
   105             --host=${CT_HOST}                           \
   106             --target=${CT_TARGET}                       \
   107             --prefix="${CT_PREFIX_DIR}"                 \
   108             --with-build-sysroot="${CT_SYSROOT_DIR}"    \
   109             --disable-werror                            \
   110             "${cross_extra_config[@]}"
   111 
   112         CT_DoLog EXTRA "Building cross-gdb"
   113         CT_DoExecLog ALL make ${PARALLELMFLAGS}
   114 
   115         CT_DoLog EXTRA "Installing cross-gdb"
   116         CT_DoExecLog ALL make install
   117 
   118         CT_EndStep
   119     fi
   120 
   121     if [ "${CT_GDB_NATIVE}" = "y" ]; then
   122         local -a native_extra_config
   123         local -a ncurses_opt
   124 
   125         CT_DoStep INFO "Installing native gdb"
   126 
   127         CT_DoStep INFO "Installing ncurses library"
   128 
   129         [ "${CT_CC_LANG_CXX}" = "y" ] || ncurses_opts+=("--without-cxx" "--without-cxx-binding")
   130         [ "${CT_CC_LANG_ADA}" = "y" ] || ncurses_opts+=("--without-ada")
   131 
   132         CT_DoStep INFO "Installing native ncurses tic"
   133         CT_DoLog EXTRA "Configuring ncurses tic"
   134         mkdir -p "${CT_BUILD_DIR}/build-ncurses-build-tic"
   135         cd "${CT_BUILD_DIR}/build-ncurses-build-tic"
   136 
   137         # Use build = CT_REAL_BUILD so that configure thinks it is
   138         # cross-compiling, and thus will use the ${CT_BUILD}-*
   139         # tools instead of searching for the native ones...
   140         CT_DoExecLog ALL                                                    \
   141         "${CT_SRC_DIR}/ncurses-${CT_DEBUG_GDB_NCURSES_VERSION}/configure"   \
   142             --build=${CT_BUILD}                                             \
   143             --host=${CT_BUILD}                                              \
   144             --prefix=/usr                                                   \
   145             --without-shared                                                \
   146             --enable-symlinks                                               \
   147             --with-build-cc=${CT_REAL_BUILD}-gcc                            \
   148             --with-build-cpp=${CT_REAL_BUILD}-gcc                           \
   149             --with-build-cflags="${CT_CFLAGS_FOR_HOST}"                     \
   150             "${ncurses_opts[@]}"
   151 
   152         # Under some operating systems (eg. Winblows), there is an
   153         # extension appended to executables. Find that.
   154         tic_ext=$(grep -E '^x[[:space:]]*=' progs/Makefile |sed -r -e 's/^.*=[[:space:]]*//;')
   155 
   156         CT_DoLog EXTRA "Building ncurses tic"
   157         CT_DoExecLog ALL make ${PARALLELMFLAGS} -C include
   158         CT_DoExecLog ALL make ${PARALLELMFLAGS} -C progs "tic${tic_ext}"
   159 
   160         CT_DoLog EXTRA "Installing ncurses tic"
   161         CT_DoExecLog ALL install -d -m 0755 "${CT_PREFIX_DIR}/bin"
   162         CT_DoExecLog ALL install -m 0755 "progs/tic${tic_ext}" "${CT_PREFIX_DIR}/bin"
   163 
   164         CT_EndStep # tic build
   165 
   166         CT_DoLog EXTRA "Configuring ncurses"
   167         mkdir -p "${CT_BUILD_DIR}/build-ncurses"
   168         cd "${CT_BUILD_DIR}/build-ncurses"
   169 
   170         CT_DoExecLog ALL                                                    \
   171         "${CT_SRC_DIR}/ncurses-${CT_DEBUG_GDB_NCURSES_VERSION}/configure"   \
   172             --build=${CT_BUILD}                                             \
   173             --host=${CT_TARGET}                                             \
   174             --with-build-cc=${CT_BUILD}-gcc                                 \
   175             --with-build-cpp=${CT_BUILD}-gcc                                \
   176             --with-build-cflags="${CT_CFLAGS_FOR_HOST}"                     \
   177             --prefix="${CT_BUILD_DIR}/ncurses"                              \
   178             --without-shared                                                \
   179             --without-sysmouse                                              \
   180             --without-progs                                                 \
   181             --enable-termcap                                                \
   182             "${ncurses_opts[@]}"
   183 
   184         CT_DoLog EXTRA "Building ncurses"
   185         CT_DoExecLog ALL make ${PARALLELMFLAGS}
   186 
   187         CT_DoLog EXTRA "Installing ncurses"
   188         CT_DoExecLog ALL make install
   189 
   190         # We no longer need the temporary tic. Remove it
   191         CT_DoExecLog DEBUG rm -fv "${CT_PREFIX_DIR}/bin/tic"
   192 
   193         CT_EndStep # ncurses build
   194 
   195         CT_DoLog EXTRA "Configuring native gdb"
   196 
   197         mkdir -p "${CT_BUILD_DIR}/build-gdb-native"
   198         cd "${CT_BUILD_DIR}/build-gdb-native"
   199 
   200         native_extra_config=("${extra_config[@]}")
   201         case "${CT_THREADS}" in
   202             none)   native_extra_config+=("--disable-threads");;
   203             *)      native_extra_config+=("--enable-threads");;
   204         esac
   205         if [ "${CT_GDB_NATIVE_USE_GMP_MPFR}" = "y" ]; then
   206             native_extra_config+=("--with-gmp=${CT_SYSROOT_DIR}/usr")
   207             native_extra_config+=("--with-mpfr=${CT_SYSROOT_DIR}/usr")
   208         fi
   209 
   210         if [ "${CT_GDB_NATIVE_STATIC}" = "y" ]; then
   211             CC_for_gdb="${CT_TARGET}-gcc -static"
   212             LD_for_gdb="${CT_TARGET}-ld -static"
   213         else
   214             CC_for_gdb="${CT_TARGET}-gcc"
   215             LD_for_gdb="${CT_TARGET}-ld"
   216         fi
   217 
   218         export ac_cv_func_strncmp_works=yes
   219 
   220         gdb_native_CFLAGS="-I${CT_BUILD_DIR}/ncurses/include -L${CT_BUILD_DIR}/ncurses/lib"
   221 
   222         CT_DoLog DEBUG "Extra config passed: '${native_extra_config[*]}'"
   223 
   224         CC="${CC_for_gdb}"                              \
   225         LD="${LD_for_gdb}"                              \
   226         CFLAGS="${gdb_native_CFLAGS}"                   \
   227         CT_DoExecLog ALL                                \
   228         "${gdb_src_dir}/configure"                      \
   229             --build=${CT_BUILD}                         \
   230             --host=${CT_TARGET}                         \
   231             --target=${CT_TARGET}                       \
   232             --prefix=/usr                               \
   233             --with-build-sysroot="${CT_SYSROOT_DIR}"    \
   234             --without-uiout                             \
   235             --disable-tui                               \
   236             --disable-gdbtk                             \
   237             --without-x                                 \
   238             --disable-sim                               \
   239             --disable-werror                            \
   240             --without-included-gettext                  \
   241             --without-develop                           \
   242             "${native_extra_config[@]}"
   243 
   244         CT_DoLog EXTRA "Building native gdb"
   245         CT_DoExecLog ALL make ${PARALLELMFLAGS} CC=${CT_TARGET}-${CT_CC}
   246 
   247         CT_DoLog EXTRA "Installing native gdb"
   248         CT_DoExecLog ALL make DESTDIR="${CT_DEBUGROOT_DIR}" install
   249 
   250         # Building a native gdb also builds a gdbserver
   251         find "${CT_DEBUGROOT_DIR}" -type f -name gdbserver -exec rm -fv {} \; 2>&1 |CT_DoLog ALL
   252 
   253         unset ac_cv_func_strncmp_works
   254 
   255         CT_DoLog EXTRA "Cleaning up ncurses"
   256         cd "${CT_BUILD_DIR}/build-ncurses"
   257         CT_DoExecLog ALL make DESTDIR="${CT_SYSROOT_DIR}" uninstall
   258 
   259         CT_DoExecLog DEBUG rm -rf "${CT_BUILD_DIR}/ncurses"
   260 
   261         CT_EndStep # native gdb build
   262     fi
   263 
   264     if [ "${CT_GDB_GDBSERVER}" = "y" ]; then
   265         local -a gdbserver_extra_config
   266 
   267         CT_DoStep INFO "Installing gdbserver"
   268         CT_DoLog EXTRA "Configuring gdbserver"
   269 
   270         mkdir -p "${CT_BUILD_DIR}/build-gdb-gdbserver"
   271         cd "${CT_BUILD_DIR}/build-gdb-gdbserver"
   272 
   273         # Workaround for bad versions, where the configure
   274         # script for gdbserver is not executable...
   275         # Bah, GNU folks strike again... :-(
   276         chmod +x "${gdb_src_dir}/gdb/gdbserver/configure"
   277 
   278         gdbserver_LDFLAGS=
   279         if [ "${CT_GDB_GDBSERVER_STATIC}" = "y" ]; then
   280             gdbserver_LDFLAGS=-static
   281         fi
   282 
   283         gdbserver_extra_config=("${extra_config[@]}")
   284 
   285         LDFLAGS="${gdbserver_LDFLAGS}"                  \
   286         CT_DoExecLog ALL                                \
   287         "${gdb_src_dir}/gdb/gdbserver/configure"        \
   288             --build=${CT_BUILD}                         \
   289             --host=${CT_TARGET}                         \
   290             --target=${CT_TARGET}                       \
   291             --prefix=/usr                               \
   292             --sysconfdir=/etc                           \
   293             --localstatedir=/var                        \
   294             --includedir="${CT_HEADERS_DIR}"            \
   295             --with-build-sysroot="${CT_SYSROOT_DIR}"    \
   296             --program-prefix=                           \
   297             --without-uiout                             \
   298             --disable-tui                               \
   299             --disable-gdbtk                             \
   300             --without-x                                 \
   301             --without-included-gettext                  \
   302             --without-develop                           \
   303             --disable-werror                            \
   304             "${gdbserver_extra_config[@]}"
   305 
   306         CT_DoLog EXTRA "Building gdbserver"
   307         CT_DoExecLog ALL make ${PARALLELMFLAGS} CC=${CT_TARGET}-${CT_CC}
   308 
   309         CT_DoLog EXTRA "Installing gdbserver"
   310         CT_DoExecLog ALL make DESTDIR="${CT_DEBUGROOT_DIR}" install
   311 
   312         CT_EndStep
   313     fi
   314 }