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