Import of gdb 7.3.1

Change-Id: I504ac949581b96a04cb1d4b7677a93ee3d0e2ec9
This commit is contained in:
2013-07-12 18:49:51 +02:00
parent 714dd83efe
commit 6fee514a1b
499 changed files with 394102 additions and 1 deletions

89
tools/gdb/Makefile Normal file
View File

@@ -0,0 +1,89 @@
# $NetBSD: Makefile,v 1.22 2012/10/01 19:27:04 bouyer Exp $
.include <bsd.own.mk>
MODULE= gdb
GNUHOSTDIST= ${.CURDIR}/../../external/gpl3/gdb/dist
FIND_ARGS= \! \( -type d -name sim -prune \)
CONFIGURE_ARGS= --target=${MACHINE_GNU_PLATFORM} --disable-nls \
--program-transform-name="s,^,${MACHINE_GNU_PLATFORM}-,"
MAKE_ARGS= MACHINE= MAKEINFO=${TOOL_MAKEINFO:Q}
ALL_TARGET= all-gdb
INSTALL_TARGET= install-gdb
.include "${.CURDIR}/../Makefile.gmakehost"
CCADDFLAGS= --sysroot=${DESTDIR} -L${DESTDIR}/lib -L${DESTDIR}/usr/lib -B${DESTDIR}/usr/lib/ -I${.OBJDIR}/.native/gcc/include
NEWCONFIGDIR?= ${.CURDIR}/../..
MKNATIVE?= ${.CURDIR}/mknative-gdb
# Some configure tests require running a test program, which is not
# possible when cross-building. Provide configure with "cached"
# values in the environment.
MKNATIVE_CONFIGURE_PRESET= \
ac_cv_prog_cc_cross=yes \
ac_cv_func_fork_works=yes \
ac_cv_func_strcoll_works=yes \
bash_cv_func_ctype_nonascii=yes \
bash_cv_func_sigsetjmp=present \
bash_cv_func_strcoll_broken=no \
bash_cv_must_reinstall_sighandlers=no
# Recent versions of Solaris have ncurses, but they hide the lib in an
# odd directory. Prevent configure from finding the ncurses headers,
# Solaris curses is sufficient.
.if ${BUILD_OSTYPE} == "SunOS"
CONFIGURE_ENV+= ac_cv_header_ncurses_h=no \
ac_cv_header_ncurses_ncurses_h=no \
ac_cv_header_ncurses_term_h=no
.endif
# Disable sim unless it's known to work (configure's default is to
# enable sim if supported).
CONFIGURE_ARGS_SIM=
.if \
${MACHINE_CPU} != "powerpc" && \
${MACHINE_CPU} != "powerpc64"
CONFIGURE_ARGS_SIM+= --disable-sim
.endif
native-gdb: .native/.configure_done
@echo 'Extracting GDB configury for a native toolchain.'
MAKE=${MAKE:Q} ${HOST_SH} ${MKNATIVE} gdb \
${.OBJDIR}/.native ${NEWCONFIGDIR} ${MACHINE_GNU_PLATFORM}
.native/.configure_done: ${_GNU_CFGSRC} ${.CURDIR}/Makefile
mkdir ${.OBJDIR}/.native 2>/dev/null || true
PATH=${TOOLDIR}/bin:$$PATH; export PATH; \
(cd ${.OBJDIR}/.native && ${CONFIGURE_ENV:NC*:NLD*} \
CC_FOR_BUILD=${HOST_CC:Q} \
CC=${CC:Q}' '${CCADDFLAGS:Q} \
CXX=${CXX:Q}' '${CCADDFLAGS:Q} \
CPP=${CPP:Q}' '-isystem' '${DESTDIR}/usr/include \
CFLAGS= CPPFLAGS= CXXFLAGS= LDFLAGS=${LDADDFLAGS:Q} \
MSGFMT=${TOOLDIR}/bin/${_TOOL_PREFIX}msgfmt \
XGETTEXT=${TOOLDIR}/bin/${_TOOL_PREFIX}xgettext \
LIBS=-lintl \
${MKNATIVE_CONFIGURE_PRESET} \
${HOST_SH} ${GNUHOSTDIST}/configure \
--prefix=/usr \
--with-separate-debug-dir=/usr/libdata/debug \
${CONFIGURE_ARGS_SIM} \
--build=`${GNUHOSTDIST}/config.guess` \
--host=${MACHINE_GNU_PLATFORM} \
--target=${MACHINE_GNU_PLATFORM}) && \
(cd ${.OBJDIR}/.native && \
/usr/bin/env ${MKNATIVE_CONFIGURE_PRESET} \
${MAKE} configure-host) && \
(cd ${.OBJDIR}/.native/bfd && ${MAKE} bfd.h bfdver.h) && \
(cd ${.OBJDIR}/.native/gdb && ${MAKE} init.c version.c)
@touch $@
clean: clean.native
clean.native:
-rm -r -f .native

