mirror of
https://git.freebsd.org/ports.git
synced 2025-07-12 06:49:18 -04:00
This includes support for cross-debugging aarch64 process cores and kernels as well as native support for aarch64 processes. Hardware single stepping is supported, but hardware watchpoints are not yet supported. Reviewed by: luca.pizzamiglio@gmail.com (maintainer) Approved by: az (implicit) Differential Revision: https://reviews.freebsd.org/D12074
416 lines
12 KiB
Text
416 lines
12 KiB
Text
diff --git gdb/Makefile.in gdb/Makefile.in
|
|
index cf59ae7143..0dd72d35d1 100644
|
|
--- gdb/Makefile.in
|
|
+++ gdb/Makefile.in
|
|
@@ -227,7 +227,8 @@ INCGNU = -I$(srcdir)/gnulib/import -I$(GNULIB_BUILDDIR)/import
|
|
|
|
# Generated headers in the gnulib directory. These must be listed
|
|
# so that they are generated before other files are compiled.
|
|
-GNULIB_H = $(GNULIB_BUILDDIR)/import/string.h @GNULIB_STDINT_H@
|
|
+GNULIB_H = $(GNULIB_BUILDDIR)/import/string.h \
|
|
+ $(GNULIB_BUILDDIR)/import/alloca.h @GNULIB_STDINT_H@
|
|
|
|
#
|
|
# CLI sub directory definitons
|
|
@@ -745,6 +746,7 @@ TARGET_OBS = @TARGET_OBS@
|
|
# All target-dependent objects files that require 64-bit CORE_ADDR
|
|
# (used with --enable-targets=all --enable-64-bit-bfd).
|
|
ALL_64_TARGET_OBS = \
|
|
+ aarch64-fbsd-kern.o \
|
|
aarch64-fbsd-tdep.o \
|
|
aarch64-insn.o \
|
|
aarch64-linux-tdep.o \
|
|
@@ -759,6 +761,7 @@ ALL_64_TARGET_OBS = \
|
|
amd64-darwin-tdep.o \
|
|
amd64-dicos-tdep.o \
|
|
amd64-fbsd-tdep.o \
|
|
+ amd64fbsd-kern.o \
|
|
amd64-linux-tdep.o \
|
|
amd64-nbsd-tdep.o \
|
|
amd64-obsd-tdep.o \
|
|
@@ -770,6 +773,7 @@ ALL_64_TARGET_OBS = \
|
|
ia64-vms-tdep.o \
|
|
mips64-obsd-tdep.o \
|
|
sparc64-fbsd-tdep.o \
|
|
+ sparc64fbsd-kern.o \
|
|
sparc64-linux-tdep.o \
|
|
sparc64-nbsd-tdep.o \
|
|
sparc64-obsd-tdep.o \
|
|
@@ -797,6 +801,9 @@ ALL_TARGET_OBS = \
|
|
cris-linux-tdep.o \
|
|
cris-tdep.o \
|
|
dicos-tdep.o \
|
|
+ fbsd-kld.o \
|
|
+ fbsd-kthr.o \
|
|
+ fbsd-kvm.o \
|
|
fbsd-tdep.o \
|
|
frv-linux-tdep.o \
|
|
frv-tdep.o \
|
|
@@ -813,6 +820,7 @@ ALL_TARGET_OBS = \
|
|
i386-darwin-tdep.o \
|
|
i386-dicos-tdep.o \
|
|
i386-fbsd-tdep.o \
|
|
+ i386fbsd-kern.o \
|
|
i386-gnu-tdep.o \
|
|
i386-go32-tdep.o \
|
|
i386-linux-tdep.o \
|
|
@@ -837,6 +845,7 @@ ALL_TARGET_OBS = \
|
|
mep-tdep.o \
|
|
microblaze-linux-tdep.o \
|
|
microblaze-tdep.o \
|
|
+ mipsfbsd-kern.o \
|
|
mips-fbsd-tdep.o \
|
|
mips-linux-tdep.o \
|
|
mips-nbsd-tdep.o \
|
|
@@ -854,6 +863,7 @@ ALL_TARGET_OBS = \
|
|
nto-tdep.o \
|
|
obsd-tdep.o \
|
|
ppc-fbsd-tdep.o \
|
|
+ ppcfbsd-kern.o \
|
|
ppc-linux-tdep.o \
|
|
ppc-nbsd-tdep.o \
|
|
ppc-obsd-tdep.o \
|
|
@@ -1871,7 +1881,7 @@ generated_files = \
|
|
# Flags needed to compile Python code
|
|
PYTHON_CFLAGS = @PYTHON_CFLAGS@
|
|
|
|
-all: gdb$(EXEEXT) $(CONFIG_ALL)
|
|
+all: gdb$(EXEEXT) kgdb$(EXEEXT) $(CONFIG_ALL)
|
|
@$(MAKE) $(FLAGS_TO_PASS) DO=all "DODIRS=`echo $(SUBDIRS) | sed 's/testsuite//'`" subdir_do
|
|
|
|
# Rule for compiling .c files in the top-level gdb directory.
|
|
@@ -2210,6 +2220,12 @@ gdb$(EXEEXT): gdb.o $(LIBGDB_OBS) $(ADD_DEPS) $(CDEPS) $(TDEPLIBS)
|
|
-o gdb$(EXEEXT) gdb.o $(LIBGDB_OBS) \
|
|
$(TDEPLIBS) $(TUI_LIBRARY) $(CLIBS) $(LOADLIBES)
|
|
|
|
+kgdb$(EXEEXT): kgdb-main.o $(LIBGDB_OBS) $(ADD_DEPS) $(CDEPS) $(TDEPLIBS)
|
|
+ rm -f kgdb$(EXEEXT)
|
|
+ $(CC_LD) $(INTERNAL_LDFLAGS) $(WIN32LDAPP) \
|
|
+ -o kgdb$(EXEEXT) kgdb-main.o $(LIBGDB_OBS) \
|
|
+ $(TDEPLIBS) $(TUI_LIBRARY) $(CLIBS) $(LOADLIBES)
|
|
+
|
|
# Convenience rule to handle recursion.
|
|
$(LIBGNU) $(GNULIB_H): all-lib
|
|
all-lib: $(GNULIB_BUILDDIR)/Makefile
|
|
@@ -2254,7 +2270,7 @@ clean mostlyclean: $(CONFIG_CLEAN)
|
|
@$(MAKE) $(FLAGS_TO_PASS) DO=clean "DODIRS=$(CLEANDIRS)" subdir_do
|
|
rm -f *.o *.a $(ADD_FILES) *~ init.c-tmp init.l-tmp version.c-tmp
|
|
rm -f init.c version.c observer.h observer.inc
|
|
- rm -f gdb$(EXEEXT) core make.log
|
|
+ rm -f gdb$(EXEEXT) core make.log kgdb$(EXEEXT)
|
|
rm -f gdb[0-9]$(EXEEXT)
|
|
rm -f test-cp-name-parser$(EXEEXT)
|
|
rm -f xml-builtin.c stamp-xml
|
|
@@ -2461,6 +2477,7 @@ MAKEOVERRIDES =
|
|
|
|
ALLDEPFILES = \
|
|
aarch64-fbsd-nat.c \
|
|
+ aarch64-fbsd-kern.c \
|
|
aarch64-fbsd-tdep.c \
|
|
aarch64-linux-nat.c \
|
|
aarch64-linux-tdep.c \
|
|
@@ -2478,6 +2495,7 @@ ALLDEPFILES = \
|
|
amd64-bsd-nat.c \
|
|
amd64-darwin-tdep.c \
|
|
amd64-dicos-tdep.c \
|
|
+ amd64fbsd-kern.c \
|
|
amd64-fbsd-nat.c \
|
|
amd64-fbsd-tdep.c \
|
|
amd64-linux-nat.c \
|
|
@@ -2513,6 +2531,9 @@ ALLDEPFILES = \
|
|
dcache.c \
|
|
dicos-tdep.c \
|
|
exec.c \
|
|
+ fbsd-kld.c \
|
|
+ fbsd-kthr.c \
|
|
+ fbsd-kvm.c \
|
|
fbsd-nat.c \
|
|
fbsd-tdep.c \
|
|
fork-child.c \
|
|
@@ -2534,6 +2555,7 @@ ALLDEPFILES = \
|
|
i386-darwin-nat.c \
|
|
i386-darwin-tdep.c \
|
|
i386-dicos-tdep.c \
|
|
+ i386fbsd-kern.c \
|
|
i386-fbsd-nat.c \
|
|
i386-fbsd-tdep.c \
|
|
i386-gnu-nat.c \
|
|
@@ -2575,6 +2597,7 @@ ALLDEPFILES = \
|
|
mingw-hdep.c \
|
|
mips-fbsd-nat.c \
|
|
mips-fbsd-tdep.c \
|
|
+ mipsfbsd-kern.c \
|
|
mips-linux-nat.c \
|
|
mips-linux-tdep.c \
|
|
mips-nbsd-nat.c \
|
|
@@ -2592,6 +2615,7 @@ ALLDEPFILES = \
|
|
obsd-nat.c \
|
|
obsd-tdep.c \
|
|
posix-hdep.c \
|
|
+ ppcfbsd-kern.c \
|
|
ppc-fbsd-nat.c \
|
|
ppc-fbsd-tdep.c \
|
|
ppc-linux-nat.c \
|
|
@@ -2636,6 +2660,7 @@ ALLDEPFILES = \
|
|
sparc-sol2-nat.c \
|
|
sparc-sol2-tdep.c \
|
|
sparc-tdep.c \
|
|
+ sparc64fbsd-kern.c \
|
|
sparc64-fbsd-nat.c \
|
|
sparc64-fbsd-tdep.c \
|
|
sparc64-linux-nat.c \
|
|
@@ -2667,6 +2692,12 @@ ALLDEPFILES = \
|
|
xtensa-linux-tdep.c \
|
|
xtensa-tdep.c \
|
|
xtensa-xtregs.c \
|
|
+ kgdb/kld.c \
|
|
+ kgdb/kthr.c \
|
|
+ kgdb/trgt.c \
|
|
+ kgdb/trgt_amd64.c \
|
|
+ kgdb/trgt_i386.c \
|
|
+ kgdb/trgt_sparc64.c \
|
|
common/mingw-strerror.c \
|
|
common/posix-strerror.c
|
|
|
|
@@ -2928,7 +2959,7 @@ endif
|
|
|
|
# A list of all the objects we might care about in this build, for
|
|
# dependency tracking.
|
|
-all_object_files = gdb.o $(LIBGDB_OBS) gdbtk-main.o \
|
|
+all_object_files = kgdb-main.o gdb.o $(LIBGDB_OBS) gdbtk-main.o \
|
|
test-cp-name-parser.o
|
|
|
|
# Ensure that generated files are created early. Use order-only
|
|
diff --git gdb/config.in gdb/config.in
|
|
index 3f8a72326b..bb1e8c23bf 100644
|
|
--- gdb/config.in
|
|
+++ gdb/config.in
|
|
@@ -222,6 +222,9 @@
|
|
/* Define to 1 if your system has the kinfo_getvmmap function. */
|
|
#undef HAVE_KINFO_GETVMMAP
|
|
|
|
+/* Define to 1 if your system has the kvm_open2 function. */
|
|
+#undef HAVE_KVM_OPEN2
|
|
+
|
|
/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
|
|
#undef HAVE_LANGINFO_CODESET
|
|
|
|
diff --git gdb/config/mips/fbsd.mh gdb/config/mips/fbsd.mh
|
|
index f433347a20..5470795612 100644
|
|
--- gdb/config/mips/fbsd.mh
|
|
+++ gdb/config/mips/fbsd.mh
|
|
@@ -1,3 +1,5 @@
|
|
# Host: FreeBSD/mips
|
|
NATDEPFILES= fork-child.o inf-ptrace.o fbsd-nat.o mips-fbsd-nat.o
|
|
HAVE_NATIVE_GCORE_HOST = 1
|
|
+
|
|
+LOADLIBES= -lkvm
|
|
diff --git gdb/configure gdb/configure
|
|
index e14886b67d..5682ce42d6 100755
|
|
--- gdb/configure
|
|
+++ gdb/configure
|
|
@@ -7968,6 +7968,66 @@ $as_echo "#define HAVE_KINFO_GETVMMAP 1" >>confdefs.h
|
|
fi
|
|
|
|
|
|
+# kgdb needs kvm_open2 for cross-debugging
|
|
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing kvm_open2" >&5
|
|
+$as_echo_n "checking for library containing kvm_open2... " >&6; }
|
|
+if test "${ac_cv_search_kvm_open2+set}" = set; then :
|
|
+ $as_echo_n "(cached) " >&6
|
|
+else
|
|
+ ac_func_search_save_LIBS=$LIBS
|
|
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
|
+/* end confdefs.h. */
|
|
+
|
|
+/* Override any GCC internal prototype to avoid an error.
|
|
+ Use char because int might match the return type of a GCC
|
|
+ builtin and then its argument prototype would still apply. */
|
|
+#ifdef __cplusplus
|
|
+extern "C"
|
|
+#endif
|
|
+char kvm_open2 ();
|
|
+int
|
|
+main ()
|
|
+{
|
|
+return kvm_open2 ();
|
|
+ ;
|
|
+ return 0;
|
|
+}
|
|
+_ACEOF
|
|
+for ac_lib in '' kvm; do
|
|
+ if test -z "$ac_lib"; then
|
|
+ ac_res="none required"
|
|
+ else
|
|
+ ac_res=-l$ac_lib
|
|
+ LIBS="-l$ac_lib $ac_func_search_save_LIBS"
|
|
+ fi
|
|
+ if ac_fn_c_try_link "$LINENO"; then :
|
|
+ ac_cv_search_kvm_open2=$ac_res
|
|
+fi
|
|
+rm -f core conftest.err conftest.$ac_objext \
|
|
+ conftest$ac_exeext
|
|
+ if test "${ac_cv_search_kvm_open2+set}" = set; then :
|
|
+ break
|
|
+fi
|
|
+done
|
|
+if test "${ac_cv_search_kvm_open2+set}" = set; then :
|
|
+
|
|
+else
|
|
+ ac_cv_search_kvm_open2=no
|
|
+fi
|
|
+rm conftest.$ac_ext
|
|
+LIBS=$ac_func_search_save_LIBS
|
|
+fi
|
|
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_kvm_open2" >&5
|
|
+$as_echo "$ac_cv_search_kvm_open2" >&6; }
|
|
+ac_res=$ac_cv_search_kvm_open2
|
|
+if test "$ac_res" != no; then :
|
|
+ test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
|
|
+
|
|
+$as_echo "#define HAVE_KVM_OPEN2 1" >>confdefs.h
|
|
+
|
|
+fi
|
|
+
|
|
+
|
|
|
|
if test "X$prefix" = "XNONE"; then
|
|
acl_final_prefix="$ac_default_prefix"
|
|
diff --git gdb/configure.ac gdb/configure.ac
|
|
index 50f6f592ba..89cdc9cc8e 100644
|
|
--- gdb/configure.ac
|
|
+++ gdb/configure.ac
|
|
@@ -530,6 +530,11 @@ AC_SEARCH_LIBS(kinfo_getvmmap, util util-freebsd,
|
|
[AC_DEFINE(HAVE_KINFO_GETVMMAP, 1,
|
|
[Define to 1 if your system has the kinfo_getvmmap function. ])])
|
|
|
|
+# kgdb needs kvm_open2 for cross-debugging
|
|
+AC_SEARCH_LIBS(kvm_open2, kvm,
|
|
+ [AC_DEFINE(HAVE_KVM_OPEN2, 1,
|
|
+ [Define to 1 if your system has the kvm_open2 function. ])])
|
|
+
|
|
AM_ICONV
|
|
|
|
# GDB may fork/exec the iconv program to get the list of supported character
|
|
diff --git gdb/configure.tgt gdb/configure.tgt
|
|
index f72a0dbbc1..2d73300961 100644
|
|
--- gdb/configure.tgt
|
|
+++ gdb/configure.tgt
|
|
@@ -203,7 +203,13 @@ i[34567]86-*-dicos*)
|
|
i[34567]86-*-freebsd* | i[34567]86-*-kfreebsd*-gnu)
|
|
# Target: FreeBSD/i386
|
|
gdb_target_obs="i386-tdep.o i387-tdep.o i386-bsd-tdep.o i386-fbsd-tdep.o \
|
|
- fbsd-tdep.o solib-svr4.o"
|
|
+ fbsd-tdep.o solib-svr4.o \
|
|
+ fbsd-kld.o fbsd-kthr.o fbsd-kvm.o i386fbsd-kern.o"
|
|
+ if test "x$enable_64_bit_bfd" = "xyes"; then
|
|
+ # Target: FreeBSD amd64
|
|
+ gdb_target_obs="amd64-tdep.o amd64fbsd-tdep.o amd64fbsd-kern.o \
|
|
+ ${gdb_target_obs}"
|
|
+ fi
|
|
;;
|
|
i[34567]86-*-netbsd* | i[34567]86-*-knetbsd*-gnu)
|
|
# Target: NetBSD/i386
|
|
@@ -377,7 +383,8 @@ mips*-*-netbsd* | mips*-*-knetbsd*-gnu)
|
|
;;
|
|
mips*-*-freebsd*)
|
|
# Target: MIPS running FreeBSD
|
|
- gdb_target_obs="mips-tdep.o mips-fbsd-tdep.o solib-svr4.o fbsd-tdep.o"
|
|
+ gdb_target_obs="mips-tdep.o mips-fbsd-tdep.o solib-svr4.o fbsd-tdep.o \
|
|
+ fbsd-kld.o fbsd-kthr.o fbsd-kvm.o mipsfbsd-kern.o"
|
|
gdb_sim=../sim/mips/libsim.a
|
|
;;
|
|
mips64*-*-openbsd*)
|
|
@@ -436,7 +443,8 @@ powerpc*-*-freebsd*)
|
|
# Target: FreeBSD/powerpc
|
|
gdb_target_obs="rs6000-tdep.o ppc-sysv-tdep.o ppc64-tdep.o \
|
|
ppc-fbsd-tdep.o fbsd-tdep.o solib-svr4.o \
|
|
- ravenscar-thread.o ppc-ravenscar-thread.o"
|
|
+ ravenscar-thread.o ppc-ravenscar-thread.o \
|
|
+ fbsd-kld.o fbsd-kthr.o fbsd-kvm.o ppcfbsd-kern.o"
|
|
;;
|
|
|
|
powerpc-*-netbsd* | powerpc-*-knetbsd*-gnu)
|
|
@@ -560,7 +568,8 @@ sparc*-*-freebsd* | sparc*-*-kfreebsd*-gnu)
|
|
# Target: FreeBSD/sparc64
|
|
gdb_target_obs="sparc-tdep.o sparc64-tdep.o sparc64-fbsd-tdep.o \
|
|
fbsd-tdep.o solib-svr4.o \
|
|
- ravenscar-thread.o sparc-ravenscar-thread.o"
|
|
+ ravenscar-thread.o sparc-ravenscar-thread.o \
|
|
+ fbsd-kld.o fbsd-kthr.o fbsd-kvm.o sparc64fbsd-kern.o"
|
|
;;
|
|
sparc-*-netbsd* | sparc-*-knetbsd*-gnu)
|
|
# Target: NetBSD/sparc
|
|
@@ -691,7 +700,9 @@ x86_64-*-freebsd* | x86_64-*-kfreebsd*-gnu)
|
|
# Target: FreeBSD/amd64
|
|
gdb_target_obs="amd64-tdep.o amd64-fbsd-tdep.o i386-tdep.o \
|
|
i387-tdep.o i386-bsd-tdep.o i386-fbsd-tdep.o \
|
|
- fbsd-tdep.o solib-svr4.o"
|
|
+ fbsd-tdep.o solib-svr4.o \
|
|
+ fbsd-kld.o fbsd-kthr.o fbsd-kvm.o amd64fbsd-kern.o \
|
|
+ i386fbsd-kern.o"
|
|
;;
|
|
x86_64-*-mingw* | x86_64-*-cygwin*)
|
|
# Target: MingW/amd64
|
|
diff --git gdb/defs.h gdb/defs.h
|
|
index a0b586f401..44d3d112ed 100644
|
|
--- gdb/defs.h
|
|
+++ gdb/defs.h
|
|
@@ -590,6 +590,7 @@ enum gdb_osabi
|
|
GDB_OSABI_SOLARIS,
|
|
GDB_OSABI_LINUX,
|
|
GDB_OSABI_FREEBSD,
|
|
+ GDB_OSABI_FREEBSD_KERNEL,
|
|
GDB_OSABI_NETBSD,
|
|
GDB_OSABI_OPENBSD,
|
|
GDB_OSABI_WINCE,
|
|
diff --git gdb/osabi.c gdb/osabi.c
|
|
index 84fa9c0273..5c49e22657 100644
|
|
--- gdb/osabi.c
|
|
+++ gdb/osabi.c
|
|
@@ -65,6 +65,7 @@ static const struct osabi_names gdb_osabi_names[] =
|
|
{ "Solaris", NULL },
|
|
{ "GNU/Linux", "linux(-gnu)?" },
|
|
{ "FreeBSD", NULL },
|
|
+ { "FreeBSD/kernel", NULL },
|
|
{ "NetBSD", NULL },
|
|
{ "OpenBSD", NULL },
|
|
{ "WindowsCE", NULL },
|
|
diff --git gdb/regcache.c gdb/regcache.c
|
|
index 37bc2f0046..9da3aaa514 100644
|
|
--- gdb/regcache.c
|
|
+++ gdb/regcache.c
|
|
@@ -1105,6 +1105,20 @@ regcache_raw_supply (struct regcache *regcache, int regnum, const void *buf)
|
|
}
|
|
}
|
|
|
|
+void
|
|
+regcache_raw_supply_unsigned (struct regcache *regcache, int regnum,
|
|
+ ULONGEST val)
|
|
+{
|
|
+ gdb_byte *buf;
|
|
+
|
|
+ gdb_assert (regcache != NULL);
|
|
+ gdb_assert (regnum >=0 && regnum < regcache->descr->nr_raw_registers);
|
|
+ buf = (gdb_byte *)alloca (regcache->descr->sizeof_register[regnum]);
|
|
+ store_unsigned_integer (buf, regcache->descr->sizeof_register[regnum],
|
|
+ gdbarch_byte_order (regcache->descr->gdbarch), val);
|
|
+ regcache_raw_supply (regcache, regnum, buf);
|
|
+}
|
|
+
|
|
/* Collect register REGNUM from REGCACHE and store its contents in BUF. */
|
|
|
|
void
|
|
diff --git gdb/regcache.h gdb/regcache.h
|
|
index 1d60fa7616..9b8a4723a3 100644
|
|
--- gdb/regcache.h
|
|
+++ gdb/regcache.h
|
|
@@ -149,6 +149,8 @@ extern void regcache_write_pc (struct regcache *regcache, CORE_ADDR pc);
|
|
|
|
extern void regcache_raw_supply (struct regcache *regcache,
|
|
int regnum, const void *buf);
|
|
+extern void regcache_raw_supply_unsigned (struct regcache *regcache,
|
|
+ int regnum, ULONGEST val);
|
|
extern void regcache_raw_collect (const struct regcache *regcache,
|
|
int regnum, void *buf);
|
|
|