47
tools/gdb/README.mknative Normal file
View File

@@ -0,0 +1,47 @@
$NetBSD: README.mknative,v 1.5 2011/09/26 02:36:19 christos Exp $
This file describes how to use the cross-compiler to generate the
native files for GDB on a target platform.
NOTE: DO NOT RUN "mknative" BY HAND! It requires the Makefile in this
directory to set up certain environments first.
Since libc's features change over time, the config.h files can change as a
result; thus the instructions below are the same no matter whether
bootstrapping on a cross or native host. This is important: even on a
"native" host, you should bootstrap the toolchain by building from an
up-to-date source tree to a $DESTDIR using the exact same instructions.
In these notes, MACHINE is the $MACHINE of the target. These files can be
cross-generated. Though a $MACHINE_ARCH all uses the same config files, you
must pick a specific $MACHINE so that building the requisite bits below will
work.
1. Set MKMAINTAINERTOOLS=yes in mk.conf. (Needed so that src/tools/gettext
gets built, eliciting proper HAVE_*GETTEXT* defns in config.h files.)
2. Build and install a cross toolchain (via "build.sh -m MACHINE tools").
3. At top level, do "nbmake-MACHINE do-distrib-dirs obj includes".
4. In src/gnu/lib/crtstuff4 do "nbmake-MACHINE depend all install"
5. In src/lib/csu, src/gnu/lib/libgcc4, and src/lib, do
"nbmake-MACHINE all install".
6. In src/tools/gdb, do "nbmake-MACHINE obj native-gdb".
This will do a full configury in ${.OBJDIR}/.native that is a "Canadian"
cross toolchain (--build reflects the host platform, but --host and
--target are the target). The result is a tree that would build a
native-to-NetBSD GDB on a cross host, and mknative pulls glue data
from this.
NOTE: this step writes files under src/external/gpl3/gdb/bin/gdb, so you
need to do it in a writable src tree!
7. Try out a full build using "nbmake-MACHINE" in
src/external/gpl3/bin/gdb; the result should include a native GDB.
8. If all is well, commit the glue files and directories added to
src/external/gpl3/gdb/bin/gdb.

169
tools/gdb/mknative-gdb Normal file
View File

@@ -0,0 +1,169 @@
#!/bin/sh
# $NetBSD: mknative-gdb,v 1.5 2011/11/06 19:46:12 christos Exp $
#
# Shell script for generating all the constants needed for a native
# platform build of src/external/gpl3/gdb
#
# initialise
_TMPDIR=$2
_TOP=$3
_PLATFORM=$4
_VPATH=`grep VPATH ${_TMPDIR}/Makefile | sed 's,^.*=[ ]*,,'`
_GDB=external/gpl3/gdb
. $_TOP/tools/gcc/mknative.common
##### gdb/lib/libbfd #####
get_gdb_libbfd () {
local _BFD=$_GDB/lib/libbfd
mkdir -p $_TOP/$_BFD/arch/$MACHINE_ARCH
{
getvars bfd/Makefile \
libbfd_la_DEPENDENCIES libbfd_la_OBJECTS DEFS \
INCLUDES TDEFAULTS
} | write_mk $_BFD/arch/$MACHINE_ARCH/defs.mk
for i in bfd-in3.h bfd_stdint.h config.h bfd.h bfdver.h targmatch.h
do
write_c $_BFD/arch/$MACHINE_ARCH/$i <$_TMPDIR/bfd/$i
done
}
##### gdb/lib/libopcodes #####
get_gdb_libopcodes () {
local _OPCODES=$_GDB/lib/libopcodes
mkdir -p $_TOP/$_OPCODES/arch/$MACHINE_ARCH
{
getvars opcodes/Makefile \
archdefs BFD_MACHINES libopcodes_la_SOURCES
} | write_mk $_GDB/lib/libopcodes//arch/$MACHINE_ARCH/defs.mk
{
cat $_TMPDIR/opcodes/config.h
} | write_c $_OPCODES/arch/$MACHINE_ARCH/config.h
}
##### gdb/lib/libiberty #####
get_gdb_libiberty () {
local _IBERTY=$_GDB/lib/libiberty
mkdir -p $_TOP/$_IBERTY/arch/$MACHINE_ARCH
getvars libiberty/Makefile \
ALLOCA EXTRA_OFILES LIBOBJS REQUIRED_OFILES \
| write_mk $_IBERTY/arch/$MACHINE_ARCH/defs.mk
write_c $_IBERTY/arch/$MACHINE_ARCH/config.h \
<$_TMPDIR/libiberty/config.h
}
##### gdb/lib/libreadline #####
get_gdb_libreadline () {
local _READLINE=$_GDB/lib/libreadline
mkdir -p $_TOP/$_READLINE/arch/$MACHINE_ARCH
{
getvars readline/Makefile \
CCFLAGS OBJECTS
} | write_mk $_READLINE/arch/$MACHINE_ARCH/defs.mk
write_c $_READLINE/arch/$MACHINE_ARCH/config.h \
<$_TMPDIR/readline/config.h
}
##### gdb/lib/libdecnumber #####
get_gdb_libdecnumber () {
local _DECNUMBER=$_GDB/lib/libdecnumber
mkdir -p $_TOP/$_DECNUMBER/arch/$MACHINE_ARCH
getvars libdecnumber/Makefile \
libdecnumber_a_OBJS |
sed -e s/libdecnumber_a_// |
write_mk $_DECNUMBER/arch/$MACHINE_ARCH/defs.mk
write_c $_DECNUMBER/arch/$MACHINE_ARCH/config.h \
<$_TMPDIR/readline/config.h
write_c $_DECNUMBER/arch/$MACHINE_ARCH/gstdint.h \
< $_TMPDIR/libdecnumber/gstdint.h
}
##### gdb/lib/libgdb #####
get_gdb_libgdb () {
local _GDBP=$_GDB/lib/libgdb
mkdir -p $_TOP/$_GDBP/arch/$MACHINE_ARCH
{
getvars gdb/Makefile \
INTERNAL_CFLAGS LIBGDB_OBS SIM_OBS
} | write_mk $_GDBP/arch/$MACHINE_ARCH/defs.mk
# getvars gdb/gdbserver/Makefile \
# INTERNAL_CFLAGS OBS \
# | write_mk $_GDB/bin/gdb/arch/$MACHINE_ARCH/gdbserver.mk
for i in config.h observer.h observer.inc version.c init.c xml-builtin.c
do
write_c $_GDBP/arch/$MACHINE_ARCH/$i \
< $_TMPDIR/gdb/$i
done
for f in nm tm xm; do
if [ -f $_TMPDIR/gdb/$f.h ]; then
ls -l $_TMPDIR/gdb/$f.h | sed 's,^.*->.*/gdb/,,;s,^,#include <,;s,$,>,' \
| write_c $_GDBP/arch/$MACHINE_ARCH/$f.h
fi
done
local _LIBSIM=$_GDB/lib/libsim
case $MACHINE_ARCH in
powerpc*)
mkdir -p $_TOP/$_LIBSIM/arch/$MACHINE_ARCH
write_c $_LIBSIM/arch/$MACHINE_ARCH/config.h \
<$_TMPDIR/sim/ppc/config.h
write_c $_LIBSIM/arch/$MACHINE_ARCH/build-config.h \
<$_TMPDIR/sim/ppc/build-config.h
write_c $_LIBSIM/arch/$MACHINE_ARCH/cconfig.h \
<$_TMPDIR/sim/common/cconfig.h
;;
xxmips*) # Disabled for now
mkdir -p $_TOP/$_LIBSIM/arch/$MACHINE_ARCH
write_c $_LIBSIM/arch/$MACHINE_ARCH/config.h \
<$_TMPDIR/sim/mips/config.h
write_c $_LIBSIM/arch/$MACHINE_ARCH/cconfig.h \
<$_TMPDIR/sim/common/cconfig.h
{
getvars sim/mips/Makefile \
LIB_OBJS CONFIG_CFLAGS \
BUILT_SRC_FROM_IGEN IGEN_OBJS
} | write_mk $_LIBSIM/arch/$MACHINE_ARCH/defs.mk
;;
*)
;;
esac
}
##### main #####
case $1 in
all|gdb) # everything (uses "canadian cross" temp environment)
get_gdb_libgdb
get_gdb_libbfd
get_gdb_libopcodes
get_gdb_libiberty
get_gdb_libreadline
get_gdb_libdecnumber
exit 0
;;
*) echo invalid arguments; exit 1;;
esac