Index: head/devel/gdb/Makefile =================================================================== --- head/devel/gdb/Makefile (revision 464492) +++ head/devel/gdb/Makefile (revision 464493) @@ -1,151 +1,140 @@ # Created by: Steven Kreuzer # $FreeBSD$ PORTNAME= gdb -PORTVERSION= 8.0.1 -PORTREVISION= 2 +PORTVERSION= 8.1 CATEGORIES= devel MASTER_SITES= GNU MAINTAINER= pizzamig@FreeBSD.org COMMENT= GNU GDB of newer version than comes with the system LICENSE= GPLv3 LICENSE_FILE= ${WRKSRC}/COPYING3 # untested on sparc64, might work ONLY_FOR_ARCHS= aarch64 amd64 armv6 armv7 i386 mips powerpc powerpc64 TEST_DEPENDS= runtest:misc/dejagnu TEST_TARGET= check # XXX: This should be compiler:c++11-lib as GDB doesn't really require # C++14. However, clang in 10.3 crashes while building this port. # Requiring C++14 forces 10.3 to use an external version of clang while # still using the base system clang on 11.0 and later. USES= compiler:c++14-lang cpe iconv gmake libtool tar:xz USE_CSTD= gnu89 CPE_VENDOR= gnu GNU_CONFIGURE= yes CONFIGURE_ENV= CONFIGURED_M4=m4 CONFIGURED_BISON=byacc CONFIGURE_ARGS= --program-suffix=${PORTVERSION:S/.//g} \ --enable-targets=all --enable-64-bit-bfd \ --with-gdb-datadir=${PREFIX}/share/gdb${PORTVERSION:S/.//g} \ --with-separate-debug-dir=/usr/lib/debug \ ${ICONV_CONFIGURE_ARG} \ --with-expat=yes --with-libexpat-prefix=${LOCALBASE} \ --without-libunwind-ia64 CFLAGS:= ${CFLAGS:C/ +$//} # blanks at EOL creep in sometimes CFLAGS+= -DRL_NO_COMPAT -Wno-unused-function -Wno-unused-variable EXCLUDE= dejagnu expect sim texinfo intl EXTRACT_AFTER_ARGS= ${EXCLUDE:S/^/--exclude /} -EXTRA_PATCHES= ${FILESDIR}/commit-45eba0ab7d \ - ${FILESDIR}/commit-3c3ae77e68 \ - ${FILESDIR}/commit-b5430a3ced \ - ${FILESDIR}/commit-762c974a09 \ - ${FILESDIR}/commit-929edea98d \ - ${FILESDIR}/commit-6e5eab33ab \ - ${FILESDIR}/commit-382b69bbb7 \ - ${FILESDIR}/commit-2af9fc4432 \ - ${FILESDIR}/commit-0b9305edf1 \ - ${FILESDIR}/commit-e6f3b9c319 \ - ${FILESDIR}/commit-4b654465bf \ - ${FILESDIR}/commit-b30ff123fb \ - ${FILESDIR}/commit-48aeef91c2 \ - ${FILESDIR}/commit-0aa37b654c \ - ${FILESDIR}/commit-0335ac6d12 \ - ${FILESDIR}/commit-12c4bd7f53 \ - ${FILESDIR}/commit-6d5be5d6b8 \ - ${FILESDIR}/commit-a80a647180 \ - ${FILESDIR}/commit-544c67cda1 \ - ${FILESDIR}/commit-a181c0bf74 +EXTRA_PATCHES= ${FILESDIR}/commit-d2176225dc \ + ${FILESDIR}/commit-b999e2038d \ + ${FILESDIR}/commit-262f62f57d \ + ${FILESDIR}/commit-92fce24de2 \ + ${FILESDIR}/commit-2d97a5d9d3 \ + ${FILESDIR}/commit-906b4aac4c \ + ${FILESDIR}/commit-f169cfdc08 \ + ${FILESDIR}/commit-12279366d7 \ + ${FILESDIR}/commit-386a867618 \ + ${FILESDIR}/commit-7efba073e2 LIB_DEPENDS+= libexpat.so:textproc/expat2 VER= ${PORTVERSION:S/.//g} PLIST_SUB= VER=${VER} OPTIONS_DEFINE= DEBUG GDB_LINK GUILE KGDB PYTHON TUI OPTIONS_DEFAULT= GDB_LINK KGDB PYTHON TUI PORT_READLINE OPTIONS_SINGLE= READLINE OPTIONS_SINGLE_READLINE= BUNDLED_READLINE PORT_READLINE GDB_LINK_DESC= Create ${PREFIX}/bin/gdb symlink KGDB_DESC= Kernel Debugging Support BUNDLED_READLINE_DESC= from gdb distfile PORT_READLINE_DESC= from devel/readline port TUI_DESC= Text User Interface enabled OPTIONS_SUB= yes BUNDLED_READLINE_CONFIGURE_OFF= --with-system-readline DEBUG_CFLAGS= -g GUILE_CONFIGURE_WITH= guile GUILE_USES= pkgconfig GUILE_LIB_DEPENDS= libguile-2.0.so:lang/guile2 PORT_READLINE_USES= readline:port PYTHON_CONFIGURE_ON= --with-python=${PYTHON_CMD} PYTHON_CONFIGURE_OFF= --without-python PYTHON_USES= python TUI_CONFIGURE_ENABLE= tui .include .if ! ${PORT_OPTIONS:MBUNDLED_READLINE} EXCLUDE+= readline .endif .if ${ARCH} == "amd64" CONFIGURE_TARGET= x86_64-portbld-freebsd${OSREL} .endif .if ${COMPILER_TYPE} == "clang" CFLAGS+= -Wno-extended-offsetof .endif post-patch: @${REINPLACE_CMD} -e 's|$$| [GDB v${PORTVERSION} for FreeBSD]|' \ ${WRKSRC}/gdb/version.in post-patch-KGDB-on: @${CP} -r ${FILESDIR}/kgdb/*.[ch] ${WRKSRC}/gdb/ @${PATCH} -d ${PATCH_WRKSRC} ${PATCH_ARGS} < ${FILESDIR}/extrapatch-kgdb do-install: ${INSTALL_PROGRAM} ${WRKSRC}/gdb/gdb \ ${STAGEDIR}${PREFIX}/bin/gdb${VER} ${INSTALL_MAN} ${WRKSRC}/gdb/doc/gdb.1 \ ${STAGEDIR}${MAN1PREFIX}/man/man1/gdb${VER}.1 (cd ${WRKSRC}/gdb/data-directory ; \ ${SETENV} ${MAKE_ENV} ${MAKE_CMD} ${MAKE_ARGS} install-syscalls ) do-install-KGDB-on: ${INSTALL_PROGRAM} ${WRKSRC}/gdb/kgdb \ ${STAGEDIR}${PREFIX}/bin/kgdb${VER} ${INSTALL_MAN} ${FILESDIR}/kgdb/kgdb.1 \ ${STAGEDIR}${MAN1PREFIX}/man/man1/kgdb${VER}.1 do-install-TUI-on: ${LN} -sf gdb${VER} ${STAGEDIR}${PREFIX}/bin/gdbtui${VER} do-install-GDB_LINK-on: ${LN} -sf gdb${VER} ${STAGEDIR}${PREFIX}/bin/gdb .if ${PORT_OPTIONS:MKGDB} ${LN} -sf kgdb${VER} ${STAGEDIR}${PREFIX}/bin/kgdb .endif do-install-PYTHON-on: (cd ${WRKSRC}/gdb; ${SETENV} ${MAKE_ENV} ${MAKE_CMD} ${MAKE_ARGS} install-python ) (cd ${WRKSRC}/gdb/data-directory ; \ ${SETENV} ${MAKE_ENV} ${MAKE_CMD} ${MAKE_ARGS} install-python ) . for f in gdb gdb/command gdb/function gdb/printer @(cd ${STAGEDIR}${PREFIX}/share/gdb${VER}/python/${f} ; ${CHMOD} 644 *.py* ) . endfor do-install-GUILE-on: (cd ${WRKSRC}/gdb; ${SETENV} ${MAKE_ENV} ${MAKE_CMD} ${MAKE_ARGS} install-guile ) (cd ${WRKSRC}/gdb/data-directory ; \ ${SETENV} ${MAKE_ENV} ${MAKE_CMD} ${MAKE_ARGS} install-guile ) .include Index: head/devel/gdb/distinfo =================================================================== --- head/devel/gdb/distinfo (revision 464492) +++ head/devel/gdb/distinfo (revision 464493) @@ -1,3 +1,3 @@ -TIMESTAMP = 1505207991 -SHA256 (gdb-8.0.1.tar.xz) = 3dbd5f93e36ba2815ad0efab030dcd0c7b211d7b353a40a53f4c02d7d56295e3 -SIZE (gdb-8.0.1.tar.xz) = 19583920 +TIMESTAMP = 1517392551 +SHA256 (gdb-8.1.tar.xz) = af61a0263858e69c5dce51eab26662ff3d2ad9aa68da9583e8143b5426be4b34 +SIZE (gdb-8.1.tar.xz) = 20095080 Index: head/devel/gdb/files/commit-929edea98d =================================================================== --- head/devel/gdb/files/commit-929edea98d (revision 464492) +++ head/devel/gdb/files/commit-929edea98d (nonexistent) @@ -1,211 +0,0 @@ -commit 929edea98d27cf9d72305c1584ee77627da7fa96 -Author: John Baldwin -Date: Wed Jun 28 09:53:06 2017 -0700 - - Fetch signal information for native FreeBSD processes. - - Use the `pl_siginfo' field in the `struct ptrace_lwpinfo' object returned - by the PT_LWPINFO ptrace() request to supply the current contents of - $_siginfo for each thread. Note that FreeBSD does not supply a way to - modify the signal information for a thread, so $_siginfo is read-only for - FreeBSD. - - To handle 32-bit processes on a 64-bit host, define types for 32-bit - compatible siginfo_t and convert the 64-bit siginfo_t to the 32-bit - equivalent when supplying information for a 32-bit process. - - gdb/ChangeLog: - - * fbsd-nat.c [PT_LWPINFO && __LP64__] (union sigval32) - (struct siginfo32): New. - [PT_LWPINFO] (fbsd_siginfo_size, fbsd_convert_siginfo): New. - (fbsd_xfer_partial) [PT_LWPINFO]: Handle TARGET_OBJECT_SIGNAL_INFO - via ptrace(PT_LWPINFO). - -diff --git gdb/fbsd-nat.c gdb/fbsd-nat.c -index ef5ad1ec92..85f56059bd 100644 ---- gdb/fbsd-nat.c -+++ gdb/fbsd-nat.c -@@ -28,6 +28,7 @@ - #include - #include - #include -+#include - #include - #ifdef HAVE_KINFO_GETVMMAP - #include -@@ -216,6 +217,135 @@ static enum target_xfer_status (*super_xfer_partial) (struct target_ops *ops, - ULONGEST len, - ULONGEST *xfered_len); - -+#ifdef PT_LWPINFO -+/* Return the size of siginfo for the current inferior. */ -+ -+#ifdef __LP64__ -+union sigval32 { -+ int sival_int; -+ uint32_t sival_ptr; -+}; -+ -+/* This structure matches the naming and layout of `siginfo_t' in -+ . In particular, the `si_foo' macros defined in that -+ header can be used with both types to copy fields in the `_reason' -+ union. */ -+ -+struct siginfo32 -+{ -+ int si_signo; -+ int si_errno; -+ int si_code; -+ __pid_t si_pid; -+ __uid_t si_uid; -+ int si_status; -+ uint32_t si_addr; -+ union sigval32 si_value; -+ union -+ { -+ struct -+ { -+ int _trapno; -+ } _fault; -+ struct -+ { -+ int _timerid; -+ int _overrun; -+ } _timer; -+ struct -+ { -+ int _mqd; -+ } _mesgq; -+ struct -+ { -+ int32_t _band; -+ } _poll; -+ struct -+ { -+ int32_t __spare1__; -+ int __spare2__[7]; -+ } __spare__; -+ } _reason; -+}; -+#endif -+ -+static size_t -+fbsd_siginfo_size () -+{ -+#ifdef __LP64__ -+ struct gdbarch *gdbarch = get_frame_arch (get_current_frame ()); -+ -+ /* Is the inferior 32-bit? If so, use the 32-bit siginfo size. */ -+ if (gdbarch_bfd_arch_info (gdbarch)->bits_per_word == 32) -+ return sizeof (struct siginfo32); -+#endif -+ return sizeof (siginfo_t); -+} -+ -+/* Convert a native 64-bit siginfo object to a 32-bit object. Note -+ that FreeBSD doesn't support writing to $_siginfo, so this only -+ needs to convert one way. */ -+ -+static void -+fbsd_convert_siginfo (siginfo_t *si) -+{ -+#ifdef __LP64__ -+ struct gdbarch *gdbarch = get_frame_arch (get_current_frame ()); -+ -+ /* Is the inferior 32-bit? If not, nothing to do. */ -+ if (gdbarch_bfd_arch_info (gdbarch)->bits_per_word != 32) -+ return; -+ -+ struct siginfo32 si32; -+ -+ si32.si_signo = si->si_signo; -+ si32.si_errno = si->si_errno; -+ si32.si_code = si->si_code; -+ si32.si_pid = si->si_pid; -+ si32.si_uid = si->si_uid; -+ si32.si_status = si->si_status; -+ si32.si_addr = (uintptr_t) si->si_addr; -+ -+ /* If sival_ptr is being used instead of sival_int on a big-endian -+ platform, then sival_int will be zero since it holds the upper -+ 32-bits of the pointer value. */ -+#if _BYTE_ORDER == _BIG_ENDIAN -+ if (si->si_value.sival_int == 0) -+ si32->si_value.sival_ptr = (uintptr_t) si->si_value.sival_ptr; -+ else -+ si32.si_value.sival_int = si->si_value.sival_int; -+#else -+ si32.si_value.sival_int = si->si_value.sival_int; -+#endif -+ -+ /* Always copy the spare fields and then possibly overwrite them for -+ signal-specific or code-specific fields. */ -+ si32._reason.__spare__.__spare1__ = si->_reason.__spare__.__spare1__; -+ for (int i = 0; i < 7; i++) -+ si32._reason.__spare__.__spare2__[i] = si->_reason.__spare__.__spare2__[i]; -+ switch (si->si_signo) { -+ case SIGILL: -+ case SIGFPE: -+ case SIGSEGV: -+ case SIGBUS: -+ si32.si_trapno = si->si_trapno; -+ break; -+ } -+ switch (si->si_code) { -+ case SI_TIMER: -+ si32.si_timerid = si->si_timerid; -+ si32.si_overrun = si->si_overrun; -+ break; -+ case SI_MESGQ: -+ si32.si_mqd = si->si_mqd; -+ break; -+ } -+ -+ memcpy(si, &si32, sizeof (si32)); -+#endif -+} -+#endif -+ - /* Implement the "to_xfer_partial target_ops" method. */ - - static enum target_xfer_status -@@ -228,6 +358,38 @@ fbsd_xfer_partial (struct target_ops *ops, enum target_object object, - - switch (object) - { -+#ifdef PT_LWPINFO -+ case TARGET_OBJECT_SIGNAL_INFO: -+ { -+ struct ptrace_lwpinfo pl; -+ size_t siginfo_size; -+ -+ /* FreeBSD doesn't support writing to $_siginfo. */ -+ if (writebuf != NULL) -+ return TARGET_XFER_E_IO; -+ -+ if (inferior_ptid.lwp_p ()) -+ pid = inferior_ptid.lwp (); -+ -+ siginfo_size = fbsd_siginfo_size (); -+ if (offset > siginfo_size) -+ return TARGET_XFER_E_IO; -+ -+ if (ptrace (PT_LWPINFO, pid, (PTRACE_TYPE_ARG3) &pl, sizeof (pl)) == -1) -+ return TARGET_XFER_E_IO; -+ -+ if (!(pl.pl_flags & PL_FLAG_SI)) -+ return TARGET_XFER_E_IO; -+ -+ fbsd_convert_siginfo (&pl.pl_siginfo); -+ if (offset + len > siginfo_size) -+ len = siginfo_size - offset; -+ -+ memcpy (readbuf, ((gdb_byte *) &pl.pl_siginfo) + offset, len); -+ *xfered_len = len; -+ return TARGET_XFER_OK; -+ } -+#endif - case TARGET_OBJECT_AUXV: - { - struct cleanup *cleanup = make_cleanup (null_cleanup, NULL); Property changes on: head/devel/gdb/files/commit-929edea98d ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/devel/gdb/files/patch-gdb_configure.host =================================================================== --- head/devel/gdb/files/patch-gdb_configure.host (revision 464492) +++ head/devel/gdb/files/patch-gdb_configure.host (nonexistent) @@ -1,10 +0,0 @@ ---- gdb/configure.host.orig 2017-09-14 09:28:17 UTC -+++ gdb/configure.host -@@ -90,6 +90,7 @@ alpha*-*-netbsd* | alpha*-*-knetbsd*-gnu) - gdb_host=nbsd ;; - alpha*-*-openbsd*) gdb_host=nbsd ;; - -+arm*-*-freebsd*) gdb_host=fbsd ;; - arm*-*-linux*) gdb_host=linux ;; - arm*-*-netbsdelf* | arm*-*-knetbsd*-gnu) - gdb_host=nbsdelf ;; Property changes on: head/devel/gdb/files/patch-gdb_configure.host ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/devel/gdb/files/commit-382b69bbb7 =================================================================== --- head/devel/gdb/files/commit-382b69bbb7 (revision 464492) +++ head/devel/gdb/files/commit-382b69bbb7 (nonexistent) @@ -1,220 +0,0 @@ -commit 382b69bbb7a4fec5213d2382fe70a68d7a46b3e7 -Author: John Baldwin -Date: Wed Jun 28 11:11:20 2017 -0700 - - Add a new gdbarch method to fetch signal information from core files. - - Previously the core_xfer_partial method used core_get_siginfo to handle - TARGET_OBJECT_SIGNAL_INFO requests. However, core_get_siginfo looked for - Linux-specific sections in the core file. To support fetching siginfo - from cores on other systems, add a new gdbarch method (`core_xfer_siginfo`) - and move the body of the existing core_get_siginfo into a - linux_core_xfer_siginfo implementation of this method in linux-tdep.c. - - gdb/ChangeLog: - - * corelow.c (get_core_siginfo): Remove. - (core_xfer_partial): Use the gdbarch "core_xfer_siginfo" method - instead of get_core_siginfo. - * gdbarch.sh (core_xfer_siginfo): New gdbarch callback. - * gdbarch.h: Re-generate. - * gdbarch.c: Re-generate. - * linux-tdep.c (linux_core_xfer_siginfo): New. - (linux_init_abi): Install gdbarch "core_xfer_siginfo" method. - -diff --git gdb/corelow.c gdb/corelow.c -index 578c910bb5..5dbabc79e6 100644 ---- gdb/corelow.c -+++ gdb/corelow.c -@@ -668,25 +668,6 @@ add_to_spuid_list (bfd *abfd, asection *asect, void *list_p) - list->pos += 4; - } - --/* Read siginfo data from the core, if possible. Returns -1 on -- failure. Otherwise, returns the number of bytes read. ABFD is the -- core file's BFD; READBUF, OFFSET, and LEN are all as specified by -- the to_xfer_partial interface. */ -- --static LONGEST --get_core_siginfo (bfd *abfd, gdb_byte *readbuf, ULONGEST offset, ULONGEST len) --{ -- thread_section_name section_name (".note.linuxcore.siginfo", inferior_ptid); -- asection *section = bfd_get_section_by_name (abfd, section_name.c_str ()); -- if (section == NULL) -- return -1; -- -- if (!bfd_get_section_contents (abfd, section, readbuf, offset, len)) -- return -1; -- -- return len; --} -- - static enum target_xfer_status - core_xfer_partial (struct target_ops *ops, enum target_object object, - const char *annex, gdb_byte *readbuf, -@@ -874,12 +855,20 @@ core_xfer_partial (struct target_ops *ops, enum target_object object, - case TARGET_OBJECT_SIGNAL_INFO: - if (readbuf) - { -- LONGEST l = get_core_siginfo (core_bfd, readbuf, offset, len); -- -- if (l > 0) -+ if (core_gdbarch -+ && gdbarch_core_xfer_siginfo_p (core_gdbarch)) - { -- *xfered_len = len; -- return TARGET_XFER_OK; -+ LONGEST l = gdbarch_core_xfer_siginfo (core_gdbarch, readbuf, -+ offset, len); -+ -+ if (l >= 0) -+ { -+ *xfered_len = l; -+ if (l == 0) -+ return TARGET_XFER_EOF; -+ else -+ return TARGET_XFER_OK; -+ } - } - } - return TARGET_XFER_E_IO; -diff --git gdb/gdbarch.c gdb/gdbarch.c -index e5efdfbb26..24521b5e23 100644 ---- gdb/gdbarch.c -+++ gdb/gdbarch.c -@@ -287,6 +287,7 @@ struct gdbarch - gdbarch_core_xfer_shared_libraries_aix_ftype *core_xfer_shared_libraries_aix; - gdbarch_core_pid_to_str_ftype *core_pid_to_str; - gdbarch_core_thread_name_ftype *core_thread_name; -+ gdbarch_core_xfer_siginfo_ftype *core_xfer_siginfo; - const char * gcore_bfd_target; - int vtable_function_descriptors; - int vbit_in_delta; -@@ -646,6 +647,7 @@ verify_gdbarch (struct gdbarch *gdbarch) - /* Skip verify of core_xfer_shared_libraries_aix, has predicate. */ - /* Skip verify of core_pid_to_str, has predicate. */ - /* Skip verify of core_thread_name, has predicate. */ -+ /* Skip verify of core_xfer_siginfo, has predicate. */ - /* Skip verify of gcore_bfd_target, has predicate. */ - /* Skip verify of vtable_function_descriptors, invalid_p == 0 */ - /* Skip verify of vbit_in_delta, invalid_p == 0 */ -@@ -884,6 +886,12 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file) - "gdbarch_dump: core_xfer_shared_libraries_aix = <%s>\n", - host_address_to_string (gdbarch->core_xfer_shared_libraries_aix)); - fprintf_unfiltered (file, -+ "gdbarch_dump: gdbarch_core_xfer_siginfo_p() = %d\n", -+ gdbarch_core_xfer_siginfo_p (gdbarch)); -+ fprintf_unfiltered (file, -+ "gdbarch_dump: core_xfer_siginfo = <%s>\n", -+ host_address_to_string (gdbarch->core_xfer_siginfo)); -+ fprintf_unfiltered (file, - "gdbarch_dump: decr_pc_after_break = %s\n", - core_addr_to_string_nz (gdbarch->decr_pc_after_break)); - fprintf_unfiltered (file, -@@ -3797,6 +3805,30 @@ set_gdbarch_core_thread_name (struct gdbarch *gdbarch, - } - - int -+gdbarch_core_xfer_siginfo_p (struct gdbarch *gdbarch) -+{ -+ gdb_assert (gdbarch != NULL); -+ return gdbarch->core_xfer_siginfo != NULL; -+} -+ -+LONGEST -+gdbarch_core_xfer_siginfo (struct gdbarch *gdbarch, gdb_byte *readbuf, ULONGEST offset, ULONGEST len) -+{ -+ gdb_assert (gdbarch != NULL); -+ gdb_assert (gdbarch->core_xfer_siginfo != NULL); -+ if (gdbarch_debug >= 2) -+ fprintf_unfiltered (gdb_stdlog, "gdbarch_core_xfer_siginfo called\n"); -+ return gdbarch->core_xfer_siginfo (gdbarch, readbuf, offset, len); -+} -+ -+void -+set_gdbarch_core_xfer_siginfo (struct gdbarch *gdbarch, -+ gdbarch_core_xfer_siginfo_ftype core_xfer_siginfo) -+{ -+ gdbarch->core_xfer_siginfo = core_xfer_siginfo; -+} -+ -+int - gdbarch_gcore_bfd_target_p (struct gdbarch *gdbarch) - { - gdb_assert (gdbarch != NULL); -diff --git gdb/gdbarch.h gdb/gdbarch.h -index ab7561f851..1c95301f6f 100644 ---- gdb/gdbarch.h -+++ gdb/gdbarch.h -@@ -933,6 +933,16 @@ typedef const char * (gdbarch_core_thread_name_ftype) (struct gdbarch *gdbarch, - extern const char * gdbarch_core_thread_name (struct gdbarch *gdbarch, struct thread_info *thr); - extern void set_gdbarch_core_thread_name (struct gdbarch *gdbarch, gdbarch_core_thread_name_ftype *core_thread_name); - -+/* Read offset OFFSET of TARGET_OBJECT_SIGNAL_INFO signal information -+ from core file into buffer READBUF with length LEN. Return the number -+ of bytes read (zero indicates EOF, a negative value indicates failure). */ -+ -+extern int gdbarch_core_xfer_siginfo_p (struct gdbarch *gdbarch); -+ -+typedef LONGEST (gdbarch_core_xfer_siginfo_ftype) (struct gdbarch *gdbarch, gdb_byte *readbuf, ULONGEST offset, ULONGEST len); -+extern LONGEST gdbarch_core_xfer_siginfo (struct gdbarch *gdbarch, gdb_byte *readbuf, ULONGEST offset, ULONGEST len); -+extern void set_gdbarch_core_xfer_siginfo (struct gdbarch *gdbarch, gdbarch_core_xfer_siginfo_ftype *core_xfer_siginfo); -+ - /* BFD target to use when generating a core file. */ - - extern int gdbarch_gcore_bfd_target_p (struct gdbarch *gdbarch); -diff --git gdb/gdbarch.sh gdb/gdbarch.sh -index 22f5715037..3aab17f958 100755 ---- gdb/gdbarch.sh -+++ gdb/gdbarch.sh -@@ -755,6 +755,11 @@ M;const char *;core_pid_to_str;ptid_t ptid;ptid - # How the core target extracts the name of a thread from a core file. - M;const char *;core_thread_name;struct thread_info *thr;thr - -+# Read offset OFFSET of TARGET_OBJECT_SIGNAL_INFO signal information -+# from core file into buffer READBUF with length LEN. Return the number -+# of bytes read (zero indicates EOF, a negative value indicates failure). -+M;LONGEST;core_xfer_siginfo;gdb_byte *readbuf, ULONGEST offset, ULONGEST len; readbuf, offset, len -+ - # BFD target to use when generating a core file. - V;const char *;gcore_bfd_target;;;0;0;;;pstring (gdbarch->gcore_bfd_target) - -diff --git gdb/linux-tdep.c gdb/linux-tdep.c -index 2792cbd4c8..5c7f8a0758 100644 ---- gdb/linux-tdep.c -+++ gdb/linux-tdep.c -@@ -1127,6 +1127,26 @@ linux_core_info_proc (struct gdbarch *gdbarch, const char *args, - error (_("unable to handle request")); - } - -+/* Read siginfo data from the core, if possible. Returns -1 on -+ failure. Otherwise, returns the number of bytes read. READBUF, -+ OFFSET, and LEN are all as specified by the to_xfer_partial -+ interface. */ -+ -+static LONGEST -+linux_core_xfer_siginfo (struct gdbarch *gdbarch, gdb_byte *readbuf, -+ ULONGEST offset, ULONGEST len) -+{ -+ thread_section_name section_name (".note.linuxcore.siginfo", inferior_ptid); -+ asection *section = bfd_get_section_by_name (core_bfd, section_name.c_str ()); -+ if (section == NULL) -+ return -1; -+ -+ if (!bfd_get_section_contents (core_bfd, section, readbuf, offset, len)) -+ return -1; -+ -+ return len; -+} -+ - typedef int linux_find_memory_region_ftype (ULONGEST vaddr, ULONGEST size, - ULONGEST offset, ULONGEST inode, - int read, int write, -@@ -2516,6 +2536,7 @@ linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) - set_gdbarch_core_pid_to_str (gdbarch, linux_core_pid_to_str); - set_gdbarch_info_proc (gdbarch, linux_info_proc); - set_gdbarch_core_info_proc (gdbarch, linux_core_info_proc); -+ set_gdbarch_core_xfer_siginfo (gdbarch, linux_core_xfer_siginfo); - set_gdbarch_find_memory_regions (gdbarch, linux_find_memory_regions); - set_gdbarch_make_corefile_notes (gdbarch, linux_make_corefile_notes); - set_gdbarch_has_shared_address_space (gdbarch, Property changes on: head/devel/gdb/files/commit-382b69bbb7 ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/devel/gdb/files/patch-armfbsd =================================================================== --- head/devel/gdb/files/patch-armfbsd (revision 464492) +++ head/devel/gdb/files/patch-armfbsd (nonexistent) @@ -1,512 +0,0 @@ -diff --git gdb/arm-fbsd-nat.c gdb/arm-fbsd-nat.c -new file mode 100644 -index 0000000000..b1c5c360f8 ---- /dev/null -+++ gdb/arm-fbsd-nat.c -@@ -0,0 +1,151 @@ -+/* Native-dependent code for FreeBSD/arm. -+ -+ Copyright (C) 2017 Free Software Foundation, Inc. -+ -+ This file is part of GDB. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program. If not, see . */ -+ -+#include "defs.h" -+#include "target.h" -+ -+#include -+#include -+#include -+ -+#include "fbsd-nat.h" -+#include "arm-tdep.h" -+#include "arm-fbsd-tdep.h" -+#include "inf-ptrace.h" -+ -+/* Determine if PT_GETREGS fetches REGNUM. */ -+ -+static bool -+getregs_supplies (struct gdbarch *gdbarch, int regnum) -+{ -+ return ((regnum >= ARM_A1_REGNUM && regnum <= ARM_PC_REGNUM) -+ || regnum == ARM_PS_REGNUM); -+} -+ -+#ifdef PT_GETVFPREGS -+/* Determine if PT_GETVFPREGS fetches REGNUM. */ -+ -+static bool -+getvfpregs_supplies (struct gdbarch *gdbarch, int regnum) -+{ -+ return ((regnum >= ARM_D0_REGNUM && regnum <= ARM_D31_REGNUM) -+ || regnum == ARM_FPSCR_REGNUM); -+} -+#endif -+ -+/* Fetch register REGNUM from the inferior. If REGNUM is -1, do this -+ for all registers. */ -+ -+static void -+arm_fbsd_fetch_inferior_registers (struct target_ops *ops, -+ struct regcache *regcache, int regnum) -+{ -+ pid_t pid = get_ptrace_pid (regcache_get_ptid (regcache)); -+ -+ struct gdbarch *gdbarch = get_regcache_arch (regcache); -+ if (regnum == -1 || getregs_supplies (gdbarch, regnum)) -+ { -+ struct reg regs; -+ -+ if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1) -+ perror_with_name (_("Couldn't get registers")); -+ -+ regcache_supply_regset (&arm_fbsd_gregset, regcache, regnum, ®s, -+ sizeof (regs)); -+ } -+ -+#ifdef PT_GETVFPREGS -+ if (regnum == -1 || getvfpregs_supplies (gdbarch, regnum)) -+ { -+ struct vfpreg vfpregs; -+ -+ if (ptrace (PT_GETVFPREGS, pid, (PTRACE_TYPE_ARG3) &vfpregs, 0) == -1) -+ perror_with_name (_("Couldn't get floating point status")); -+ -+ regcache_supply_regset (&arm_fbsd_vfpregset, regcache, regnum, &vfpregs, -+ sizeof (vfpregs)); -+ } -+#endif -+} -+ -+/* Store register REGNUM back into the inferior. If REGNUM is -1, do -+ this for all registers. */ -+ -+static void -+arm_fbsd_store_inferior_registers (struct target_ops *ops, -+ struct regcache *regcache, int regnum) -+{ -+ pid_t pid = get_ptrace_pid (regcache_get_ptid (regcache)); -+ -+ struct gdbarch *gdbarch = get_regcache_arch (regcache); -+ if (regnum == -1 || getregs_supplies (gdbarch, regnum)) -+ { -+ struct reg regs; -+ -+ if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1) -+ perror_with_name (_("Couldn't get registers")); -+ -+ regcache_collect_regset (&arm_fbsd_gregset, regcache, regnum, ®s, -+ sizeof (regs)); -+ -+ if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1) -+ perror_with_name (_("Couldn't write registers")); -+ } -+ -+#ifdef PT_GETVFPREGS -+ if (regnum == -1 || getvfpregs_supplies (gdbarch, regnum)) -+ { -+ struct vfpreg vfpregs; -+ -+ if (ptrace (PT_GETVFPREGS, pid, (PTRACE_TYPE_ARG3) &vfpregs, 0) == -1) -+ perror_with_name (_("Couldn't get floating point status")); -+ -+ regcache_collect_regset (&arm_fbsd_vfpregset, regcache, regnum, &vfpregs, -+ sizeof (vfpregs)); -+ -+ if (ptrace (PT_SETVFPREGS, pid, (PTRACE_TYPE_ARG3) &vfpregs, 0) == -1) -+ perror_with_name (_("Couldn't write floating point status")); -+ } -+#endif -+} -+ -+/* Implement the to_read_description method. */ -+ -+static const struct target_desc * -+arm_fbsd_read_description (struct target_ops *ops) -+{ -+ const struct target_desc *desc; -+ -+ desc = arm_fbsd_read_description_auxv (ops); -+ if (desc == NULL) -+ desc = ops->beneath->to_read_description (ops->beneath); -+ return desc; -+} -+ -+void -+_initialize_arm_fbsd_nat (void) -+{ -+ struct target_ops *t; -+ -+ t = inf_ptrace_target (); -+ t->to_fetch_registers = arm_fbsd_fetch_inferior_registers; -+ t->to_store_registers = arm_fbsd_store_inferior_registers; -+ t->to_read_description = arm_fbsd_read_description; -+ fbsd_nat_add_target (t); -+} -diff --git gdb/arm-fbsd-tdep.c gdb/arm-fbsd-tdep.c -new file mode 100644 -index 0000000000..02697b3de8 ---- /dev/null -+++ gdb/arm-fbsd-tdep.c -@@ -0,0 +1,260 @@ -+/* Target-dependent code for FreeBSD/arm. -+ -+ Copyright (C) 2017 Free Software Foundation, Inc. -+ -+ This file is part of GDB. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program. If not, see . */ -+ -+#include "defs.h" -+ -+#include "elf/common.h" -+#include "arm-tdep.h" -+#include "arm-fbsd-tdep.h" -+#include "auxv.h" -+#include "fbsd-tdep.h" -+#include "osabi.h" -+#include "solib-svr4.h" -+#include "target.h" -+#include "trad-frame.h" -+#include "tramp-frame.h" -+ -+/* In a signal frame, sp points to a 'struct sigframe' which is -+ defined as: -+ -+ struct sigframe { -+ siginfo_t sf_si; -+ ucontext_t sf_uc; -+ mcontext_vfp_t sf_vfp; -+ }; -+ -+ ucontext_t is defined as: -+ -+ struct __ucontext { -+ sigset_t uc_sigmask; -+ mcontext_t uc_mcontext; -+ ... -+ }; -+ -+ mcontext_t is defined as: -+ -+ struct { -+ unsigned int __gregs[17]; -+ size_t mc_vfp_size; -+ void *mc_vfp_ptr; -+ ... -+ }; -+ -+ mcontext_vfp_t is defined as: -+ -+ struct { -+ uint64_t mcv_reg[32]; -+ uint32_t mcv_fpscr; -+ }; -+ -+ If the VFP state is valid, then mc_vfp_ptr will point to sf_vfp in -+ the sigframe, otherwise it is NULL. There is no non-VFP floating -+ point register state saved in the signal frame. */ -+ -+#define ARM_MCONTEXT_REG_SIZE 4 -+#define ARM_MCONTEXT_VFP_REG_SIZE 8 -+#define ARM_SIGFRAME_UCONTEXT_OFFSET 64 -+#define ARM_UCONTEXT_MCONTEXT_OFFSET 16 -+#define ARM_MCONTEXT_VFP_PTR_OFFSET 72 -+ -+/* Implement the "init" method of struct tramp_frame. */ -+ -+static void -+arm_fbsd_sigframe_init (const struct tramp_frame *self, -+ struct frame_info *this_frame, -+ struct trad_frame_cache *this_cache, -+ CORE_ADDR func) -+{ -+ struct gdbarch *gdbarch = get_frame_arch (this_frame); -+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); -+ CORE_ADDR sp = get_frame_register_unsigned (this_frame, ARM_SP_REGNUM); -+ CORE_ADDR mcontext_addr = -+ sp -+ + ARM_SIGFRAME_UCONTEXT_OFFSET -+ + ARM_UCONTEXT_MCONTEXT_OFFSET; -+ CORE_ADDR mcontext_vfp_addr; -+ gdb_byte buf[4]; -+ int i; -+ -+ for (i = 0; i < 16; i++) -+ { -+ trad_frame_set_reg_addr (this_cache, -+ ARM_A1_REGNUM + i, -+ mcontext_addr + i * ARM_MCONTEXT_REG_SIZE); -+ } -+ trad_frame_set_reg_addr (this_cache, ARM_PS_REGNUM, -+ mcontext_addr + 16 * ARM_MCONTEXT_REG_SIZE); -+ -+ mcontext_vfp_addr = 0; -+ if (target_read_memory (mcontext_addr + ARM_MCONTEXT_VFP_PTR_OFFSET, buf, -+ 4) == 0) -+ mcontext_vfp_addr = extract_unsigned_integer (buf, 4, byte_order); -+ if (mcontext_vfp_addr != 0) -+ { -+ for (i = 0; i < 32; i++) -+ { -+ trad_frame_set_reg_addr (this_cache, ARM_D0_REGNUM + i, -+ mcontext_vfp_addr -+ + i * ARM_MCONTEXT_VFP_REG_SIZE); -+ } -+ trad_frame_set_reg_addr (this_cache, ARM_FPSCR_REGNUM, -+ mcontext_vfp_addr -+ + 32 * ARM_MCONTEXT_VFP_REG_SIZE); -+ } -+ -+ trad_frame_set_id (this_cache, frame_id_build (sp, func)); -+} -+ -+static const struct tramp_frame arm_fbsd_sigframe = -+{ -+ SIGTRAMP_FRAME, -+ 4, -+ { -+ {0xe1a0000d, -1}, /* mov r0, sp */ -+ {0xe2800040, -1}, /* add r0, r0, #SIGF_UC */ -+ {0xe59f700c, -1}, /* ldr r7, [pc, #12] */ -+ {0xef0001a1, -1}, /* swi SYS_sigreturn */ -+ {TRAMP_SENTINEL_INSN, -1} -+ }, -+ arm_fbsd_sigframe_init -+}; -+ -+/* Register maps. */ -+ -+static const struct regcache_map_entry arm_fbsd_gregmap[] = -+ { -+ { 13, ARM_A1_REGNUM, 4 }, /* r0 ... r12 */ -+ { 1, ARM_SP_REGNUM, 4 }, -+ { 1, ARM_LR_REGNUM, 4 }, -+ { 1, ARM_PC_REGNUM, 4 }, -+ { 1, ARM_PS_REGNUM, 4 }, -+ { 0 } -+ }; -+ -+static const struct regcache_map_entry arm_fbsd_vfpregmap[] = -+ { -+ { 32, ARM_D0_REGNUM, 8 }, /* d0 ... d31 */ -+ { 1, ARM_FPSCR_REGNUM, 4 }, -+ { 0 } -+ }; -+ -+/* Register set definitions. */ -+ -+const struct regset arm_fbsd_gregset = -+ { -+ arm_fbsd_gregmap, -+ regcache_supply_regset, regcache_collect_regset -+ }; -+ -+const struct regset arm_fbsd_vfpregset = -+ { -+ arm_fbsd_vfpregmap, -+ regcache_supply_regset, regcache_collect_regset -+ }; -+ -+/* Implement the "regset_from_core_section" gdbarch method. */ -+ -+static void -+arm_fbsd_iterate_over_regset_sections (struct gdbarch *gdbarch, -+ iterate_over_regset_sections_cb *cb, -+ void *cb_data, -+ const struct regcache *regcache) -+{ -+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); -+ -+ cb (".reg", ARM_FBSD_SIZEOF_GREGSET, &arm_fbsd_gregset, NULL, cb_data); -+ -+ /* While FreeBSD/arm cores do contain a NT_FPREGSET / ".reg2" -+ register set, it is not populated with register values by the -+ kernel but just contains all zeroes. */ -+ if (tdep->vfp_register_count > 0) -+ cb (".reg-arm-vfp", ARM_FBSD_SIZEOF_VFPREGSET, &arm_fbsd_vfpregset, -+ "VFP floating-point", cb_data); -+} -+ -+/* Lookup a target description from a target's AT_HWCAP auxiliary -+ vector. */ -+ -+const struct target_desc * -+arm_fbsd_read_description_auxv (struct target_ops *target) -+{ -+ CORE_ADDR arm_hwcap = 0; -+ -+ if (target_auxv_search (target, AT_FREEBSD_HWCAP, &arm_hwcap) != 1) -+ return NULL; -+ -+ if (arm_hwcap & HWCAP_VFP) -+ { -+ if (arm_hwcap & HWCAP_NEON) -+ return tdesc_arm_with_neon; -+ else if ((arm_hwcap & (HWCAP_VFPv3 | HWCAP_VFPD32)) -+ == (HWCAP_VFPv3 | HWCAP_VFPD32)) -+ return tdesc_arm_with_vfpv3; -+ else -+ return tdesc_arm_with_vfpv2; -+ } -+ -+ return NULL; -+} -+ -+/* Implement the "core_read_description" gdbarch method. */ -+ -+static const struct target_desc * -+arm_fbsd_core_read_description (struct gdbarch *gdbarch, -+ struct target_ops *target, -+ bfd *abfd) -+{ -+ return arm_fbsd_read_description_auxv (target); -+} -+ -+/* Implement the 'init_osabi' method of struct gdb_osabi_handler. */ -+ -+static void -+arm_fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) -+{ -+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); -+ -+ /* Generic FreeBSD support. */ -+ fbsd_init_abi (info, gdbarch); -+ -+ if (tdep->fp_model == ARM_FLOAT_AUTO) -+ tdep->fp_model = ARM_FLOAT_SOFT_VFP; -+ -+ tramp_frame_prepend_unwinder (gdbarch, &arm_fbsd_sigframe); -+ -+ set_solib_svr4_fetch_link_map_offsets -+ (gdbarch, svr4_ilp32_fetch_link_map_offsets); -+ -+ tdep->jb_pc = 24; -+ tdep->jb_elt_size = 4; -+ -+ set_gdbarch_iterate_over_regset_sections -+ (gdbarch, arm_fbsd_iterate_over_regset_sections); -+ set_gdbarch_core_read_description (gdbarch, arm_fbsd_core_read_description); -+ -+ /* Single stepping. */ -+ set_gdbarch_software_single_step (gdbarch, arm_software_single_step); -+} -+ -+void -+_initialize_arm_fbsd_tdep (void) -+{ -+ gdbarch_register_osabi (bfd_arch_arm, 0, GDB_OSABI_FREEBSD, -+ arm_fbsd_init_abi); -+} -diff --git gdb/arm-fbsd-tdep.h gdb/arm-fbsd-tdep.h -new file mode 100644 -index 0000000000..8717b804af ---- /dev/null -+++ gdb/arm-fbsd-tdep.h -@@ -0,0 +1,40 @@ -+/* FreeBSD/arm target support, prototypes. -+ -+ Copyright (C) 2017 Free Software Foundation, Inc. -+ -+ This file is part of GDB. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program. If not, see . */ -+ -+#include "regset.h" -+ -+/* The general-purpose regset consists of 13 R registers, plus SP, LR, -+ PC, and CPSR registers. */ -+#define ARM_FBSD_SIZEOF_GREGSET (17 * 4) -+ -+/* The VFP regset consists of 32 D registers plus FPSCR, and the whole -+ structure is padded to 64-bit alignment. */ -+#define ARM_FBSD_SIZEOF_VFPREGSET (33 * 8) -+ -+extern const struct regset arm_fbsd_gregset; -+extern const struct regset arm_fbsd_vfpregset; -+ -+/* Flags passed in AT_HWCAP. */ -+#define HWCAP_VFP 0x00000040 -+#define HWCAP_NEON 0x00001000 -+#define HWCAP_VFPv3 0x00002000 -+#define HWCAP_VFPD32 0x00080000 -+ -+extern const struct target_desc * -+arm_fbsd_read_description_auxv (struct target_ops *target); ---- /dev/null -+++ gdb/config/arm/fbsd.mh -@@ -0,0 +1,3 @@ -+# Host: FreeBSD/arm -+NATDEPFILES= arm-fbsd-nat.o fbsd-nat.o fork-child.o inf-ptrace.o -+HAVE_NATIVE_GCORE_HOST = 1 -diff --git gdb/configure.tgt gdb/configure.tgt -index 122a72608f..06957c111d 100644 ---- gdb/configure.tgt -+++ gdb/configure.tgt -@@ -110,6 +110,11 @@ arm*-*-linux*) - solib-svr4.o symfile-mem.o linux-tdep.o linux-record.o" - build_gdbserver=yes - ;; -+arm*-*-freebsd*) -+ # Target: FreeBSD/arm -+ gdb_target_obs="arm.o arm-get-next-pcs.o arm-tdep.o arm-fbsd-tdep.o \ -+ fbsd-tdep.o solib-svr4.o" -+ ;; - arm*-*-netbsd* | arm*-*-knetbsd*-gnu) - # Target: NetBSD/arm - gdb_target_obs="arm.o arm-get-next-pcs.o arm-tdep.o arm-nbsd-tdep.o \ -diff --git gdb/Makefile.in gdb/Makefile.in -index 9454e3a62f..c9bd60a2d8 100644 ---- gdb/Makefile.in -+++ gdb/Makefile.in -@@ -794,6 +794,7 @@ ALL_TARGET_OBS = \ - arc-tdep.o \ - arm.o \ - arm-bsd-tdep.o \ -+ arm-fbsd-tdep.o \ - arm-get-next-pcs.o \ - arm-linux.o \ - arm-linux-tdep.o \ -@@ -2537,6 +2538,8 @@ ALLDEPFILES = \ - arc-tdep.c \ - arm.c \ - arm-bsd-tdep.c \ -+ arm-fbsd-nat.c \ -+ arm-fbsd-tdep.c \ - arm-get-next-pcs.c \ - arm-linux.c \ - arm-linux-nat.c \ Property changes on: head/devel/gdb/files/patch-armfbsd ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/devel/gdb/files/commit-2af9fc4432 =================================================================== --- head/devel/gdb/files/commit-2af9fc4432 (revision 464492) +++ head/devel/gdb/files/commit-2af9fc4432 (nonexistent) @@ -1,35 +0,0 @@ -commit 2af9fc4432bbda5ebd805bf5b56d81cd80d0cbf5 -Author: John Baldwin -Date: Wed Jun 28 11:21:10 2017 -0700 - - Use the thread_section_name helper class in fbsd_core_thread_name. - - gdb/ChangeLog: - - * fbsd-tdep.c (fbsd_core_thread_name): Use thread_section_name. - -diff --git gdb/fbsd-tdep.c gdb/fbsd-tdep.c -index 24a3c20dd6..32df104208 100644 ---- gdb/fbsd-tdep.c -+++ gdb/fbsd-tdep.c -@@ -75,7 +75,6 @@ fbsd_core_thread_name (struct gdbarch *gdbarch, struct thread_info *thr) - static char buf[80]; - struct bfd_section *section; - bfd_size_type size; -- char sectionstr[32]; - - if (ptid_get_lwp (thr->ptid) != 0) - { -@@ -86,9 +85,9 @@ fbsd_core_thread_name (struct gdbarch *gdbarch, struct thread_info *thr) - structure. Rather than define the full structure here, just - extract the null-terminated name from the start of the - note. */ -- xsnprintf (sectionstr, sizeof sectionstr, ".thrmisc/%ld", -- ptid_get_lwp (thr->ptid)); -- section = bfd_get_section_by_name (core_bfd, sectionstr); -+ thread_section_name section_name (".thrmisc", thr->ptid); -+ -+ section = bfd_get_section_by_name (core_bfd, section_name.c_str ()); - if (section != NULL && bfd_section_size (core_bfd, section) > 0) - { - /* Truncate the name if it is longer than "buf". */ Property changes on: head/devel/gdb/files/commit-2af9fc4432 ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/devel/gdb/files/patch-aarch64-fbsd =================================================================== --- head/devel/gdb/files/patch-aarch64-fbsd (revision 464492) +++ head/devel/gdb/files/patch-aarch64-fbsd (nonexistent) @@ -1,468 +0,0 @@ ---- gdb/Makefile.in.orig 2017-09-14 09:28:17 UTC -+++ gdb/Makefile.in -@@ -745,6 +745,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-tdep.o \ - aarch64-insn.o \ - aarch64-linux-tdep.o \ - aarch64-newlib-tdep.o \ -@@ -2458,6 +2459,8 @@ force_update: - MAKEOVERRIDES = - - ALLDEPFILES = \ -+ aarch64-fbsd-nat.c \ -+ aarch64-fbsd-tdep.c \ - aarch64-linux-nat.c \ - aarch64-linux-tdep.c \ - aarch64-newlib-tdep.c \ -diff --git gdb/aarch64-fbsd-nat.c gdb/aarch64-fbsd-nat.c -new file mode 100644 -index 0000000000..f7855b9c0b ---- /dev/null -+++ gdb/aarch64-fbsd-nat.c -@@ -0,0 +1,133 @@ -+/* Native-dependent code for FreeBSD/aarch64. -+ -+ Copyright (C) 2017 Free Software Foundation, Inc. -+ -+ This file is part of GDB. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program. If not, see . */ -+ -+#include "defs.h" -+#include "target.h" -+ -+#include -+#include -+#include -+ -+#include "fbsd-nat.h" -+#include "aarch64-tdep.h" -+#include "aarch64-fbsd-tdep.h" -+#include "inf-ptrace.h" -+ -+/* Determine if PT_GETREGS fetches REGNUM. */ -+ -+static bool -+getregs_supplies (struct gdbarch *gdbarch, int regnum) -+{ -+ return (regnum >= AARCH64_X0_REGNUM && regnum <= AARCH64_CPSR_REGNUM); -+} -+ -+/* Determine if PT_GETFPREGS fetches REGNUM. */ -+ -+static bool -+getfpregs_supplies (struct gdbarch *gdbarch, int regnum) -+{ -+ return (regnum >= AARCH64_V0_REGNUM && regnum <= AARCH64_FPCR_REGNUM); -+} -+ -+/* Fetch register REGNUM from the inferior. If REGNUM is -1, do this -+ for all registers. */ -+ -+static void -+aarch64_fbsd_fetch_inferior_registers (struct target_ops *ops, -+ struct regcache *regcache, int regnum) -+{ -+ pid_t pid = get_ptrace_pid (regcache_get_ptid (regcache)); -+ -+ struct gdbarch *gdbarch = get_regcache_arch (regcache); -+ if (regnum == -1 || getregs_supplies (gdbarch, regnum)) -+ { -+ struct reg regs; -+ -+ if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1) -+ perror_with_name (_("Couldn't get registers")); -+ -+ regcache_supply_regset (&aarch64_fbsd_gregset, regcache, regnum, ®s, -+ sizeof (regs)); -+ } -+ -+ if (regnum == -1 || getfpregs_supplies (gdbarch, regnum)) -+ { -+ struct fpreg fpregs; -+ -+ if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) -+ perror_with_name (_("Couldn't get floating point status")); -+ -+ regcache_supply_regset (&aarch64_fbsd_fpregset, regcache, regnum, &fpregs, -+ sizeof (fpregs)); -+ } -+} -+ -+/* Store register REGNUM back into the inferior. If REGNUM is -1, do -+ this for all registers. */ -+ -+static void -+aarch64_fbsd_store_inferior_registers (struct target_ops *ops, -+ struct regcache *regcache, int regnum) -+{ -+ pid_t pid = get_ptrace_pid (regcache_get_ptid (regcache)); -+ -+ struct gdbarch *gdbarch = get_regcache_arch (regcache); -+ if (regnum == -1 || getregs_supplies (gdbarch, regnum)) -+ { -+ struct reg regs; -+ -+ if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1) -+ perror_with_name (_("Couldn't get registers")); -+ -+ regcache_collect_regset (&aarch64_fbsd_gregset, regcache, regnum, ®s, -+ sizeof (regs)); -+ -+ if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1) -+ perror_with_name (_("Couldn't write registers")); -+ } -+ -+ if (regnum == -1 || getfpregs_supplies (gdbarch, regnum)) -+ { -+ struct fpreg fpregs; -+ -+ if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) -+ perror_with_name (_("Couldn't get floating point status")); -+ -+ regcache_collect_regset (&aarch64_fbsd_fpregset, regcache, regnum, &fpregs, -+ sizeof (fpregs)); -+ -+ if (ptrace (PT_SETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) -+ perror_with_name (_("Couldn't write floating point status")); -+ } -+} -+ -+ -+/* Provide a prototype to silence -Wmissing-prototypes. */ -+void _initialize_aarch64_fbsd_nat (void); -+ -+void -+_initialize_aarch64_fbsd_nat (void) -+{ -+ struct target_ops *t; -+ -+ t = inf_ptrace_target (); -+ t->to_fetch_registers = aarch64_fbsd_fetch_inferior_registers; -+ t->to_store_registers = aarch64_fbsd_store_inferior_registers; -+ fbsd_nat_add_target (t); -+} -diff --git gdb/aarch64-fbsd-tdep.c gdb/aarch64-fbsd-tdep.c -new file mode 100644 -index 0000000000..f8ce627282 ---- /dev/null -+++ gdb/aarch64-fbsd-tdep.c -@@ -0,0 +1,208 @@ -+/* Target-dependent code for FreeBSD/aarch64. -+ -+ Copyright (C) 2017 Free Software Foundation, Inc. -+ -+ This file is part of GDB. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program. If not, see . */ -+ -+#include "defs.h" -+ -+#include "gdbarch.h" -+#include "fbsd-tdep.h" -+#include "aarch64-tdep.h" -+#include "aarch64-fbsd-tdep.h" -+#include "osabi.h" -+#include "solib-svr4.h" -+#include "target.h" -+#include "tramp-frame.h" -+#include "trad-frame.h" -+ -+/* In a signal frame, sp points to a 'struct sigframe' which is -+ defined as: -+ -+ struct sigframe { -+ siginfo_t sf_si; -+ ucontext_t sf_uc; -+ }; -+ -+ ucontext_t is defined as: -+ -+ struct __ucontext { -+ sigset_t uc_sigmask; -+ mcontext_t uc_mcontext; -+ ... -+ }; -+ -+ The mcontext_t contains the general purpose register set followed -+ by the floating point register set. The floating point register -+ set is only valid if the _MC_FP_VALID flag is set in mc_flags. */ -+ -+#define AARCH64_MCONTEXT_REG_SIZE 8 -+#define AARCH64_MCONTEXT_FPREG_SIZE 16 -+#define AARCH64_SIGFRAME_UCONTEXT_OFFSET 80 -+#define AARCH64_UCONTEXT_MCONTEXT_OFFSET 16 -+#define AARCH64_MCONTEXT_FPREGS_OFFSET 272 -+#define AARCH64_MCONTEXT_FLAGS_OFFSET 800 -+#define AARCH64_MCONTEXT_FLAG_FP_VALID 0x1 -+ -+/* Implement the "init" method of struct tramp_frame. */ -+ -+static void -+aarch64_fbsd_sigframe_init (const struct tramp_frame *self, -+ struct frame_info *this_frame, -+ struct trad_frame_cache *this_cache, -+ CORE_ADDR func) -+{ -+ struct gdbarch *gdbarch = get_frame_arch (this_frame); -+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); -+ CORE_ADDR sp = get_frame_register_unsigned (this_frame, AARCH64_SP_REGNUM); -+ CORE_ADDR mcontext_addr = -+ sp -+ + AARCH64_SIGFRAME_UCONTEXT_OFFSET -+ + AARCH64_UCONTEXT_MCONTEXT_OFFSET; -+ gdb_byte buf[4]; -+ int i; -+ -+ for (i = 0; i < 30; i++) -+ { -+ trad_frame_set_reg_addr (this_cache, -+ AARCH64_X0_REGNUM + i, -+ mcontext_addr + i * AARCH64_MCONTEXT_REG_SIZE); -+ } -+ trad_frame_set_reg_addr (this_cache, AARCH64_LR_REGNUM, -+ mcontext_addr + 30 * AARCH64_MCONTEXT_REG_SIZE); -+ trad_frame_set_reg_addr (this_cache, AARCH64_SP_REGNUM, -+ mcontext_addr + 31 * AARCH64_MCONTEXT_REG_SIZE); -+ trad_frame_set_reg_addr (this_cache, AARCH64_PC_REGNUM, -+ mcontext_addr + 32 * AARCH64_MCONTEXT_REG_SIZE); -+ trad_frame_set_reg_addr (this_cache, AARCH64_CPSR_REGNUM, -+ mcontext_addr + 33 * AARCH64_MCONTEXT_REG_SIZE); -+ -+ if (target_read_memory (mcontext_addr + AARCH64_MCONTEXT_FLAGS_OFFSET, buf, -+ 4) == 0 -+ && (extract_unsigned_integer (buf, 4, byte_order) -+ & AARCH64_MCONTEXT_FLAG_FP_VALID)) -+ { -+ for (i = 0; i < 32; i++) -+ { -+ trad_frame_set_reg_addr (this_cache, AARCH64_V0_REGNUM + i, -+ mcontext_addr -+ + AARCH64_MCONTEXT_FPREGS_OFFSET -+ + i * AARCH64_MCONTEXT_FPREG_SIZE); -+ } -+ trad_frame_set_reg_addr (this_cache, AARCH64_FPSR_REGNUM, -+ mcontext_addr + AARCH64_MCONTEXT_FPREGS_OFFSET -+ + 32 * AARCH64_MCONTEXT_FPREG_SIZE); -+ trad_frame_set_reg_addr (this_cache, AARCH64_FPCR_REGNUM, -+ mcontext_addr + AARCH64_MCONTEXT_FPREGS_OFFSET -+ + 32 * AARCH64_MCONTEXT_FPREG_SIZE + 4); -+ } -+ -+ trad_frame_set_id (this_cache, frame_id_build (sp, func)); -+} -+ -+static const struct tramp_frame aarch64_fbsd_sigframe = -+{ -+ SIGTRAMP_FRAME, -+ 4, -+ { -+ {0x910003e0, -1}, /* mov x0, sp */ -+ {0x91014000, -1}, /* add x0, x0, #SF_UC */ -+ {0xd2803428, -1}, /* mov x8, #SYS_sigreturn */ -+ {0xd4000001, -1}, /* svc 0x0 */ -+ {TRAMP_SENTINEL_INSN, -1} -+ }, -+ aarch64_fbsd_sigframe_init -+}; -+ -+/* Register maps. */ -+ -+static const struct regcache_map_entry aarch64_fbsd_gregmap[] = -+ { -+ { 30, AARCH64_X0_REGNUM, 8 }, /* x0 ... x29 */ -+ { 1, AARCH64_LR_REGNUM, 8 }, -+ { 1, AARCH64_SP_REGNUM, 8 }, -+ { 1, AARCH64_PC_REGNUM, 8 }, -+ { 1, AARCH64_CPSR_REGNUM, 4 }, -+ { 0 } -+ }; -+ -+static const struct regcache_map_entry aarch64_fbsd_fpregmap[] = -+ { -+ { 32, AARCH64_V0_REGNUM, 16 }, /* v0 ... v31 */ -+ { 1, AARCH64_FPSR_REGNUM, 4 }, -+ { 1, AARCH64_FPCR_REGNUM, 4 }, -+ { 0 } -+ }; -+ -+/* Register set definitions. */ -+ -+const struct regset aarch64_fbsd_gregset = -+ { -+ aarch64_fbsd_gregmap, -+ regcache_supply_regset, regcache_collect_regset -+ }; -+ -+const struct regset aarch64_fbsd_fpregset = -+ { -+ aarch64_fbsd_fpregmap, -+ regcache_supply_regset, regcache_collect_regset -+ }; -+ -+/* Implement the "regset_from_core_section" gdbarch method. */ -+ -+static void -+aarch64_fbsd_iterate_over_regset_sections (struct gdbarch *gdbarch, -+ iterate_over_regset_sections_cb *cb, -+ void *cb_data, -+ const struct regcache *regcache) -+{ -+ cb (".reg", AARCH64_FBSD_SIZEOF_GREGSET, &aarch64_fbsd_gregset, -+ NULL, cb_data); -+ cb (".reg2", AARCH64_FBSD_SIZEOF_FPREGSET, &aarch64_fbsd_fpregset, -+ NULL, cb_data); -+} -+ -+/* Implement the 'init_osabi' method of struct gdb_osabi_handler. */ -+ -+static void -+aarch64_fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) -+{ -+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); -+ -+ /* Generic FreeBSD support. */ -+ fbsd_init_abi (info, gdbarch); -+ -+ set_solib_svr4_fetch_link_map_offsets (gdbarch, -+ svr4_lp64_fetch_link_map_offsets); -+ -+ tramp_frame_prepend_unwinder (gdbarch, &aarch64_fbsd_sigframe); -+ -+ /* Enable longjmp. */ -+ tdep->jb_pc = 13; -+ -+ set_gdbarch_iterate_over_regset_sections -+ (gdbarch, aarch64_fbsd_iterate_over_regset_sections); -+} -+ -+/* Provide a prototype to silence -Wmissing-prototypes. */ -+extern initialize_file_ftype _initialize_aarch64_fbsd_tdep; -+ -+void -+_initialize_aarch64_fbsd_tdep (void) -+{ -+ gdbarch_register_osabi (bfd_arch_aarch64, 0, GDB_OSABI_FREEBSD, -+ aarch64_fbsd_init_abi); -+} -diff --git gdb/aarch64-fbsd-tdep.h gdb/aarch64-fbsd-tdep.h -new file mode 100644 -index 0000000000..0f66dd3925 ---- /dev/null -+++ gdb/aarch64-fbsd-tdep.h -@@ -0,0 +1,33 @@ -+/* FreeBSD/aarch64 target support, prototypes. -+ -+ Copyright (C) 2017 Free Software Foundation, Inc. -+ -+ This file is part of GDB. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program. If not, see . */ -+ -+#include "regset.h" -+ -+/* The general-purpose regset consists of 30 X registers, plus LR, SP, -+ ELR, and SPSR registers. SPSR is 32 bits but the structure is -+ passed to 64 bit alignment. */ -+#define AARCH64_FBSD_SIZEOF_GREGSET (34 * X_REGISTER_SIZE) -+ -+/* The fp regset consists of 32 V registers, plus FPSR and FPCR which -+ are 4 bytes wide each, and the whole structure is padded to 128 bit -+ alignment. */ -+#define AARCH64_FBSD_SIZEOF_FPREGSET (33 * V_REGISTER_SIZE) -+ -+extern const struct regset aarch64_fbsd_gregset; -+extern const struct regset aarch64_fbsd_fpregset; -diff --git gdb/config/aarch64/fbsd.mh gdb/config/aarch64/fbsd.mh -new file mode 100644 -index 0000000000..4171987bc9 ---- /dev/null -+++ gdb/config/aarch64/fbsd.mh -@@ -0,0 +1,23 @@ -+# Host: Freebsd/aarch64 -+# -+# Copyright (C) 2017 Free Software Foundation, Inc. -+# -+# This file is part of GDB. -+# -+# This program is free software; you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 3 of the License, or -+# (at your option) any later version. -+# -+# This program is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with this program. If not, see . -+ -+NATDEPFILES= inf-ptrace.o fork-child.o aarch64-fbsd-nat.o fbsd-nat.o -+HAVE_NATIVE_GCORE_HOST = 1 -+ -+LOADLIBES= -lkvm -diff --git gdb/configure.host gdb/configure.host -index d74fd04934..304675f137 100644 ---- gdb/configure.host -+++ gdb/configure.host -@@ -84,6 +84,7 @@ case "${host}" in - *-*-darwin*) gdb_host=darwin ;; - - aarch64*-*-linux*) gdb_host=linux ;; -+aarch64*-*-freebsd*) gdb_host=fbsd ;; - - alpha*-*-linux*) gdb_host=alpha-linux ;; - alpha*-*-netbsd* | alpha*-*-knetbsd*-gnu) -diff --git gdb/configure.tgt gdb/configure.tgt -index fdcb7b1d69..f72a0dbbc1 100644 ---- gdb/configure.tgt -+++ gdb/configure.tgt -@@ -44,6 +44,11 @@ aarch64*-*-elf | aarch64*-*-rtems*) - gdb_target_obs="aarch64-tdep.o aarch64-newlib-tdep.o aarch64-insn.o" - ;; - -+aarch64*-*-freebsd*) -+ # Target: FreeBSD/aarch64 -+ gdb_target_obs="aarch64-tdep.o aarch64-fbsd-tdep.o aarch64-insn.o" -+ ;; -+ - aarch64*-*-linux*) - # Target: AArch64 linux - gdb_target_obs="aarch64-tdep.o aarch64-linux-tdep.o aarch64-insn.o \ Property changes on: head/devel/gdb/files/patch-aarch64-fbsd ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/devel/gdb/files/commit-4b654465bf =================================================================== --- head/devel/gdb/files/commit-4b654465bf (revision 464492) +++ head/devel/gdb/files/commit-4b654465bf (nonexistent) @@ -1,118 +0,0 @@ -commit 4b654465bfc3034c969d2d942c14b2cedfd3e3b6 -Author: John Baldwin -Date: Wed Jun 28 12:50:56 2017 -0700 - - Read signal information from FreeBSD core dumps. - - FreeBSD recently added a new ELF core note which dumps the entire LWP - info structure (the same structure returned by the ptrace PT_LWPINFO - operation) for each thread. The plan is for this note to eventually - supplant the older "thrmisc" ELF core note as it contains more - information and it permits new information to be exported via both - ptrace() and core dumps using the same structure. - - For signal information, the implementation is similar to the native - implementation for FreeBSD processes. The PL_FLAG_SI flag must be - checked to determine if the embedded siginfo_t structure is valid, and - if so it is transferred into the caller's buffer. - - gdb/ChangeLog: - - * fbsd-tdep.c (LWPINFO_OFFSET, LWPINFO_PL_FLAGS) - (LWPINFO64_PL_SIGINFO, LWPINFO32_PL_SIGINFO, PL_FLAG_SI) - (SIZE64_SIGINFO_T, SIZE32_SIGINFO_T, fbsd_core_xfer_siginfo): New. - (fbsd_init_abi): Install gdbarch "core_xfer_siginfo" method. - -diff --git gdb/fbsd-tdep.c gdb/fbsd-tdep.c -index 32df104208..6f30197a83 100644 ---- gdb/fbsd-tdep.c -+++ gdb/fbsd-tdep.c -@@ -30,6 +30,28 @@ - #include "fbsd-tdep.h" - - -+/* FreeBSD kernels 12.0 and later include a copy of the -+ 'ptrace_lwpinfo' structure returned by the PT_LWPINFO ptrace -+ operation in an ELF core note (NT_FREEBSD_PTLWPINFO) for each LWP. -+ The constants below define the offset of field members and flags in -+ this structure used by methods in this file. Note that the -+ 'ptrace_lwpinfo' struct in the note is preceded by a 4 byte integer -+ containing the size of the structure. */ -+ -+#define LWPINFO_OFFSET 0x4 -+ -+/* Offsets in ptrace_lwpinfo. */ -+#define LWPINFO_PL_FLAGS 0x8 -+#define LWPINFO64_PL_SIGINFO 0x30 -+#define LWPINFO32_PL_SIGINFO 0x2c -+ -+/* Flags in pl_flags. */ -+#define PL_FLAG_SI 0x20 /* siginfo is valid */ -+ -+/* Sizes of siginfo_t. */ -+#define SIZE64_SIGINFO_T 80 -+#define SIZE32_SIGINFO_T 64 -+ - static struct gdbarch_data *fbsd_gdbarch_data_handle; - - struct fbsd_gdbarch_data -@@ -113,6 +135,51 @@ fbsd_core_thread_name (struct gdbarch *gdbarch, struct thread_info *thr) - return NULL; - } - -+/* Implement the "core_xfer_siginfo" gdbarch method. */ -+ -+static LONGEST -+fbsd_core_xfer_siginfo (struct gdbarch *gdbarch, gdb_byte *readbuf, -+ ULONGEST offset, ULONGEST len) -+{ -+ size_t siginfo_size; -+ -+ if (gdbarch_bfd_arch_info (gdbarch)->bits_per_word == 32) -+ siginfo_size = SIZE32_SIGINFO_T; -+ else -+ siginfo_size = SIZE64_SIGINFO_T; -+ if (offset > siginfo_size) -+ return -1; -+ -+ thread_section_name section_name (".note.freebsdcore.lwpinfo", inferior_ptid); -+ asection *section = bfd_get_section_by_name (core_bfd, section_name.c_str ()); -+ if (section == NULL) -+ return -1; -+ -+ gdb_byte buf[4]; -+ if (!bfd_get_section_contents (core_bfd, section, buf, -+ LWPINFO_OFFSET + LWPINFO_PL_FLAGS, 4)) -+ return -1; -+ -+ int pl_flags = extract_signed_integer (buf, 4, gdbarch_byte_order (gdbarch)); -+ if (!(pl_flags & PL_FLAG_SI)) -+ return -1; -+ -+ if (offset + len > siginfo_size) -+ len = siginfo_size - offset; -+ -+ ULONGEST siginfo_offset; -+ if (gdbarch_bfd_arch_info (gdbarch)->bits_per_word == 32) -+ siginfo_offset = LWPINFO_OFFSET + LWPINFO32_PL_SIGINFO; -+ else -+ siginfo_offset = LWPINFO_OFFSET + LWPINFO64_PL_SIGINFO; -+ -+ if (!bfd_get_section_contents (core_bfd, section, readbuf, -+ siginfo_offset + offset, len)) -+ return -1; -+ -+ return len; -+} -+ - static int - find_signalled_thread (struct thread_info *info, void *data) - { -@@ -447,6 +514,7 @@ fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) - { - set_gdbarch_core_pid_to_str (gdbarch, fbsd_core_pid_to_str); - set_gdbarch_core_thread_name (gdbarch, fbsd_core_thread_name); -+ set_gdbarch_core_xfer_siginfo (gdbarch, fbsd_core_xfer_siginfo); - set_gdbarch_make_corefile_notes (gdbarch, fbsd_make_corefile_notes); - set_gdbarch_print_auxv_entry (gdbarch, fbsd_print_auxv_entry); - set_gdbarch_get_siginfo_type (gdbarch, fbsd_get_siginfo_type); Property changes on: head/devel/gdb/files/commit-4b654465bf ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/devel/gdb/files/commit-3c3ae77e68 =================================================================== --- head/devel/gdb/files/commit-3c3ae77e68 (revision 464492) +++ head/devel/gdb/files/commit-3c3ae77e68 (nonexistent) @@ -1,156 +0,0 @@ -commit 3c3ae77e68a9032ef9f174bf6b1cc992b6a4cb35 -Author: Pedro Alves -Date: Thu May 4 15:14:37 2017 +0100 - - Fix get_core_register_section leak, introduce thread_section_name - - This plugs a leak introduced in the previous change to - get_core_register_section, which removed an xfree call that is - actually necessary because the 'section_name' local is static. - - From [1] it looks like the reason the variable was made static to - begin with, was just "laziness" to avoid having to think about freeing - it on every function return path: - - https://sourceware.org/ml/gdb-patches/2005-03/msg00237.html - - The easiest to fix that nowadays is to use a std::string. - - I don't see a need to xstrdup the section name in the single-threaded - case though, and also there's more than one place that computes a - multi-threaded section name in the same way. So put the section name - computation in a wrapper class with state. - - gdb/ChangeLog: - 2017-05-04 Pedro Alves - - * corelow.c (thread_section_name): New class. - (get_core_register_section, get_core_siginfo): Use it. - -diff --git gdb/corelow.c gdb/corelow.c -index 2266f2467a..0aff02d4db 100644 ---- gdb/corelow.c -+++ gdb/corelow.c -@@ -485,6 +485,51 @@ core_detach (struct target_ops *ops, const char *args, int from_tty) - printf_filtered (_("No core file now.\n")); - } - -+/* Build either a single-thread or multi-threaded section name for -+ PTID. -+ -+ If ptid's lwp member is zero, we want to do the single-threaded -+ thing: look for a section named NAME (as passed to the -+ constructor). If ptid's lwp member is non-zero, we'll want do the -+ multi-threaded thing: look for a section named "NAME/LWP", where -+ LWP is the shortest ASCII decimal representation of ptid's lwp -+ member. */ -+ -+class thread_section_name -+{ -+public: -+ /* NAME is the single-threaded section name. If PTID represents an -+ LWP, then the build section name is "NAME/LWP", otherwise it's -+ just "NAME" unmodified. */ -+ thread_section_name (const char *name, ptid_t ptid) -+ { -+ if (ptid.lwp_p ()) -+ { -+ m_storage = string_printf ("%s/%ld", name, ptid.lwp ()); -+ m_section_name = m_storage.c_str (); -+ } -+ else -+ m_section_name = name; -+ } -+ -+ /* Return the computed section name. The result is valid as long as -+ this thread_section_name object is live. */ -+ const char *c_str () const -+ { return m_section_name; } -+ -+ /* Disable copy. */ -+ thread_section_name (const thread_section_name &) = delete; -+ void operator= (const thread_section_name &) = delete; -+ -+private: -+ /* Either a pointer into M_STORAGE, or a pointer to the name passed -+ as parameter to the constructor. */ -+ const char *m_section_name; -+ /* If we need to build a new section name, this is where we store -+ it. */ -+ std::string m_storage; -+}; -+ - /* Try to retrieve registers from a section in core_bfd, and supply - them to core_vec->core_read_registers, as the register set numbered - WHICH. -@@ -511,21 +556,15 @@ get_core_register_section (struct regcache *regcache, - const char *human_name, - int required) - { -- static char *section_name; - struct bfd_section *section; - bfd_size_type size; - char *contents; - bool variable_size_section = (regset != NULL - && regset->flags & REGSET_VARIABLE_SIZE); -- ptid_t ptid = regcache_get_ptid (regcache); - -- if (ptid_get_lwp (ptid)) -- section_name = xstrprintf ("%s/%ld", name, -- ptid_get_lwp (ptid)); -- else -- section_name = xstrdup (name); -+ thread_section_name section_name (name, regcache->ptid ()); - -- section = bfd_get_section_by_name (core_bfd, section_name); -+ section = bfd_get_section_by_name (core_bfd, section_name.c_str ()); - if (! section) - { - if (required) -@@ -537,13 +576,14 @@ get_core_register_section (struct regcache *regcache, - size = bfd_section_size (core_bfd, section); - if (size < min_size) - { -- warning (_("Section `%s' in core file too small."), section_name); -+ warning (_("Section `%s' in core file too small."), -+ section_name.c_str ()); - return; - } - if (size != min_size && !variable_size_section) - { - warning (_("Unexpected size of section `%s' in core file."), -- section_name); -+ section_name.c_str ()); - } - - contents = (char *) alloca (size); -@@ -551,7 +591,7 @@ get_core_register_section (struct regcache *regcache, - (file_ptr) 0, size)) - { - warning (_("Couldn't read %s registers from `%s' section in core file."), -- human_name, name); -+ human_name, section_name.c_str ()); - return; - } - -@@ -681,18 +721,8 @@ add_to_spuid_list (bfd *abfd, asection *asect, void *list_p) - static LONGEST - get_core_siginfo (bfd *abfd, gdb_byte *readbuf, ULONGEST offset, ULONGEST len) - { -- asection *section; -- char *section_name; -- const char *name = ".note.linuxcore.siginfo"; -- -- if (ptid_get_lwp (inferior_ptid)) -- section_name = xstrprintf ("%s/%ld", name, -- ptid_get_lwp (inferior_ptid)); -- else -- section_name = xstrdup (name); -- -- section = bfd_get_section_by_name (abfd, section_name); -- xfree (section_name); -+ thread_section_name section_name (".note.linuxcore.siginfo", inferior_ptid); -+ asection *section = bfd_get_section_by_name (abfd, section_name.c_str ()); - if (section == NULL) - return -1; - Property changes on: head/devel/gdb/files/commit-3c3ae77e68 ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/devel/gdb/files/commit-6e5eab33ab =================================================================== --- head/devel/gdb/files/commit-6e5eab33ab (revision 464492) +++ head/devel/gdb/files/commit-6e5eab33ab (nonexistent) @@ -1,120 +0,0 @@ -commit 6e5eab33abe09041b29e0ce484f684ad0ffe80a5 -Author: John Baldwin -Date: Wed Jun 28 10:41:57 2017 -0700 - - Move the thread_section_name class to gdbcore.h. - - This allows it to be used outside of corelow.c. - -diff --git gdb/corelow.c gdb/corelow.c -index 0aff02d4db..578c910bb5 100644 ---- gdb/corelow.c -+++ gdb/corelow.c -@@ -485,51 +485,6 @@ core_detach (struct target_ops *ops, const char *args, int from_tty) - printf_filtered (_("No core file now.\n")); - } - --/* Build either a single-thread or multi-threaded section name for -- PTID. -- -- If ptid's lwp member is zero, we want to do the single-threaded -- thing: look for a section named NAME (as passed to the -- constructor). If ptid's lwp member is non-zero, we'll want do the -- multi-threaded thing: look for a section named "NAME/LWP", where -- LWP is the shortest ASCII decimal representation of ptid's lwp -- member. */ -- --class thread_section_name --{ --public: -- /* NAME is the single-threaded section name. If PTID represents an -- LWP, then the build section name is "NAME/LWP", otherwise it's -- just "NAME" unmodified. */ -- thread_section_name (const char *name, ptid_t ptid) -- { -- if (ptid.lwp_p ()) -- { -- m_storage = string_printf ("%s/%ld", name, ptid.lwp ()); -- m_section_name = m_storage.c_str (); -- } -- else -- m_section_name = name; -- } -- -- /* Return the computed section name. The result is valid as long as -- this thread_section_name object is live. */ -- const char *c_str () const -- { return m_section_name; } -- -- /* Disable copy. */ -- thread_section_name (const thread_section_name &) = delete; -- void operator= (const thread_section_name &) = delete; -- --private: -- /* Either a pointer into M_STORAGE, or a pointer to the name passed -- as parameter to the constructor. */ -- const char *m_section_name; -- /* If we need to build a new section name, this is where we store -- it. */ -- std::string m_storage; --}; -- - /* Try to retrieve registers from a section in core_bfd, and supply - them to core_vec->core_read_registers, as the register set numbered - WHICH. -diff --git gdb/gdbcore.h gdb/gdbcore.h -index e3eed0395d..87f3dcd64d 100644 ---- gdb/gdbcore.h -+++ gdb/gdbcore.h -@@ -226,6 +226,51 @@ struct core_fns - - }; - -+/* Build either a single-thread or multi-threaded section name for -+ PTID. -+ -+ If ptid's lwp member is zero, we want to do the single-threaded -+ thing: look for a section named NAME (as passed to the -+ constructor). If ptid's lwp member is non-zero, we'll want do the -+ multi-threaded thing: look for a section named "NAME/LWP", where -+ LWP is the shortest ASCII decimal representation of ptid's lwp -+ member. */ -+ -+class thread_section_name -+{ -+public: -+ /* NAME is the single-threaded section name. If PTID represents an -+ LWP, then the build section name is "NAME/LWP", otherwise it's -+ just "NAME" unmodified. */ -+ thread_section_name (const char *name, ptid_t ptid) -+ { -+ if (ptid.lwp_p ()) -+ { -+ m_storage = string_printf ("%s/%ld", name, ptid.lwp ()); -+ m_section_name = m_storage.c_str (); -+ } -+ else -+ m_section_name = name; -+ } -+ -+ /* Return the computed section name. The result is valid as long as -+ this thread_section_name object is live. */ -+ const char *c_str () const -+ { return m_section_name; } -+ -+ /* Disable copy. */ -+ thread_section_name (const thread_section_name &) = delete; -+ void operator= (const thread_section_name &) = delete; -+ -+private: -+ /* Either a pointer into M_STORAGE, or a pointer to the name passed -+ as parameter to the constructor. */ -+ const char *m_section_name; -+ /* If we need to build a new section name, this is where we store -+ it. */ -+ std::string m_storage; -+}; -+ - /* NOTE: cagney/2004-04-05: Replaced by "regset.h" and - regset_from_core_section(). */ - extern void deprecated_add_core_fns (struct core_fns *cf); Property changes on: head/devel/gdb/files/commit-6e5eab33ab ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/devel/gdb/files/commit-12c4bd7f53 =================================================================== --- head/devel/gdb/files/commit-12c4bd7f53 (revision 464492) +++ head/devel/gdb/files/commit-12c4bd7f53 (nonexistent) @@ -1,45 +0,0 @@ -commit 12c4bd7f53e9cefcf7c3a7f8cbf9e552526cb963 -Author: John Baldwin -Date: Thu Oct 5 09:50:01 2017 -0700 - - Handle FreeBSD-specific AT_EHDRFLAGS and AT_HWCAP auxiliary vector types. - - FreeBSD recently added two additional ELF auxiliary vectors. FreeBSD's - AT_HWCAP uses a different number compared to AT_HWCAP on Linux as the - numerical value was already in use for a different vector on FreeBSD. - - include/ChangeLog: - - * elf/common.h (AT_FREEBSD_EHDRFLAGS, AT_FREEBSD_HWCAP): Define. - - gdb/ChangeLog: - - * fbsd-tdep.c (fbsd_print_auxv_entry): Handle AT_EHDRFLAGS and - AT_HWCAP. - -diff --git gdb/fbsd-tdep.c gdb/fbsd-tdep.c -index 727e28a645..fa4cd912ef 100644 ---- gdb/fbsd-tdep.c -+++ gdb/fbsd-tdep.c -@@ -392,6 +392,8 @@ fbsd_print_auxv_entry (struct gdbarch *gdbarch, struct ui_file *file, - TAG (PAGESIZESLEN, _("Number of pagesizes"), AUXV_FORMAT_DEC); - TAG (TIMEKEEP, _("Pointer to timehands"), AUXV_FORMAT_HEX); - TAG (STACKPROT, _("Initial stack protection"), AUXV_FORMAT_HEX); -+ TAG (EHDRFLAGS, _("ELF header e_flags"), AUXV_FORMAT_HEX); -+ TAG (HWCAP, _("Machine-dependent CPU capability hints"), AUXV_FORMAT_HEX); - default: - default_print_auxv_entry (gdbarch, file, type, val); - return; -diff --git include/elf/common.h include/elf/common.h -index d08731cca1..f89ab32889 100644 ---- include/elf/common.h -+++ include/elf/common.h -@@ -1144,6 +1144,8 @@ - #define AT_FREEBSD_PAGESIZESLEN 21 /* Number of pagesizes. */ - #define AT_FREEBSD_TIMEKEEP 22 /* Pointer to timehands. */ - #define AT_FREEBSD_STACKPROT 23 /* Initial stack protection. */ -+#define AT_FREEBSD_EHDRFLAGS 24 /* e_flags field from ELF header. */ -+#define AT_FREEBSD_HWCAP 25 /* CPU feature flags. */ - - #define AT_SUN_UID 2000 /* Effective user ID. */ - #define AT_SUN_RUID 2001 /* Real user ID. */ Property changes on: head/devel/gdb/files/commit-12c4bd7f53 ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/devel/gdb/files/commit-e6f3b9c319 =================================================================== --- head/devel/gdb/files/commit-e6f3b9c319 (revision 464492) +++ head/devel/gdb/files/commit-e6f3b9c319 (nonexistent) @@ -1,25 +0,0 @@ -commit e6f3b9c3194c0d89efffd6e5b59471950f979e5a -Author: John Baldwin -Date: Wed Jun 28 12:47:14 2017 -0700 - - Create pseudo sections for FreeBSD NT_PTLWPINFO core notes. - - bfd/ChangeLog: - - * elf.c (elfcore_grok_freebsd_note): Handle NT_FREEBSD_PTLWPINFO. - -diff --git bfd/elf.c bfd/elf.c -index 063a6e4bb3..dcb06383d9 100644 ---- bfd/elf.c -+++ bfd/elf.c -@@ -9980,6 +9980,10 @@ elfcore_grok_freebsd_note (bfd *abfd, Elf_Internal_Note *note) - else - return TRUE; - -+ case NT_FREEBSD_PTLWPINFO: -+ return elfcore_make_note_pseudosection (abfd, ".note.freebsdcore.lwpinfo", -+ note); -+ - default: - return TRUE; - } Property changes on: head/devel/gdb/files/commit-e6f3b9c319 ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/devel/gdb/files/commit-6d5be5d6b8 =================================================================== --- head/devel/gdb/files/commit-6d5be5d6b8 (revision 464492) +++ head/devel/gdb/files/commit-6d5be5d6b8 (nonexistent) @@ -1,24 +0,0 @@ -commit 6d5be5d6b8b4412e65bc037472aa2e727c25ccf5 -Author: John Baldwin -Date: Thu Oct 5 09:50:01 2017 -0700 - - Handle the NT_ARM_VFP core dump note on FreeBSD. - - bfd/ChangeLog: - - * elf.c (elfcore_grok_freebsd_note): Handle NT_ARM_VFP. - -diff --git bfd/elf.c bfd/elf.c -index fd7f773730..02deceaf4c 100644 ---- bfd/elf.c -+++ bfd/elf.c -@@ -10022,6 +10022,9 @@ elfcore_grok_freebsd_note (bfd *abfd, Elf_Internal_Note *note) - return elfcore_make_note_pseudosection (abfd, ".note.freebsdcore.lwpinfo", - note); - -+ case NT_ARM_VFP: -+ return elfcore_grok_arm_vfp (abfd, note); -+ - default: - return TRUE; - } Property changes on: head/devel/gdb/files/commit-6d5be5d6b8 ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/devel/gdb/files/commit-544c67cda1 =================================================================== --- head/devel/gdb/files/commit-544c67cda1 (revision 464492) +++ head/devel/gdb/files/commit-544c67cda1 (nonexistent) @@ -1,159 +0,0 @@ -commit 544c67cda1686c1b204cb96c0d7885b08d37b8d6 -Author: John Baldwin -Date: Fri Oct 6 11:41:45 2017 -0700 - - Account for padding in FreeBSD/mipsn32 NT_PRSTATUS notes. - - Add a new ELF backend method to grok FreeBSD NT_PRSTATUS core dump - notes. Define a method for MIPS N32 to override the default - elfcore_grok_freebsd_prstatus that accounts for additional padding - between pr_pid and pr_reg that is not present in other 32-bit FreeBSD - platforms. - - * elf-bfd.h (struct elf_backend_data): Add - `elf_backend_grok_freebsd_prstatus'. - * elf.c (elfcore_grok_freebsd_note): Call - `elf_backend_grok_freebsd_prstatus' to handle NT_PRSTATUS if - present. - * elfn32-mips.c (elf_n32_mips_grok_freebsd_prstatus): New - function. - (elf_backend_grok_freebsd_prstatus): Define. - * elfxx-target.h (elf_backend_grok_freebsd_prstatus): Define. - (elfNN_bed): Initialize `elf_backend_grok_freebsd_prstatus'. - -diff --git bfd/elf-bfd.h bfd/elf-bfd.h -index fd08748ae2..399e298a8d 100644 ---- bfd/elf-bfd.h -+++ bfd/elf-bfd.h -@@ -1270,6 +1270,11 @@ struct elf_backend_data - bfd_boolean (*elf_backend_grok_psinfo) - (bfd *, Elf_Internal_Note *); - -+ /* This function, if defined, is called when a "FreeBSD" NT_PRSTATUS -+ note is found in a core file. */ -+ bfd_boolean (*elf_backend_grok_freebsd_prstatus) -+ (bfd *, Elf_Internal_Note *); -+ - /* This function, if defined, is called to write a note to a corefile. */ - char *(*elf_backend_write_core_note) - (bfd *abfd, char *buf, int *bufsiz, int note_type, ...); -diff --git bfd/elf.c bfd/elf.c -index 02deceaf4c..c6de70d6b5 100644 ---- bfd/elf.c -+++ bfd/elf.c -@@ -9981,9 +9981,14 @@ elfcore_grok_freebsd_prstatus (bfd *abfd, Elf_Internal_Note *note) - static bfd_boolean - elfcore_grok_freebsd_note (bfd *abfd, Elf_Internal_Note *note) - { -+ const struct elf_backend_data *bed = get_elf_backend_data (abfd); -+ - switch (note->type) - { - case NT_PRSTATUS: -+ if (bed->elf_backend_grok_freebsd_prstatus) -+ if ((*bed->elf_backend_grok_freebsd_prstatus) (abfd, note)) -+ return TRUE; - return elfcore_grok_freebsd_prstatus (abfd, note); - - case NT_FPREGSET: -diff --git bfd/elfn32-mips.c bfd/elfn32-mips.c -index dce7ba1c7a..fdae18365e 100644 ---- bfd/elfn32-mips.c -+++ bfd/elfn32-mips.c -@@ -80,6 +80,8 @@ static bfd_boolean elf32_mips_grok_prstatus - (bfd *, Elf_Internal_Note *); - static bfd_boolean elf32_mips_grok_psinfo - (bfd *, Elf_Internal_Note *); -+static bfd_boolean elf_n32_mips_grok_freebsd_prstatus -+ (bfd *, Elf_Internal_Note *); - static irix_compat_t elf_n32_mips_irix_compat - (bfd *); - -@@ -3578,6 +3580,56 @@ elf32_mips_grok_psinfo (bfd *abfd, Elf_Internal_Note *note) - - return TRUE; - } -+ -+static bfd_boolean -+elf_n32_mips_grok_freebsd_prstatus (bfd *abfd, Elf_Internal_Note *note) -+{ -+ size_t offset; -+ size_t size; -+ size_t min_size; -+ -+ /* Compute offset of pr_getregsz, skipping over pr_statussz. -+ Also compute minimum size of this note. */ -+ offset = 4 + 4; -+ min_size = offset + 4 * 2 + 4 + 4 + 4; -+ -+ if (note->descsz < min_size) -+ return FALSE; -+ -+ /* Check for version 1 in pr_version. */ -+ if (bfd_h_get_32 (abfd, (bfd_byte *) note->descdata) != 1) -+ return FALSE; -+ -+ /* Extract size of pr_reg from pr_gregsetsz. */ -+ /* Skip over pr_gregsetsz and pr_fpregsetsz. */ -+ size = bfd_h_get_32 (abfd, (bfd_byte *) note->descdata + offset); -+ offset += 4 * 2; -+ -+ /* Skip over pr_osreldate. */ -+ offset += 4; -+ -+ /* Read signal from pr_cursig. */ -+ if (elf_tdata (abfd)->core->signal == 0) -+ elf_tdata (abfd)->core->signal -+ = bfd_h_get_32 (abfd, (bfd_byte *) note->descdata + offset); -+ offset += 4; -+ -+ /* Read TID from pr_pid. */ -+ elf_tdata (abfd)->core->lwpid -+ = bfd_h_get_32 (abfd, (bfd_byte *) note->descdata + offset); -+ offset += 4; -+ -+ /* Padding before pr_reg. */ -+ offset += 4; -+ -+ /* Make sure that there is enough data remaining in the note. */ -+ if (note->descsz - offset < size) -+ return FALSE; -+ -+ /* Make a ".reg/999" section and a ".reg" section. */ -+ return _bfd_elfcore_make_pseudosection (abfd, ".reg", -+ size, note->descpos + offset); -+} - - /* Depending on the target vector we generate some version of Irix - executables or "normal" MIPS ELF ABI executables. */ -@@ -3684,6 +3736,8 @@ static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap = { - _bfd_mips_elf_copy_indirect_symbol - #define elf_backend_grok_prstatus elf32_mips_grok_prstatus - #define elf_backend_grok_psinfo elf32_mips_grok_psinfo -+#define elf_backend_grok_freebsd_prstatus \ -+ elf_n32_mips_grok_freebsd_prstatus - #define elf_backend_ecoff_debug_swap &mips_elf32_ecoff_debug_swap - - #define elf_backend_got_header_size (4 * MIPS_RESERVED_GOTNO) -diff --git bfd/elfxx-target.h bfd/elfxx-target.h -index 551883fa09..6efca84e4e 100644 ---- bfd/elfxx-target.h -+++ bfd/elfxx-target.h -@@ -597,6 +597,9 @@ - #ifndef elf_backend_grok_psinfo - #define elf_backend_grok_psinfo NULL - #endif -+#ifndef elf_backend_grok_freebsd_prstatus -+#define elf_backend_grok_freebsd_prstatus NULL -+#endif - #ifndef elf_backend_write_core_note - #define elf_backend_write_core_note NULL - #endif -@@ -820,6 +823,7 @@ static struct elf_backend_data elfNN_bed = - elf_backend_sort_relocs_p, - elf_backend_grok_prstatus, - elf_backend_grok_psinfo, -+ elf_backend_grok_freebsd_prstatus, - elf_backend_write_core_note, - elf_backend_lookup_section_flags_hook, - elf_backend_reloc_type_class, Property changes on: head/devel/gdb/files/commit-544c67cda1 ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/devel/gdb/files/patch-nowarning =================================================================== --- head/devel/gdb/files/patch-nowarning (revision 464492) +++ head/devel/gdb/files/patch-nowarning (nonexistent) @@ -1,65 +0,0 @@ ---- gdb/arm-tdep.c.orig 2016-07-08 15:42:17 UTC -+++ gdb/arm-tdep.c -@@ -9880,7 +9880,7 @@ - && !INSN_RECORDED(arm_insn_r)) - { - /* Handle MLA(S) and MUL(S). */ -- if (0 <= insn_op1 && 3 >= insn_op1) -+ if (3 >= insn_op1) - { - record_buf[0] = bits (arm_insn_r->arm_insn, 12, 15); - record_buf[1] = ARM_PS_REGNUM; ---- gdb/cris-tdep.c.orig 2016-07-08 15:45:26.575379589 +0200 -+++ gdb/cris-tdep.c 2016-07-08 15:47:07.849372792 +0200 -@@ -1441,7 +1441,7 @@ - /* Indeterminate/obsolete. */ - return 0; - case cris_ver_v0_3: -- return (version >= 0 && version <= 3); -+ return (version <= 3); - case cris_ver_v3p: - return (version >= 3); - case cris_ver_v8: -@@ -1449,7 +1449,7 @@ - case cris_ver_v8p: - return (version >= 8); - case cris_ver_v0_10: -- return (version >= 0 && version <= 10); -+ return (version <= 10); - case cris_ver_v3_10: - return (version >= 3 && version <= 10); - case cris_ver_v8_10: ---- gdb/main.c.orig 2016-08-03 17:55:42.243017327 +0200 -+++ gdb/main.c 2016-08-03 17:56:04.478015630 +0200 -@@ -226,7 +226,7 @@ - { - /* Append the part of SYSTEM_GDBINIT that follows GDB_DATADIR - to gdb_datadir. */ -- char *tmp_sys_gdbinit = xstrdup (SYSTEM_GDBINIT + datadir_len); -+ char *tmp_sys_gdbinit = xstrdup (&(SYSTEM_GDBINIT[datadir_len])); - char *p; - - for (p = tmp_sys_gdbinit; IS_DIR_SEPARATOR (*p); ++p) ---- gdb/dtrace-probe.c.orig 2016-08-03 17:57:18.454010903 +0200 -+++ gdb/dtrace-probe.c 2016-08-03 17:58:01.001007519 +0200 -@@ -421,7 +421,8 @@ - arg.type_str = xstrdup (p); - - /* Use strtab_size as a sentinel. */ -- while (*p++ != '\0' && p - strtab < strtab_size); -+ while (*p++ != '\0' && p - strtab < strtab_size) -+ ; - - /* Try to parse a type expression from the type string. If - this does not work then we set the type to `long ---- libiberty/stack-limit.c.orig 2016-08-05 14:12:21.942893014 +0200 -+++ libiberty/stack-limit.c 2016-08-05 14:12:58.794890125 +0200 -@@ -51,7 +51,7 @@ - struct rlimit rlim; - if (getrlimit (RLIMIT_STACK, &rlim) == 0 - && rlim.rlim_cur != RLIM_INFINITY -- && rlim.rlim_cur < pref -+ && rlim.rlim_cur < (rlim_t)pref - && (rlim.rlim_max == RLIM_INFINITY || rlim.rlim_cur < rlim.rlim_max)) - { - rlim.rlim_cur = pref; Property changes on: head/devel/gdb/files/patch-nowarning ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/devel/gdb/files/commit-b5430a3ced =================================================================== --- head/devel/gdb/files/commit-b5430a3ced (revision 464492) +++ head/devel/gdb/files/commit-b5430a3ced (nonexistent) @@ -1,117 +0,0 @@ -commit b5430a3ced5fe5ba484bd9b3215b9ae19ced0160 -Author: John Baldwin -Date: Thu Jun 1 09:40:46 2017 -0700 - - Use the ELF class to determine the word size for FreeBSD core notes. - - FreeBSD ELF cores contain data structures with that have two different - layouts: one for ILP32 platforms and a second for LP64 platforms. - Previously, the code used 'bits_per_word' from 'arch_info', but this - field is not a reliable indicator of the format for FreeBSD MIPS cores - in particular. - - I had originally posted this patch back in November because process - cores for FreeBSD MIPS contained an e_flags value of 0 in the header - which resulted in a bfd_arch which always had 'bits_per_word' set to - 32. This permitted reading o32 cores, but not n64 cores. The feedback - I received then was to try to change n64 cores to use a different - default bfd_arch that had a 64-bit 'bits_per_word' when e_flags was zero. - I submitted a patch to that effect but it was never approved. Instead, - I changed FreeBSD's kernel and gcore commands to preserve the e_flags - field from an executable when generating process cores. With a proper - e_flags field in process cores, n64 cores now use a 64-bit bfd_arch and - now work fine. However, the change to include e_flags in the process - cores had the unintended side effect of breaking handling of o32 - process cores. Specifically, FreeBSD MIPS builds o32 with a default - MIPS architecture of 'mips3', thus FreeBSD process cores with a non-zero - e_flags match the 'mips3' bfd_arch which has 64 'bits_per_word'. - - From this, it seems that 'bits_per_word' for FreeBSD MIPS is not likely - to ever be completely correct. However, FreeBSD core dumps do - reliably set the ELF class to ELFCLASS32 for cores using ILP32 and - ELFCLASS64 for cores using LP64. As such, I think my original patch of - using the ELF class instead of 'bits_per_word' is probably the simplest - and most reliable approach for detecting the note structure layout. - - bfd/ChangeLog: - - * elf.c (elfcore_grok_freebsd_psinfo): Use ELF header class to - determine structure sizes. - (elfcore_grok_freebsd_prstatus): Likewise. - -diff --git bfd/elf.c bfd/elf.c -index 863bd61c5f..34d39c547b 100644 ---- bfd/elf.c -+++ bfd/elf.c -@@ -9814,14 +9814,14 @@ elfcore_grok_freebsd_psinfo (bfd *abfd, Elf_Internal_Note *note) - { - size_t offset; - -- switch (abfd->arch_info->bits_per_word) -+ switch (elf_elfheader (abfd)->e_ident[EI_CLASS]) - { -- case 32: -+ case ELFCLASS32: - if (note->descsz < 108) - return FALSE; - break; - -- case 64: -+ case ELFCLASS64: - if (note->descsz < 120) - return FALSE; - break; -@@ -9836,7 +9836,7 @@ elfcore_grok_freebsd_psinfo (bfd *abfd, Elf_Internal_Note *note) - offset = 4; - - /* Skip over pr_psinfosz. */ -- if (abfd->arch_info->bits_per_word == 32) -+ if (elf_elfheader (abfd)->e_ident[EI_CLASS] == ELFCLASS32) - offset += 4; - else - { -@@ -9879,13 +9879,13 @@ elfcore_grok_freebsd_prstatus (bfd *abfd, Elf_Internal_Note *note) - offset = 4; - - /* Skip over pr_statussz. */ -- switch (abfd->arch_info->bits_per_word) -+ switch (elf_elfheader (abfd)->e_ident[EI_CLASS]) - { -- case 32: -+ case ELFCLASS32: - offset += 4; - break; - -- case 64: -+ case ELFCLASS64: - offset += 4; /* Padding before pr_statussz. */ - offset += 8; - break; -@@ -9895,13 +9895,16 @@ elfcore_grok_freebsd_prstatus (bfd *abfd, Elf_Internal_Note *note) - } - - /* Extract size of pr_reg from pr_gregsetsz. */ -- if (abfd->arch_info->bits_per_word == 32) -+ if (elf_elfheader (abfd)->e_ident[EI_CLASS] == ELFCLASS32) - size = bfd_h_get_32 (abfd, (bfd_byte *) note->descdata + offset); - else - size = bfd_h_get_64 (abfd, (bfd_byte *) note->descdata + offset); - - /* Skip over pr_gregsetsz and pr_fpregsetsz. */ -- offset += (abfd->arch_info->bits_per_word / 8) * 2; -+ if (elf_elfheader (abfd)->e_ident[EI_CLASS] == ELFCLASS32) -+ offset += 4 * 2; -+ else -+ offset += 8 * 2; - - /* Skip over pr_osreldate. */ - offset += 4; -@@ -9918,7 +9921,7 @@ elfcore_grok_freebsd_prstatus (bfd *abfd, Elf_Internal_Note *note) - offset += 4; - - /* Padding before pr_reg. */ -- if (abfd->arch_info->bits_per_word == 64) -+ if (elf_elfheader (abfd)->e_ident[EI_CLASS] == ELFCLASS64) - offset += 4; - - /* Make a ".reg/999" section and a ".reg" section. */ Property changes on: head/devel/gdb/files/commit-b5430a3ced ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/devel/gdb/files/commit-762c974a09 =================================================================== --- head/devel/gdb/files/commit-762c974a09 (revision 464492) +++ head/devel/gdb/files/commit-762c974a09 (nonexistent) @@ -1,167 +0,0 @@ -commit 762c974a09746bda8a5d64ed3ee887adeae742b9 -Author: John Baldwin -Date: Wed Jun 28 08:14:06 2017 -0700 - - Implement the "get_siginfo_type" gdbarch method for FreeBSD architectures. - - As with Linux architectures, cache the created type in the gdbarch when it - is first created. Currently FreeBSD uses an identical siginfo type on - all architectures, so there is no support for architecture-specific fields. - - gdb/ChangeLog: - - * fbsd-tdep.c (fbsd_gdbarch_data_handle, struct fbsd_gdbarch_data) - (init_fbsd_gdbarch_data, get_fbsd_gdbarch_data) - (fbsd_get_siginfo_type): New. - (fbsd_init_abi): Install gdbarch "get_siginfo_type" method. - (_initialize_fbsd_tdep): New. - -diff --git gdb/fbsd-tdep.c gdb/fbsd-tdep.c -index b834ce38b4..24a3c20dd6 100644 ---- gdb/fbsd-tdep.c -+++ gdb/fbsd-tdep.c -@@ -30,6 +30,26 @@ - #include "fbsd-tdep.h" - - -+static struct gdbarch_data *fbsd_gdbarch_data_handle; -+ -+struct fbsd_gdbarch_data -+ { -+ struct type *siginfo_type; -+ }; -+ -+static void * -+init_fbsd_gdbarch_data (struct gdbarch *gdbarch) -+{ -+ return GDBARCH_OBSTACK_ZALLOC (gdbarch, struct fbsd_gdbarch_data); -+} -+ -+static struct fbsd_gdbarch_data * -+get_fbsd_gdbarch_data (struct gdbarch *gdbarch) -+{ -+ return ((struct fbsd_gdbarch_data *) -+ gdbarch_data (gdbarch, fbsd_gdbarch_data_handle)); -+} -+ - /* This is how we want PTIDs from core files to be printed. */ - - static const char * -@@ -314,6 +334,97 @@ fbsd_print_auxv_entry (struct gdbarch *gdbarch, struct ui_file *file, - fprint_auxv_entry (file, name, description, format, type, val); - } - -+/* Implement the "get_siginfo_type" gdbarch method. */ -+ -+static struct type * -+fbsd_get_siginfo_type (struct gdbarch *gdbarch) -+{ -+ struct fbsd_gdbarch_data *fbsd_gdbarch_data; -+ struct type *int_type, *int32_type, *uint32_type, *long_type, *void_ptr_type; -+ struct type *uid_type, *pid_type; -+ struct type *sigval_type, *reason_type; -+ struct type *siginfo_type; -+ struct type *type; -+ -+ fbsd_gdbarch_data = get_fbsd_gdbarch_data (gdbarch); -+ if (fbsd_gdbarch_data->siginfo_type != NULL) -+ return fbsd_gdbarch_data->siginfo_type; -+ -+ int_type = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch), -+ 0, "int"); -+ int32_type = arch_integer_type (gdbarch, 32, 0, "int32_t"); -+ uint32_type = arch_integer_type (gdbarch, 32, 1, "uint32_t"); -+ long_type = arch_integer_type (gdbarch, gdbarch_long_bit (gdbarch), -+ 0, "long"); -+ void_ptr_type = lookup_pointer_type (builtin_type (gdbarch)->builtin_void); -+ -+ /* union sigval */ -+ sigval_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_UNION); -+ TYPE_NAME (sigval_type) = xstrdup ("sigval"); -+ append_composite_type_field (sigval_type, "sival_int", int_type); -+ append_composite_type_field (sigval_type, "sival_ptr", void_ptr_type); -+ -+ /* __pid_t */ -+ pid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF, -+ TYPE_LENGTH (int32_type), "__pid_t"); -+ TYPE_TARGET_TYPE (pid_type) = int32_type; -+ TYPE_TARGET_STUB (pid_type) = 1; -+ -+ /* __uid_t */ -+ uid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF, -+ TYPE_LENGTH (uint32_type), "__uid_t"); -+ TYPE_TARGET_TYPE (uid_type) = uint32_type; -+ TYPE_TARGET_STUB (uid_type) = 1; -+ -+ /* _reason */ -+ reason_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_UNION); -+ -+ /* _fault */ -+ type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT); -+ append_composite_type_field (type, "si_trapno", int_type); -+ append_composite_type_field (reason_type, "_fault", type); -+ -+ /* _timer */ -+ type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT); -+ append_composite_type_field (type, "si_timerid", int_type); -+ append_composite_type_field (type, "si_overrun", int_type); -+ append_composite_type_field (reason_type, "_timer", type); -+ -+ /* _mesgq */ -+ type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT); -+ append_composite_type_field (type, "si_mqd", int_type); -+ append_composite_type_field (reason_type, "_mesgq", type); -+ -+ /* _poll */ -+ type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT); -+ append_composite_type_field (type, "si_band", long_type); -+ append_composite_type_field (reason_type, "_poll", type); -+ -+ /* __spare__ */ -+ type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT); -+ append_composite_type_field (type, "__spare1__", long_type); -+ append_composite_type_field (type, "__spare2__", -+ init_vector_type (int_type, 7)); -+ append_composite_type_field (reason_type, "__spare__", type); -+ -+ /* struct siginfo */ -+ siginfo_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT); -+ TYPE_NAME (siginfo_type) = xstrdup ("siginfo"); -+ append_composite_type_field (siginfo_type, "si_signo", int_type); -+ append_composite_type_field (siginfo_type, "si_errno", int_type); -+ append_composite_type_field (siginfo_type, "si_code", int_type); -+ append_composite_type_field (siginfo_type, "si_pid", pid_type); -+ append_composite_type_field (siginfo_type, "si_uid", uid_type); -+ append_composite_type_field (siginfo_type, "si_status", int_type); -+ append_composite_type_field (siginfo_type, "si_addr", void_ptr_type); -+ append_composite_type_field (siginfo_type, "si_value", sigval_type); -+ append_composite_type_field (siginfo_type, "_reason", reason_type); -+ -+ fbsd_gdbarch_data->siginfo_type = siginfo_type; -+ -+ return siginfo_type; -+} -+ - /* Implement the "get_syscall_number" gdbarch method. */ - - static LONGEST -@@ -339,8 +450,19 @@ fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) - set_gdbarch_core_thread_name (gdbarch, fbsd_core_thread_name); - set_gdbarch_make_corefile_notes (gdbarch, fbsd_make_corefile_notes); - set_gdbarch_print_auxv_entry (gdbarch, fbsd_print_auxv_entry); -+ set_gdbarch_get_siginfo_type (gdbarch, fbsd_get_siginfo_type); - - /* `catch syscall' */ - set_xml_syscall_file_name (gdbarch, "syscalls/freebsd.xml"); - set_gdbarch_get_syscall_number (gdbarch, fbsd_get_syscall_number); - } -+ -+/* Provide a prototype to silence -Wmissing-prototypes. */ -+extern initialize_file_ftype _initialize_fbsd_tdep; -+ -+void -+_initialize_fbsd_tdep (void) -+{ -+ fbsd_gdbarch_data_handle = -+ gdbarch_data_register_post_init (init_fbsd_gdbarch_data); -+} Property changes on: head/devel/gdb/files/commit-762c974a09 ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/devel/gdb/files/commit-45eba0ab7d =================================================================== --- head/devel/gdb/files/commit-45eba0ab7d (revision 464492) +++ head/devel/gdb/files/commit-45eba0ab7d (nonexistent) @@ -1,45 +0,0 @@ -commit 45eba0ab7d26435121facb68847fbd0cd4a313c1 -Author: Andreas Arnez -Date: Thu May 4 11:06:10 2017 +0200 - - Remove some superfluous code in corelow.c - - In corelow.c I stumbled upon an extra semicolon and an xfree of a NULL - pointer. Remove them. - - gdb/ChangeLog: - - * corelow.c (sniff_core_bfd): Remove extra semicolon. - (get_core_register_section): Remove xfree of NULL pointer. - -diff --git gdb/corelow.c gdb/corelow.c -index 3267c37843..2266f2467a 100644 ---- gdb/corelow.c -+++ gdb/corelow.c -@@ -129,7 +129,7 @@ sniff_core_bfd (bfd *abfd) - { - struct core_fns *cf; - struct core_fns *yummy = NULL; -- int matches = 0;; -+ int matches = 0; - - /* Don't sniff if we have support for register sets in - CORE_GDBARCH. */ -@@ -511,7 +511,7 @@ get_core_register_section (struct regcache *regcache, - const char *human_name, - int required) - { -- static char *section_name = NULL; -+ static char *section_name; - struct bfd_section *section; - bfd_size_type size; - char *contents; -@@ -519,8 +519,6 @@ get_core_register_section (struct regcache *regcache, - && regset->flags & REGSET_VARIABLE_SIZE); - ptid_t ptid = regcache_get_ptid (regcache); - -- xfree (section_name); -- - if (ptid_get_lwp (ptid)) - section_name = xstrprintf ("%s/%ld", name, - ptid_get_lwp (ptid)); Property changes on: head/devel/gdb/files/commit-45eba0ab7d ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/devel/gdb/files/commit-b30ff123fb =================================================================== --- head/devel/gdb/files/commit-b30ff123fb (revision 464492) +++ head/devel/gdb/files/commit-b30ff123fb (nonexistent) @@ -1,40 +0,0 @@ -commit b30ff123fbff63d6c8be1115320efd0158e49a7f -Author: Yao Qi -Date: Thu Jun 22 13:41:27 2017 +0100 - - Regenerate two regformats/i386/.dat files - - The self tests which compare pre-generated target descriptions and - dynamically created target descriptions fail, and it turns out that two - pre-generated target descriptions are wrong, so regenerate them. - - gdb: - - 2017-06-22 Yao Qi - - * regformats/i386/amd64-avx-mpx-avx512-pku-linux.dat: Regenerated. - * regformats/i386/amd64-avx-mpx-avx512-pku.dat: Regenerated. - -diff --git gdb/regformats/i386/amd64-avx-mpx-avx512-pku-linux.dat gdb/regformats/i386/amd64-avx-mpx-avx512-pku-linux.dat -index 3ae6b0e472..9cd0fae820 100644 ---- gdb/regformats/i386/amd64-avx-mpx-avx512-pku-linux.dat -+++ gdb/regformats/i386/amd64-avx-mpx-avx512-pku-linux.dat -@@ -157,3 +157,4 @@ expedite:rbp,rsp,rip - 256:zmm29h - 256:zmm30h - 256:zmm31h -+32:pkru -diff --git gdb/regformats/i386/amd64-avx-mpx-avx512-pku.dat gdb/regformats/i386/amd64-avx-mpx-avx512-pku.dat -index 88185fd8c3..b3340d3276 100644 ---- gdb/regformats/i386/amd64-avx-mpx-avx512-pku.dat -+++ gdb/regformats/i386/amd64-avx-mpx-avx512-pku.dat -@@ -60,9 +60,6 @@ expedite:rbp,rsp,rip - 128:xmm14 - 128:xmm15 - 32:mxcsr --64:orig_rax --64:fs_base --64:gs_base - 128:ymm0h - 128:ymm1h - 128:ymm2h Property changes on: head/devel/gdb/files/commit-b30ff123fb ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/devel/gdb/files/commit-0b9305edf1 =================================================================== --- head/devel/gdb/files/commit-0b9305edf1 (revision 464492) +++ head/devel/gdb/files/commit-0b9305edf1 (nonexistent) @@ -1,30 +0,0 @@ -commit 0b9305edf1d0b15913643b132dad02d4ca4fbb43 -Author: John Baldwin -Date: Wed Jun 28 11:41:41 2017 -0700 - - Recognize the recently-added FreeBSD core dump note for LWP info. - - This core dump note contains the same information returned by the - ptrace PT_LWPINFO operation for each LWP belonging to a process. - - binutils/ChangeLog: - - * readelf.c (get_freebsd_elfcore_note_type): Handle - NT_FREEBSD_PTLWPINFO. - - include/ChangeLog: - - * elf/common.h (NT_FREEBSD_PTLWPINFO): Define. - -diff --git include/elf/common.h include/elf/common.h -index 2976c06067..3a144f03bc 100644 ---- include/elf/common.h -+++ include/elf/common.h -@@ -641,6 +641,7 @@ - #define NT_FREEBSD_PROCSTAT_OSREL 14 /* Procstat osreldate data. */ - #define NT_FREEBSD_PROCSTAT_PSSTRINGS 15 /* Procstat ps_strings data. */ - #define NT_FREEBSD_PROCSTAT_AUXV 16 /* Procstat auxv data. */ -+#define NT_FREEBSD_PTLWPINFO 17 /* Thread ptrace miscellaneous info. */ - - /* Note segments for core files on NetBSD systems. Note name - must start with "NetBSD-CORE". */ Property changes on: head/devel/gdb/files/commit-0b9305edf1 ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/devel/gdb/files/commit-0335ac6d12 =================================================================== --- head/devel/gdb/files/commit-0335ac6d12 (revision 464492) +++ head/devel/gdb/files/commit-0335ac6d12 (nonexistent) @@ -1,24 +0,0 @@ -commit 0335ac6d12906bfb4b48410d8a7229c21c727cf2 -Author: John Baldwin -Date: Tue Aug 15 08:04:23 2017 -0700 - - Fix compile on big-endian platforms in siginfo_t converter. - - gdb/ChangeLog: - - * fbsd-nat.c (fbsd_convert_siginfo): Fix compile on big-endian - platforms. - -diff --git gdb/fbsd-nat.c gdb/fbsd-nat.c -index c89343a24f..6ba6a01a70 100644 ---- gdb/fbsd-nat.c -+++ gdb/fbsd-nat.c -@@ -314,7 +314,7 @@ fbsd_convert_siginfo (siginfo_t *si) - 32-bits of the pointer value. */ - #if _BYTE_ORDER == _BIG_ENDIAN - if (si->si_value.sival_int == 0) -- si32->si_value.sival_ptr = (uintptr_t) si->si_value.sival_ptr; -+ si32.si_value.sival_ptr = (uintptr_t) si->si_value.sival_ptr; - else - si32.si_value.sival_int = si->si_value.sival_int; - #else Property changes on: head/devel/gdb/files/commit-0335ac6d12 ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/devel/gdb/files/commit-0aa37b654c =================================================================== --- head/devel/gdb/files/commit-0aa37b654c (revision 464492) +++ head/devel/gdb/files/commit-0aa37b654c (nonexistent) @@ -1,90 +0,0 @@ -commit 0aa37b654c0f31e446ab47826f0bcbec15d0112f -Author: John Baldwin -Date: Mon Jun 26 18:18:19 2017 -0700 - - Support the fs_base and gs_base registers on FreeBSD/amd64 native processes. - - Use ptrace operations to fetch and store the fs_base and gs_base registers - for FreeBSD/amd64 processes. Note that FreeBSD does not currently store the - value of these registers in core dumps, so these registers are only - available when inspecting a running process. - - gdb/ChangeLog: - - * amd64-bsd-nat.c (amd64bsd_fetch_inferior_registers): Use - PT_GETFSBASE and PT_GETGSBASE. - (amd64bsd_store_inferior_registers): Use PT_SETFSBASE and - PT_SETGSBASE. - -diff --git gdb/amd64-bsd-nat.c gdb/amd64-bsd-nat.c -index ca61a3551b..41dee84269 100644 ---- gdb/amd64-bsd-nat.c -+++ gdb/amd64-bsd-nat.c -@@ -57,6 +57,33 @@ amd64bsd_fetch_inferior_registers (struct target_ops *ops, - return; - } - -+#ifdef PT_GETFSBASE -+ if (regnum == -1 || regnum == AMD64_FSBASE_REGNUM) -+ { -+ register_t base; -+ -+ if (ptrace (PT_GETFSBASE, pid, (PTRACE_TYPE_ARG3) &base, 0) == -1) -+ perror_with_name (_("Couldn't get segment register fs_base")); -+ -+ regcache_raw_supply (regcache, AMD64_FSBASE_REGNUM, &base); -+ if (regnum != -1) -+ return; -+ } -+#endif -+#ifdef PT_GETGSBASE -+ if (regnum == -1 || regnum == AMD64_GSBASE_REGNUM) -+ { -+ register_t base; -+ -+ if (ptrace (PT_GETGSBASE, pid, (PTRACE_TYPE_ARG3) &base, 0) == -1) -+ perror_with_name (_("Couldn't get segment register gs_base")); -+ -+ regcache_raw_supply (regcache, AMD64_GSBASE_REGNUM, &base); -+ if (regnum != -1) -+ return; -+ } -+#endif -+ - if (regnum == -1 || !amd64_native_gregset_supplies_p (gdbarch, regnum)) - { - struct fpreg fpregs; -@@ -108,6 +135,33 @@ amd64bsd_store_inferior_registers (struct target_ops *ops, - return; - } - -+#ifdef PT_SETFSBASE -+ if (regnum == -1 || regnum == AMD64_FSBASE_REGNUM) -+ { -+ register_t base; -+ -+ regcache_raw_collect (regcache, AMD64_FSBASE_REGNUM, &base); -+ -+ if (ptrace (PT_SETFSBASE, pid, (PTRACE_TYPE_ARG3) &base, 0) == -1) -+ perror_with_name (_("Couldn't write segment register fs_base")); -+ if (regnum != -1) -+ return; -+ } -+#endif -+#ifdef PT_SETGSBASE -+ if (regnum == -1 || regnum == AMD64_GSBASE_REGNUM) -+ { -+ register_t base; -+ -+ regcache_raw_collect (regcache, AMD64_GSBASE_REGNUM, &base); -+ -+ if (ptrace (PT_SETGSBASE, pid, (PTRACE_TYPE_ARG3) &base, 0) == -1) -+ perror_with_name (_("Couldn't write segment register gs_base")); -+ if (regnum != -1) -+ return; -+ } -+#endif -+ - if (regnum == -1 || !amd64_native_gregset_supplies_p (gdbarch, regnum)) - { - struct fpreg fpregs; Property changes on: head/devel/gdb/files/commit-0aa37b654c ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/devel/gdb/files/commit-48aeef91c2 =================================================================== --- head/devel/gdb/files/commit-48aeef91c2 (revision 464492) +++ head/devel/gdb/files/commit-48aeef91c2 (nonexistent) @@ -1,805 +0,0 @@ -commit 48aeef91c248291dd03583798904612426b1f40a -Author: John Baldwin -Date: Mon Jun 26 18:14:43 2017 -0700 - - Include the fs_base and gs_base registers in amd64 target descriptions. - - This permits these registers to be used with non-Linux targets. - - gdb/ChangeLog: - - * features/Makefile (amd64.dat, amd64-avx.dat, amd64-mpx.dat) - (amd64-avx-mpx.dat, amd64-avx-avx512.dat) - (amd64-avx-mpx-avx512-pku.dat): Add i386/64bit-segments.xml in - those rules. - * features/i386/amd64-avx-avx512.xml: Add 64bit-segments.xml. - * features/i386/amd64-avx-mpx-avx512-pku.xml: Add 64bit-segments.xml. - * features/i386/amd64-avx-mpx.xml: Add 64bit-segments.xml. - * features/i386/amd64-avx.xml: Add 64bit-segments.xml. - * features/i386/amd64-mpx.xml: Add 64bit-segments.xml. - * features/i386/amd64.xml: Add 64bit-segments.xml. - * features/i386/amd64-avx-avx512.c: Regenerated. - * features/i386/amd64-avx-mpx-avx512-pku.c: Regenerated. - * features/i386/amd64-avx-mpx.c: Regenerated. - * features/i386/amd64-avx.c: Regenerated. - * features/i386/amd64-mpx.c: Regenerated. - * features/i386/amd64.c: Regenerated. - * regformats/i386/amd64-avx-avx512.dat: Regenerated. - * regformats/i386/amd64-avx-mpx-avx512-pku.dat: Regenerated. - * regformats/i386/amd64-avx-mpx.dat: Regenerated. - * regformats/i386/amd64-avx.dat: Regenerated. - * regformats/i386/amd64-mpx.dat: Regenerated. - * regformats/i386/amd64.dat: Regenerated. - -diff --git gdb/features/Makefile gdb/features/Makefile -index 3bc8b5ae85..75741acbe1 100644 ---- gdb/features/Makefile -+++ gdb/features/Makefile -@@ -263,7 +263,8 @@ $(outdir)/arm/arm-with-iwmmxt.dat: arm/arm-core.xml arm/xscale-iwmmxt.xml - $(outdir)/i386/i386.dat: i386/32bit-core.xml i386/32bit-sse.xml - $(outdir)/i386/i386-linux.dat: i386/32bit-core.xml i386/32bit-sse.xml \ - i386/32bit-linux.xml --$(outdir)/i386/amd64.dat: i386/64bit-core.xml i386/64bit-sse.xml -+$(outdir)/i386/amd64.dat: i386/64bit-core.xml i386/64bit-sse.xml \ -+ i386/64bit-segments.xml - $(outdir)/i386/amd64-linux.dat: i386/64bit-core.xml i386/64bit-sse.xml \ - i386/64bit-linux.xml i386/64bit-segments.xml - $(outdir)/i386/i386-avx.dat: i386/32bit-core.xml i386/32bit-avx.xml -@@ -289,7 +290,8 @@ $(outdir)/i386/i386-avx-mpx-avx512-pku-linux.dat: i386/32bit-core.xml \ - i386/32bit-pkeys.xml i386/32bit-linux.xml - $(outdir)/i386/i386-mmx.dat: i386/32bit-core.xml - $(outdir)/i386/i386-mmx-linux.dat: i386/32bit-core.xml i386/32bit-linux.xml --$(outdir)/i386/amd64-avx.dat: i386/64bit-core.xml i386/64bit-avx.xml -+$(outdir)/i386/amd64-avx.dat: i386/64bit-core.xml i386/64bit-avx.xml \ -+ i386/64bit-segments.xml - $(outdir)/i386/amd64-avx-linux.dat: i386/64bit-core.xml i386/64bit-avx.xml \ - i386/64bit-linux.xml i386/64bit-segments.xml - $(outdir)/i386/amd64-mpx-linux.dat: i386/64bit-core.xml i386/64bit-avx.xml \ -@@ -297,16 +299,16 @@ $(outdir)/i386/amd64-mpx-linux.dat: i386/64bit-core.xml i386/64bit-avx.xml \ - $(outdir)/i386/amd64-avx-mpx-linux.dat: i386/64bit-core.xml \ - i386/64bit-linux.xml i386/64bit-segments.xml i386/64bit-mpx.xml - $(outdir)/i386/amd64-mpx.dat: i386/64bit-core.xml i386/64bit-avx.xml \ -- i386/64bit-mpx.xml -+ i386/64bit-segments.xml i386/64bit-mpx.xml - $(outdir)/i386/amd64-avx-mpx.dat: i386/64bit-core.xml \ -- i386/64bit-mpx.xml -+ i386/64bit-segments.xml i386/64bit-mpx.xml - $(outdir)/i386/amd64-avx-avx512.dat: i386/64bit-core.xml i386/64bit-avx.xml \ -- i386/64bit-avx512.xml -+ i386/64bit-avx512.xml i386/64bit-segments.xml - $(outdir)/i386/amd64-avx-avx512-linux.dat: i386/64bit-core.xml i386/64bit-avx.xml \ - i386/64bit-avx512.xml i386/64bit-linux.xml - $(outdir)/i386/amd64-avx-mpx-avx512-pku.dat: i386/64bit-core.xml \ - i386/64bit-avx.xml i386/64bit-mpx.xml i386/64bit-avx512.xml \ -- i386/64bit-pkeys.xml -+ i386/64bit-pkeys.xml i386/64bit-segments.xml - $(outdir)/i386/amd64-avx-mpx-avx512-pku-linux.dat: i386/64bit-core.xml \ - i386/64bit-avx.xml i386/64bit-mpx.xml i386/64bit-avx512.xml \ - i386/64bit-linux.xml i386/64bit-segments.xml \ -diff --git gdb/features/i386/amd64-avx-avx512.c gdb/features/i386/amd64-avx-avx512.c -index 8a185c108d..f1ebde1071 100644 ---- gdb/features/i386/amd64-avx-avx512.c -+++ gdb/features/i386/amd64-avx-avx512.c -@@ -146,23 +146,27 @@ initialize_tdesc_amd64_avx_avx512 (void) - tdesc_create_reg (feature, "xmm15", 55, 1, NULL, 128, "vec128"); - tdesc_create_reg (feature, "mxcsr", 56, 1, "vector", 32, "i386_mxcsr"); - -+ feature = tdesc_create_feature (result, "org.gnu.gdb.i386.segments"); -+ tdesc_create_reg (feature, "fs_base", 57, 1, NULL, 64, "int"); -+ tdesc_create_reg (feature, "gs_base", 58, 1, NULL, 64, "int"); -+ - feature = tdesc_create_feature (result, "org.gnu.gdb.i386.avx"); -- tdesc_create_reg (feature, "ymm0h", 57, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm1h", 58, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm2h", 59, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm3h", 60, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm4h", 61, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm5h", 62, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm6h", 63, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm7h", 64, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm8h", 65, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm9h", 66, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm10h", 67, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm11h", 68, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm12h", 69, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm13h", 70, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm14h", 71, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm15h", 72, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm0h", 59, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm1h", 60, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm2h", 61, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm3h", 62, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm4h", 63, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm5h", 64, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm6h", 65, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm7h", 66, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm8h", 67, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm9h", 68, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm10h", 69, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm11h", 70, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm12h", 71, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm13h", 72, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm14h", 73, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm15h", 74, 1, NULL, 128, "uint128"); - - feature = tdesc_create_feature (result, "org.gnu.gdb.i386.avx512"); - field_type = tdesc_named_type (feature, "ieee_single"); -@@ -202,78 +206,78 @@ initialize_tdesc_amd64_avx_avx512 (void) - field_type = tdesc_named_type (feature, "uint128"); - tdesc_create_vector (feature, "v2ui128", field_type, 2); - -- tdesc_create_reg (feature, "xmm16", 73, 1, NULL, 128, "vec128"); -- tdesc_create_reg (feature, "xmm17", 74, 1, NULL, 128, "vec128"); -- tdesc_create_reg (feature, "xmm18", 75, 1, NULL, 128, "vec128"); -- tdesc_create_reg (feature, "xmm19", 76, 1, NULL, 128, "vec128"); -- tdesc_create_reg (feature, "xmm20", 77, 1, NULL, 128, "vec128"); -- tdesc_create_reg (feature, "xmm21", 78, 1, NULL, 128, "vec128"); -- tdesc_create_reg (feature, "xmm22", 79, 1, NULL, 128, "vec128"); -- tdesc_create_reg (feature, "xmm23", 80, 1, NULL, 128, "vec128"); -- tdesc_create_reg (feature, "xmm24", 81, 1, NULL, 128, "vec128"); -- tdesc_create_reg (feature, "xmm25", 82, 1, NULL, 128, "vec128"); -- tdesc_create_reg (feature, "xmm26", 83, 1, NULL, 128, "vec128"); -- tdesc_create_reg (feature, "xmm27", 84, 1, NULL, 128, "vec128"); -- tdesc_create_reg (feature, "xmm28", 85, 1, NULL, 128, "vec128"); -- tdesc_create_reg (feature, "xmm29", 86, 1, NULL, 128, "vec128"); -- tdesc_create_reg (feature, "xmm30", 87, 1, NULL, 128, "vec128"); -- tdesc_create_reg (feature, "xmm31", 88, 1, NULL, 128, "vec128"); -- tdesc_create_reg (feature, "ymm16h", 89, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm17h", 90, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm18h", 91, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm19h", 92, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm20h", 93, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm21h", 94, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm22h", 95, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm23h", 96, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm24h", 97, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm25h", 98, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm26h", 99, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm27h", 100, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm28h", 101, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm29h", 102, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm30h", 103, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm31h", 104, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "k0", 105, 1, NULL, 64, "uint64"); -- tdesc_create_reg (feature, "k1", 106, 1, NULL, 64, "uint64"); -- tdesc_create_reg (feature, "k2", 107, 1, NULL, 64, "uint64"); -- tdesc_create_reg (feature, "k3", 108, 1, NULL, 64, "uint64"); -- tdesc_create_reg (feature, "k4", 109, 1, NULL, 64, "uint64"); -- tdesc_create_reg (feature, "k5", 110, 1, NULL, 64, "uint64"); -- tdesc_create_reg (feature, "k6", 111, 1, NULL, 64, "uint64"); -- tdesc_create_reg (feature, "k7", 112, 1, NULL, 64, "uint64"); -- tdesc_create_reg (feature, "zmm0h", 113, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm1h", 114, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm2h", 115, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm3h", 116, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm4h", 117, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm5h", 118, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm6h", 119, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm7h", 120, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm8h", 121, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm9h", 122, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm10h", 123, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm11h", 124, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm12h", 125, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm13h", 126, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm14h", 127, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm15h", 128, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm16h", 129, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm17h", 130, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm18h", 131, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm19h", 132, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm20h", 133, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm21h", 134, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm22h", 135, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm23h", 136, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm24h", 137, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm25h", 138, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm26h", 139, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm27h", 140, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm28h", 141, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm29h", 142, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm30h", 143, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm31h", 144, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "xmm16", 75, 1, NULL, 128, "vec128"); -+ tdesc_create_reg (feature, "xmm17", 76, 1, NULL, 128, "vec128"); -+ tdesc_create_reg (feature, "xmm18", 77, 1, NULL, 128, "vec128"); -+ tdesc_create_reg (feature, "xmm19", 78, 1, NULL, 128, "vec128"); -+ tdesc_create_reg (feature, "xmm20", 79, 1, NULL, 128, "vec128"); -+ tdesc_create_reg (feature, "xmm21", 80, 1, NULL, 128, "vec128"); -+ tdesc_create_reg (feature, "xmm22", 81, 1, NULL, 128, "vec128"); -+ tdesc_create_reg (feature, "xmm23", 82, 1, NULL, 128, "vec128"); -+ tdesc_create_reg (feature, "xmm24", 83, 1, NULL, 128, "vec128"); -+ tdesc_create_reg (feature, "xmm25", 84, 1, NULL, 128, "vec128"); -+ tdesc_create_reg (feature, "xmm26", 85, 1, NULL, 128, "vec128"); -+ tdesc_create_reg (feature, "xmm27", 86, 1, NULL, 128, "vec128"); -+ tdesc_create_reg (feature, "xmm28", 87, 1, NULL, 128, "vec128"); -+ tdesc_create_reg (feature, "xmm29", 88, 1, NULL, 128, "vec128"); -+ tdesc_create_reg (feature, "xmm30", 89, 1, NULL, 128, "vec128"); -+ tdesc_create_reg (feature, "xmm31", 90, 1, NULL, 128, "vec128"); -+ tdesc_create_reg (feature, "ymm16h", 91, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm17h", 92, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm18h", 93, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm19h", 94, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm20h", 95, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm21h", 96, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm22h", 97, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm23h", 98, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm24h", 99, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm25h", 100, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm26h", 101, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm27h", 102, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm28h", 103, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm29h", 104, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm30h", 105, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm31h", 106, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "k0", 107, 1, NULL, 64, "uint64"); -+ tdesc_create_reg (feature, "k1", 108, 1, NULL, 64, "uint64"); -+ tdesc_create_reg (feature, "k2", 109, 1, NULL, 64, "uint64"); -+ tdesc_create_reg (feature, "k3", 110, 1, NULL, 64, "uint64"); -+ tdesc_create_reg (feature, "k4", 111, 1, NULL, 64, "uint64"); -+ tdesc_create_reg (feature, "k5", 112, 1, NULL, 64, "uint64"); -+ tdesc_create_reg (feature, "k6", 113, 1, NULL, 64, "uint64"); -+ tdesc_create_reg (feature, "k7", 114, 1, NULL, 64, "uint64"); -+ tdesc_create_reg (feature, "zmm0h", 115, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm1h", 116, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm2h", 117, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm3h", 118, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm4h", 119, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm5h", 120, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm6h", 121, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm7h", 122, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm8h", 123, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm9h", 124, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm10h", 125, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm11h", 126, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm12h", 127, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm13h", 128, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm14h", 129, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm15h", 130, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm16h", 131, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm17h", 132, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm18h", 133, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm19h", 134, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm20h", 135, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm21h", 136, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm22h", 137, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm23h", 138, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm24h", 139, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm25h", 140, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm26h", 141, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm27h", 142, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm28h", 143, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm29h", 144, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm30h", 145, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm31h", 146, 1, NULL, 256, "v2ui128"); - - tdesc_amd64_avx_avx512 = result; - } -diff --git gdb/features/i386/amd64-avx-avx512.xml gdb/features/i386/amd64-avx-avx512.xml -index a4587433c8..fdf8136f74 100644 ---- gdb/features/i386/amd64-avx-avx512.xml -+++ gdb/features/i386/amd64-avx-avx512.xml -@@ -12,6 +12,7 @@ - i386:x86-64 - - -+ - - - -diff --git gdb/features/i386/amd64-avx-mpx-avx512-pku.c gdb/features/i386/amd64-avx-mpx-avx512-pku.c -index dfe7d7778a..f119e52f5d 100644 ---- gdb/features/i386/amd64-avx-mpx-avx512-pku.c -+++ gdb/features/i386/amd64-avx-mpx-avx512-pku.c -@@ -146,23 +146,27 @@ initialize_tdesc_amd64_avx_mpx_avx512_pku (void) - tdesc_create_reg (feature, "xmm15", 55, 1, NULL, 128, "vec128"); - tdesc_create_reg (feature, "mxcsr", 56, 1, "vector", 32, "i386_mxcsr"); - -+ feature = tdesc_create_feature (result, "org.gnu.gdb.i386.segments"); -+ tdesc_create_reg (feature, "fs_base", 57, 1, NULL, 64, "int"); -+ tdesc_create_reg (feature, "gs_base", 58, 1, NULL, 64, "int"); -+ - feature = tdesc_create_feature (result, "org.gnu.gdb.i386.avx"); -- tdesc_create_reg (feature, "ymm0h", 57, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm1h", 58, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm2h", 59, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm3h", 60, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm4h", 61, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm5h", 62, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm6h", 63, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm7h", 64, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm8h", 65, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm9h", 66, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm10h", 67, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm11h", 68, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm12h", 69, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm13h", 70, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm14h", 71, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm15h", 72, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm0h", 59, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm1h", 60, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm2h", 61, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm3h", 62, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm4h", 63, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm5h", 64, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm6h", 65, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm7h", 66, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm8h", 67, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm9h", 68, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm10h", 69, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm11h", 70, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm12h", 71, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm13h", 72, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm14h", 73, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm15h", 74, 1, NULL, 128, "uint128"); - - feature = tdesc_create_feature (result, "org.gnu.gdb.i386.mpx"); - type = tdesc_create_struct (feature, "br128"); -@@ -195,12 +199,12 @@ initialize_tdesc_amd64_avx_mpx_avx512_pku (void) - field_type = tdesc_named_type (feature, "_bndcfgu"); - tdesc_add_field (type, "config", field_type); - -- tdesc_create_reg (feature, "bnd0raw", 73, 1, NULL, 128, "br128"); -- tdesc_create_reg (feature, "bnd1raw", 74, 1, NULL, 128, "br128"); -- tdesc_create_reg (feature, "bnd2raw", 75, 1, NULL, 128, "br128"); -- tdesc_create_reg (feature, "bnd3raw", 76, 1, NULL, 128, "br128"); -- tdesc_create_reg (feature, "bndcfgu", 77, 1, NULL, 64, "cfgu"); -- tdesc_create_reg (feature, "bndstatus", 78, 1, NULL, 64, "status"); -+ tdesc_create_reg (feature, "bnd0raw", 75, 1, NULL, 128, "br128"); -+ tdesc_create_reg (feature, "bnd1raw", 76, 1, NULL, 128, "br128"); -+ tdesc_create_reg (feature, "bnd2raw", 77, 1, NULL, 128, "br128"); -+ tdesc_create_reg (feature, "bnd3raw", 78, 1, NULL, 128, "br128"); -+ tdesc_create_reg (feature, "bndcfgu", 79, 1, NULL, 64, "cfgu"); -+ tdesc_create_reg (feature, "bndstatus", 80, 1, NULL, 64, "status"); - - feature = tdesc_create_feature (result, "org.gnu.gdb.i386.avx512"); - field_type = tdesc_named_type (feature, "ieee_single"); -@@ -240,81 +244,81 @@ initialize_tdesc_amd64_avx_mpx_avx512_pku (void) - field_type = tdesc_named_type (feature, "uint128"); - tdesc_create_vector (feature, "v2ui128", field_type, 2); - -- tdesc_create_reg (feature, "xmm16", 79, 1, NULL, 128, "vec128"); -- tdesc_create_reg (feature, "xmm17", 80, 1, NULL, 128, "vec128"); -- tdesc_create_reg (feature, "xmm18", 81, 1, NULL, 128, "vec128"); -- tdesc_create_reg (feature, "xmm19", 82, 1, NULL, 128, "vec128"); -- tdesc_create_reg (feature, "xmm20", 83, 1, NULL, 128, "vec128"); -- tdesc_create_reg (feature, "xmm21", 84, 1, NULL, 128, "vec128"); -- tdesc_create_reg (feature, "xmm22", 85, 1, NULL, 128, "vec128"); -- tdesc_create_reg (feature, "xmm23", 86, 1, NULL, 128, "vec128"); -- tdesc_create_reg (feature, "xmm24", 87, 1, NULL, 128, "vec128"); -- tdesc_create_reg (feature, "xmm25", 88, 1, NULL, 128, "vec128"); -- tdesc_create_reg (feature, "xmm26", 89, 1, NULL, 128, "vec128"); -- tdesc_create_reg (feature, "xmm27", 90, 1, NULL, 128, "vec128"); -- tdesc_create_reg (feature, "xmm28", 91, 1, NULL, 128, "vec128"); -- tdesc_create_reg (feature, "xmm29", 92, 1, NULL, 128, "vec128"); -- tdesc_create_reg (feature, "xmm30", 93, 1, NULL, 128, "vec128"); -- tdesc_create_reg (feature, "xmm31", 94, 1, NULL, 128, "vec128"); -- tdesc_create_reg (feature, "ymm16h", 95, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm17h", 96, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm18h", 97, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm19h", 98, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm20h", 99, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm21h", 100, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm22h", 101, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm23h", 102, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm24h", 103, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm25h", 104, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm26h", 105, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm27h", 106, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm28h", 107, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm29h", 108, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm30h", 109, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm31h", 110, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "k0", 111, 1, NULL, 64, "uint64"); -- tdesc_create_reg (feature, "k1", 112, 1, NULL, 64, "uint64"); -- tdesc_create_reg (feature, "k2", 113, 1, NULL, 64, "uint64"); -- tdesc_create_reg (feature, "k3", 114, 1, NULL, 64, "uint64"); -- tdesc_create_reg (feature, "k4", 115, 1, NULL, 64, "uint64"); -- tdesc_create_reg (feature, "k5", 116, 1, NULL, 64, "uint64"); -- tdesc_create_reg (feature, "k6", 117, 1, NULL, 64, "uint64"); -- tdesc_create_reg (feature, "k7", 118, 1, NULL, 64, "uint64"); -- tdesc_create_reg (feature, "zmm0h", 119, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm1h", 120, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm2h", 121, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm3h", 122, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm4h", 123, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm5h", 124, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm6h", 125, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm7h", 126, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm8h", 127, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm9h", 128, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm10h", 129, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm11h", 130, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm12h", 131, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm13h", 132, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm14h", 133, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm15h", 134, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm16h", 135, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm17h", 136, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm18h", 137, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm19h", 138, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm20h", 139, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm21h", 140, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm22h", 141, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm23h", 142, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm24h", 143, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm25h", 144, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm26h", 145, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm27h", 146, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm28h", 147, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm29h", 148, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm30h", 149, 1, NULL, 256, "v2ui128"); -- tdesc_create_reg (feature, "zmm31h", 150, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "xmm16", 81, 1, NULL, 128, "vec128"); -+ tdesc_create_reg (feature, "xmm17", 82, 1, NULL, 128, "vec128"); -+ tdesc_create_reg (feature, "xmm18", 83, 1, NULL, 128, "vec128"); -+ tdesc_create_reg (feature, "xmm19", 84, 1, NULL, 128, "vec128"); -+ tdesc_create_reg (feature, "xmm20", 85, 1, NULL, 128, "vec128"); -+ tdesc_create_reg (feature, "xmm21", 86, 1, NULL, 128, "vec128"); -+ tdesc_create_reg (feature, "xmm22", 87, 1, NULL, 128, "vec128"); -+ tdesc_create_reg (feature, "xmm23", 88, 1, NULL, 128, "vec128"); -+ tdesc_create_reg (feature, "xmm24", 89, 1, NULL, 128, "vec128"); -+ tdesc_create_reg (feature, "xmm25", 90, 1, NULL, 128, "vec128"); -+ tdesc_create_reg (feature, "xmm26", 91, 1, NULL, 128, "vec128"); -+ tdesc_create_reg (feature, "xmm27", 92, 1, NULL, 128, "vec128"); -+ tdesc_create_reg (feature, "xmm28", 93, 1, NULL, 128, "vec128"); -+ tdesc_create_reg (feature, "xmm29", 94, 1, NULL, 128, "vec128"); -+ tdesc_create_reg (feature, "xmm30", 95, 1, NULL, 128, "vec128"); -+ tdesc_create_reg (feature, "xmm31", 96, 1, NULL, 128, "vec128"); -+ tdesc_create_reg (feature, "ymm16h", 97, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm17h", 98, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm18h", 99, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm19h", 100, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm20h", 101, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm21h", 102, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm22h", 103, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm23h", 104, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm24h", 105, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm25h", 106, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm26h", 107, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm27h", 108, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm28h", 109, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm29h", 110, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm30h", 111, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm31h", 112, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "k0", 113, 1, NULL, 64, "uint64"); -+ tdesc_create_reg (feature, "k1", 114, 1, NULL, 64, "uint64"); -+ tdesc_create_reg (feature, "k2", 115, 1, NULL, 64, "uint64"); -+ tdesc_create_reg (feature, "k3", 116, 1, NULL, 64, "uint64"); -+ tdesc_create_reg (feature, "k4", 117, 1, NULL, 64, "uint64"); -+ tdesc_create_reg (feature, "k5", 118, 1, NULL, 64, "uint64"); -+ tdesc_create_reg (feature, "k6", 119, 1, NULL, 64, "uint64"); -+ tdesc_create_reg (feature, "k7", 120, 1, NULL, 64, "uint64"); -+ tdesc_create_reg (feature, "zmm0h", 121, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm1h", 122, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm2h", 123, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm3h", 124, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm4h", 125, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm5h", 126, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm6h", 127, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm7h", 128, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm8h", 129, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm9h", 130, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm10h", 131, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm11h", 132, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm12h", 133, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm13h", 134, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm14h", 135, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm15h", 136, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm16h", 137, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm17h", 138, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm18h", 139, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm19h", 140, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm20h", 141, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm21h", 142, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm22h", 143, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm23h", 144, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm24h", 145, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm25h", 146, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm26h", 147, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm27h", 148, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm28h", 149, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm29h", 150, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm30h", 151, 1, NULL, 256, "v2ui128"); -+ tdesc_create_reg (feature, "zmm31h", 152, 1, NULL, 256, "v2ui128"); - - feature = tdesc_create_feature (result, "org.gnu.gdb.i386.pkeys"); -- tdesc_create_reg (feature, "pkru", 151, 1, NULL, 32, "uint32"); -+ tdesc_create_reg (feature, "pkru", 153, 1, NULL, 32, "uint32"); - - tdesc_amd64_avx_mpx_avx512_pku = result; - } -diff --git gdb/features/i386/amd64-avx-mpx-avx512-pku.xml gdb/features/i386/amd64-avx-mpx-avx512-pku.xml -index e769108873..d8203e3400 100644 ---- gdb/features/i386/amd64-avx-mpx-avx512-pku.xml -+++ gdb/features/i386/amd64-avx-mpx-avx512-pku.xml -@@ -12,6 +12,7 @@ - i386:x86-64 - - -+ - - - -diff --git gdb/features/i386/amd64-avx-mpx.c gdb/features/i386/amd64-avx-mpx.c -index ab56f42f13..0c5161fe8d 100644 ---- gdb/features/i386/amd64-avx-mpx.c -+++ gdb/features/i386/amd64-avx-mpx.c -@@ -146,23 +146,27 @@ initialize_tdesc_amd64_avx_mpx (void) - tdesc_create_reg (feature, "xmm15", 55, 1, NULL, 128, "vec128"); - tdesc_create_reg (feature, "mxcsr", 56, 1, "vector", 32, "i386_mxcsr"); - -+ feature = tdesc_create_feature (result, "org.gnu.gdb.i386.segments"); -+ tdesc_create_reg (feature, "fs_base", 57, 1, NULL, 64, "int"); -+ tdesc_create_reg (feature, "gs_base", 58, 1, NULL, 64, "int"); -+ - feature = tdesc_create_feature (result, "org.gnu.gdb.i386.avx"); -- tdesc_create_reg (feature, "ymm0h", 57, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm1h", 58, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm2h", 59, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm3h", 60, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm4h", 61, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm5h", 62, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm6h", 63, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm7h", 64, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm8h", 65, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm9h", 66, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm10h", 67, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm11h", 68, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm12h", 69, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm13h", 70, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm14h", 71, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm15h", 72, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm0h", 59, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm1h", 60, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm2h", 61, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm3h", 62, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm4h", 63, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm5h", 64, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm6h", 65, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm7h", 66, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm8h", 67, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm9h", 68, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm10h", 69, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm11h", 70, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm12h", 71, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm13h", 72, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm14h", 73, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm15h", 74, 1, NULL, 128, "uint128"); - - feature = tdesc_create_feature (result, "org.gnu.gdb.i386.mpx"); - type = tdesc_create_struct (feature, "br128"); -@@ -195,12 +199,12 @@ initialize_tdesc_amd64_avx_mpx (void) - field_type = tdesc_named_type (feature, "_bndcfgu"); - tdesc_add_field (type, "config", field_type); - -- tdesc_create_reg (feature, "bnd0raw", 73, 1, NULL, 128, "br128"); -- tdesc_create_reg (feature, "bnd1raw", 74, 1, NULL, 128, "br128"); -- tdesc_create_reg (feature, "bnd2raw", 75, 1, NULL, 128, "br128"); -- tdesc_create_reg (feature, "bnd3raw", 76, 1, NULL, 128, "br128"); -- tdesc_create_reg (feature, "bndcfgu", 77, 1, NULL, 64, "cfgu"); -- tdesc_create_reg (feature, "bndstatus", 78, 1, NULL, 64, "status"); -+ tdesc_create_reg (feature, "bnd0raw", 75, 1, NULL, 128, "br128"); -+ tdesc_create_reg (feature, "bnd1raw", 76, 1, NULL, 128, "br128"); -+ tdesc_create_reg (feature, "bnd2raw", 77, 1, NULL, 128, "br128"); -+ tdesc_create_reg (feature, "bnd3raw", 78, 1, NULL, 128, "br128"); -+ tdesc_create_reg (feature, "bndcfgu", 79, 1, NULL, 64, "cfgu"); -+ tdesc_create_reg (feature, "bndstatus", 80, 1, NULL, 64, "status"); - - tdesc_amd64_avx_mpx = result; - } -diff --git gdb/features/i386/amd64-avx-mpx.xml gdb/features/i386/amd64-avx-mpx.xml -index 0001dc8413..001cc58fa6 100644 ---- gdb/features/i386/amd64-avx-mpx.xml -+++ gdb/features/i386/amd64-avx-mpx.xml -@@ -12,6 +12,7 @@ - i386:x86-64 - - -+ - - - -diff --git gdb/features/i386/amd64-avx.c gdb/features/i386/amd64-avx.c -index 42bd69ab97..61d3ff56a4 100644 ---- gdb/features/i386/amd64-avx.c -+++ gdb/features/i386/amd64-avx.c -@@ -146,23 +146,27 @@ initialize_tdesc_amd64_avx (void) - tdesc_create_reg (feature, "xmm15", 55, 1, NULL, 128, "vec128"); - tdesc_create_reg (feature, "mxcsr", 56, 1, "vector", 32, "i386_mxcsr"); - -+ feature = tdesc_create_feature (result, "org.gnu.gdb.i386.segments"); -+ tdesc_create_reg (feature, "fs_base", 57, 1, NULL, 64, "int"); -+ tdesc_create_reg (feature, "gs_base", 58, 1, NULL, 64, "int"); -+ - feature = tdesc_create_feature (result, "org.gnu.gdb.i386.avx"); -- tdesc_create_reg (feature, "ymm0h", 57, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm1h", 58, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm2h", 59, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm3h", 60, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm4h", 61, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm5h", 62, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm6h", 63, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm7h", 64, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm8h", 65, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm9h", 66, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm10h", 67, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm11h", 68, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm12h", 69, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm13h", 70, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm14h", 71, 1, NULL, 128, "uint128"); -- tdesc_create_reg (feature, "ymm15h", 72, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm0h", 59, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm1h", 60, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm2h", 61, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm3h", 62, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm4h", 63, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm5h", 64, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm6h", 65, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm7h", 66, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm8h", 67, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm9h", 68, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm10h", 69, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm11h", 70, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm12h", 71, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm13h", 72, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm14h", 73, 1, NULL, 128, "uint128"); -+ tdesc_create_reg (feature, "ymm15h", 74, 1, NULL, 128, "uint128"); - - tdesc_amd64_avx = result; - } -diff --git gdb/features/i386/amd64-avx.xml gdb/features/i386/amd64-avx.xml -index d3b63b8132..a0fec551d9 100644 ---- gdb/features/i386/amd64-avx.xml -+++ gdb/features/i386/amd64-avx.xml -@@ -12,5 +12,6 @@ - i386:x86-64 - - -+ - - -diff --git gdb/features/i386/amd64-mpx.c gdb/features/i386/amd64-mpx.c -index 41f0e7834b..026fdb8625 100644 ---- gdb/features/i386/amd64-mpx.c -+++ gdb/features/i386/amd64-mpx.c -@@ -146,6 +146,10 @@ initialize_tdesc_amd64_mpx (void) - tdesc_create_reg (feature, "xmm15", 55, 1, NULL, 128, "vec128"); - tdesc_create_reg (feature, "mxcsr", 56, 1, "vector", 32, "i386_mxcsr"); - -+ feature = tdesc_create_feature (result, "org.gnu.gdb.i386.segments"); -+ tdesc_create_reg (feature, "fs_base", 57, 1, NULL, 64, "int"); -+ tdesc_create_reg (feature, "gs_base", 58, 1, NULL, 64, "int"); -+ - feature = tdesc_create_feature (result, "org.gnu.gdb.i386.mpx"); - type = tdesc_create_struct (feature, "br128"); - field_type = tdesc_named_type (feature, "uint64"); -@@ -177,12 +181,12 @@ initialize_tdesc_amd64_mpx (void) - field_type = tdesc_named_type (feature, "_bndcfgu"); - tdesc_add_field (type, "config", field_type); - -- tdesc_create_reg (feature, "bnd0raw", 57, 1, NULL, 128, "br128"); -- tdesc_create_reg (feature, "bnd1raw", 58, 1, NULL, 128, "br128"); -- tdesc_create_reg (feature, "bnd2raw", 59, 1, NULL, 128, "br128"); -- tdesc_create_reg (feature, "bnd3raw", 60, 1, NULL, 128, "br128"); -- tdesc_create_reg (feature, "bndcfgu", 61, 1, NULL, 64, "cfgu"); -- tdesc_create_reg (feature, "bndstatus", 62, 1, NULL, 64, "status"); -+ tdesc_create_reg (feature, "bnd0raw", 59, 1, NULL, 128, "br128"); -+ tdesc_create_reg (feature, "bnd1raw", 60, 1, NULL, 128, "br128"); -+ tdesc_create_reg (feature, "bnd2raw", 61, 1, NULL, 128, "br128"); -+ tdesc_create_reg (feature, "bnd3raw", 62, 1, NULL, 128, "br128"); -+ tdesc_create_reg (feature, "bndcfgu", 63, 1, NULL, 64, "cfgu"); -+ tdesc_create_reg (feature, "bndstatus", 64, 1, NULL, 64, "status"); - - tdesc_amd64_mpx = result; - } -diff --git gdb/features/i386/amd64-mpx.xml gdb/features/i386/amd64-mpx.xml -index 7692006e9c..7e0253d661 100644 ---- gdb/features/i386/amd64-mpx.xml -+++ gdb/features/i386/amd64-mpx.xml -@@ -12,5 +12,6 @@ - i386:x86-64 - - -+ - - -diff --git gdb/features/i386/amd64.c gdb/features/i386/amd64.c -index b875a9b322..31ab6ccfba 100644 ---- gdb/features/i386/amd64.c -+++ gdb/features/i386/amd64.c -@@ -146,5 +146,9 @@ initialize_tdesc_amd64 (void) - tdesc_create_reg (feature, "xmm15", 55, 1, NULL, 128, "vec128"); - tdesc_create_reg (feature, "mxcsr", 56, 1, "vector", 32, "i386_mxcsr"); - -+ feature = tdesc_create_feature (result, "org.gnu.gdb.i386.segments"); -+ tdesc_create_reg (feature, "fs_base", 57, 1, NULL, 64, "int"); -+ tdesc_create_reg (feature, "gs_base", 58, 1, NULL, 64, "int"); -+ - tdesc_amd64 = result; - } -diff --git gdb/features/i386/amd64.xml gdb/features/i386/amd64.xml -index d11c07e234..1962a2af37 100644 ---- gdb/features/i386/amd64.xml -+++ gdb/features/i386/amd64.xml -@@ -12,4 +12,5 @@ - i386:x86-64 - - -+ - -diff --git gdb/regformats/i386/amd64-avx-avx512.dat gdb/regformats/i386/amd64-avx-avx512.dat -index b7938e6919..1fbe4733f5 100644 ---- gdb/regformats/i386/amd64-avx-avx512.dat -+++ gdb/regformats/i386/amd64-avx-avx512.dat -@@ -60,6 +60,8 @@ expedite:rbp,rsp,rip - 128:xmm14 - 128:xmm15 - 32:mxcsr -+64:fs_base -+64:gs_base - 128:ymm0h - 128:ymm1h - 128:ymm2h -diff --git gdb/regformats/i386/amd64-avx-mpx-avx512-pku.dat gdb/regformats/i386/amd64-avx-mpx-avx512-pku.dat -index b3340d3276..23c3a4062e 100644 ---- gdb/regformats/i386/amd64-avx-mpx-avx512-pku.dat -+++ gdb/regformats/i386/amd64-avx-mpx-avx512-pku.dat -@@ -60,6 +60,8 @@ expedite:rbp,rsp,rip - 128:xmm14 - 128:xmm15 - 32:mxcsr -+64:fs_base -+64:gs_base - 128:ymm0h - 128:ymm1h - 128:ymm2h -diff --git gdb/regformats/i386/amd64-avx-mpx.dat gdb/regformats/i386/amd64-avx-mpx.dat -index d985641b01..655775b0f9 100644 ---- gdb/regformats/i386/amd64-avx-mpx.dat -+++ gdb/regformats/i386/amd64-avx-mpx.dat -@@ -60,6 +60,8 @@ expedite:rbp,rsp,rip - 128:xmm14 - 128:xmm15 - 32:mxcsr -+64:fs_base -+64:gs_base - 128:ymm0h - 128:ymm1h - 128:ymm2h -diff --git gdb/regformats/i386/amd64-avx.dat gdb/regformats/i386/amd64-avx.dat -index 223233667a..8b9d81e743 100644 ---- gdb/regformats/i386/amd64-avx.dat -+++ gdb/regformats/i386/amd64-avx.dat -@@ -60,6 +60,8 @@ expedite:rbp,rsp,rip - 128:xmm14 - 128:xmm15 - 32:mxcsr -+64:fs_base -+64:gs_base - 128:ymm0h - 128:ymm1h - 128:ymm2h -diff --git gdb/regformats/i386/amd64-mpx.dat gdb/regformats/i386/amd64-mpx.dat -index 43b87769c2..d5e60babd8 100644 ---- gdb/regformats/i386/amd64-mpx.dat -+++ gdb/regformats/i386/amd64-mpx.dat -@@ -60,6 +60,8 @@ expedite:rbp,rsp,rip - 128:xmm14 - 128:xmm15 - 32:mxcsr -+64:fs_base -+64:gs_base - 128:bnd0raw - 128:bnd1raw - 128:bnd2raw -diff --git gdb/regformats/i386/amd64.dat gdb/regformats/i386/amd64.dat -index 0ff917019d..66f26ad094 100644 ---- gdb/regformats/i386/amd64.dat -+++ gdb/regformats/i386/amd64.dat -@@ -60,3 +60,5 @@ expedite:rbp,rsp,rip - 128:xmm14 - 128:xmm15 - 32:mxcsr -+64:fs_base -+64:gs_base Property changes on: head/devel/gdb/files/commit-48aeef91c2 ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/devel/gdb/files/commit-a181c0bf74 =================================================================== --- head/devel/gdb/files/commit-a181c0bf74 (revision 464492) +++ head/devel/gdb/files/commit-a181c0bf74 (nonexistent) @@ -1,79 +0,0 @@ -commit a181c0bf74 -Author: John Baldwin -Date: Mon Oct 9 09:54:42 2017 -0700 - - Use gdbarch_long_bit to determine layout of FreeBSD siginfo_t. - - FreeBSD architectures are either ILP32 or LP64 resulting in two - different layouts for siginfo_t. Previously, the 'bits_per_word' - member of bfd_arch_info was used to determine the layout to use for a - given FreeBSD architecture. However, mipsn32 architectures inherit - from a 64-bit mips architecture where bits_per_word is 64. As a - result, $_siginfo was not properly extracted from FreeBSD/mipsn32 core - dumps. Fix this by using gdbarch_long_bit instead of 'bits_per_word' - to determine if a FreeBSD architecture is ILP32 or LP64. - - gdb/ChangeLog: - - * fbsd-nat.c (fbsd_siginfo_size): Use gdbarch_long_bit. - (fbsd_convert_siginfo): Likewise. - * fbsd-tdep.c (fbsd_core_xfer_siginfo): Likewise. - -diff --git gdb/ChangeLog gdb/ChangeLog -index 7c8c6e4fe5..b04da8bd44 100644 ---- gdb/ChangeLog -+++ gdb/ChangeLog -@@ -1,3 +1,9 @@ -+2017-10-09 John Baldwin -+ -+ * fbsd-nat.c (fbsd_siginfo_size): Use gdbarch_long_bit. -+ (fbsd_convert_siginfo): Likewise. -+ * fbsd-tdep.c (fbsd_core_xfer_siginfo): Likewise. -+ - 2017-10-09 Simon Marchi - - * configure.ac (try_guile_versions): Remove guile-2.2. -diff --git gdb/fbsd-nat.c gdb/fbsd-nat.c -index 5ad0dda5b4..265175a769 100644 ---- gdb/fbsd-nat.c -+++ gdb/fbsd-nat.c -@@ -279,7 +279,7 @@ fbsd_siginfo_size () - struct gdbarch *gdbarch = get_frame_arch (get_current_frame ()); - - /* Is the inferior 32-bit? If so, use the 32-bit siginfo size. */ -- if (gdbarch_bfd_arch_info (gdbarch)->bits_per_word == 32) -+ if (gdbarch_long_bit (gdbarch) == 32) - return sizeof (struct siginfo32); - #endif - return sizeof (siginfo_t); -@@ -296,7 +296,7 @@ fbsd_convert_siginfo (siginfo_t *si) - struct gdbarch *gdbarch = get_frame_arch (get_current_frame ()); - - /* Is the inferior 32-bit? If not, nothing to do. */ -- if (gdbarch_bfd_arch_info (gdbarch)->bits_per_word != 32) -+ if (gdbarch_long_bit (gdbarch) != 32) - return; - - struct siginfo32 si32; -diff --git gdb/fbsd-tdep.c gdb/fbsd-tdep.c -index fa4cd912ef..fa70f7c20b 100644 ---- gdb/fbsd-tdep.c -+++ gdb/fbsd-tdep.c -@@ -143,7 +143,7 @@ fbsd_core_xfer_siginfo (struct gdbarch *gdbarch, gdb_byte *readbuf, - { - size_t siginfo_size; - -- if (gdbarch_bfd_arch_info (gdbarch)->bits_per_word == 32) -+ if (gdbarch_long_bit (gdbarch) == 32) - siginfo_size = SIZE32_SIGINFO_T; - else - siginfo_size = SIZE64_SIGINFO_T; -@@ -168,7 +168,7 @@ fbsd_core_xfer_siginfo (struct gdbarch *gdbarch, gdb_byte *readbuf, - len = siginfo_size - offset; - - ULONGEST siginfo_offset; -- if (gdbarch_bfd_arch_info (gdbarch)->bits_per_word == 32) -+ if (gdbarch_long_bit (gdbarch) == 32) - siginfo_offset = LWPINFO_OFFSET + LWPINFO32_PL_SIGINFO; - else - siginfo_offset = LWPINFO_OFFSET + LWPINFO64_PL_SIGINFO; Property changes on: head/devel/gdb/files/commit-a181c0bf74 ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/devel/gdb/files/commit-a80a647180 =================================================================== --- head/devel/gdb/files/commit-a80a647180 (revision 464492) +++ head/devel/gdb/files/commit-a80a647180 (nonexistent) @@ -1,53 +0,0 @@ -commit a80a647180bf92692e0f01efe7b323afe7d317c9 -Author: John Baldwin -Date: Thu Oct 5 09:50:01 2017 -0700 - - Add a signal frame unwinder for FreeBSD/mipsn32. - - The N32 signal frame uses an identical layout to N64, so reuse the N64 - handler. The N32 signal trampoline does use one different instruction - relative to N64, so a separate tramp_frame is required. - - gdb/ChangeLog: - - * mips-fbsd-tdep.c (MIPS_INST_ADDIU_A0_SP_N32): Define. - (mipsn32_fbsd_sigframe): Define. - (mips_fbsd_init_abi): Install mipsn32_fbsd_sigframe unwinder - for FreeBSD/mipsn32. - -diff --git gdb/mips-fbsd-tdep.c gdb/mips-fbsd-tdep.c -index 05545e37d8..b1578d0cbb 100644 ---- gdb/mips-fbsd-tdep.c -+++ gdb/mips-fbsd-tdep.c -@@ -426,6 +426,23 @@ mips64_fbsd_sigframe_init (const struct tramp_frame *self, - trad_frame_set_id (cache, frame_id_build (sp, func)); - } - -+#define MIPS_INST_ADDIU_A0_SP_N32 (0x27a40000 \ -+ + N64_SIGFRAME_UCONTEXT_OFFSET) -+ -+static const struct tramp_frame mipsn32_fbsd_sigframe = -+{ -+ SIGTRAMP_FRAME, -+ MIPS_INSN32_SIZE, -+ { -+ { MIPS_INST_ADDIU_A0_SP_N32, -1 }, /* addiu a0, sp, SIGF_UC */ -+ { MIPS_INST_LI_V0_SIGRETURN, -1 }, /* li v0, SYS_sigreturn */ -+ { MIPS_INST_SYSCALL, -1 }, /* syscall */ -+ { MIPS_INST_BREAK, -1 }, /* break */ -+ { TRAMP_SENTINEL_INSN, -1 } -+ }, -+ mips64_fbsd_sigframe_init -+}; -+ - #define MIPS_INST_DADDIU_A0_SP_N64 (0x67a40000 \ - + N64_SIGFRAME_UCONTEXT_OFFSET) - -@@ -519,6 +536,7 @@ mips_fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) - tramp_frame_prepend_unwinder (gdbarch, &mips_fbsd_sigframe); - break; - case MIPS_ABI_N32: -+ tramp_frame_prepend_unwinder (gdbarch, &mipsn32_fbsd_sigframe); - break; - case MIPS_ABI_N64: - tramp_frame_prepend_unwinder (gdbarch, &mips64_fbsd_sigframe); Property changes on: head/devel/gdb/files/commit-a80a647180 ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/devel/gdb/files/commit-12279366d7 =================================================================== --- head/devel/gdb/files/commit-12279366d7 (nonexistent) +++ head/devel/gdb/files/commit-12279366d7 (revision 464493) @@ -0,0 +1,121 @@ +commit 12279366d71627bfbdd74d1a6675dca825d8feca +Author: John Baldwin +Date: Sat Mar 3 21:25:33 2018 -0800 + + Implement "to_stopped_by_hw_breakpoint" for x86 debug registers. + + Report that a thread is stopped by a hardware breakpoint if a non-data + watchpoint is set in DR6. This change should be a no-op since a target + still needs to implement the "to_supports_stopped_by_hw_breakpoint" + method before this function is used. + + gdb/ChangeLog: + + * nat/x86-dregs.c (x86_dr_stopped_by_hw_breakpoint): New function. + * nat/x86-dregs.h (x86_dr_stopped_by_hw_breakpoint): New + prototype. + * x86-nat.c (x86_stopped_by_hw_breakpoint): New function. + (x86_use_watchpoints): Set "stopped_by_hw_breakpoint" target + method. + +diff --git gdb/nat/x86-dregs.c gdb/nat/x86-dregs.c +index c816473628..f11a708e27 100644 +--- gdb/nat/x86-dregs.c ++++ gdb/nat/x86-dregs.c +@@ -649,3 +649,48 @@ x86_dr_stopped_by_watchpoint (struct x86_debug_reg_state *state) + CORE_ADDR addr = 0; + return x86_dr_stopped_data_address (state, &addr); + } ++ ++/* Return non-zero if the inferior has some hardware breakpoint that ++ triggered. Otherwise return zero. */ ++ ++int ++x86_dr_stopped_by_hw_breakpoint (struct x86_debug_reg_state *state) ++{ ++ CORE_ADDR addr = 0; ++ int i; ++ int rc = 0; ++ /* The current thread's DR_STATUS. We always need to read this to ++ check whether some watchpoint caused the trap. */ ++ unsigned status; ++ /* We need DR_CONTROL as well, but only iff DR_STATUS indicates a ++ breakpoint trap. Only fetch it when necessary, to avoid an ++ unnecessary extra syscall when no watchpoint triggered. */ ++ int control_p = 0; ++ unsigned control = 0; ++ ++ /* As above, always read the current thread's debug registers rather ++ than trusting dr_mirror. */ ++ status = x86_dr_low_get_status (); ++ ++ ALL_DEBUG_ADDRESS_REGISTERS (i) ++ { ++ if (!X86_DR_WATCH_HIT (status, i)) ++ continue; ++ ++ if (!control_p) ++ { ++ control = x86_dr_low_get_control (); ++ control_p = 1; ++ } ++ ++ if (X86_DR_GET_RW_LEN (control, i) == 0) ++ { ++ addr = x86_dr_low_get_addr (i); ++ rc = 1; ++ if (show_debug_regs) ++ x86_show_dr (state, "watchpoint_hit", addr, -1, hw_execute); ++ } ++ } ++ ++ return rc; ++} +diff --git gdb/nat/x86-dregs.h gdb/nat/x86-dregs.h +index dd6242eda9..e86e83aea0 100644 +--- gdb/nat/x86-dregs.h ++++ gdb/nat/x86-dregs.h +@@ -128,4 +128,8 @@ extern int x86_dr_stopped_data_address (struct x86_debug_reg_state *state, + Otherwise return false. */ + extern int x86_dr_stopped_by_watchpoint (struct x86_debug_reg_state *state); + ++/* Return true if the inferior has some hardware breakpoint that ++ triggered. Otherwise return false. */ ++extern int x86_dr_stopped_by_hw_breakpoint (struct x86_debug_reg_state *state); ++ + #endif /* X86_DREGS_H */ +diff --git gdb/x86-nat.c gdb/x86-nat.c +index b126c47c94..bec51373a6 100644 +--- gdb/x86-nat.c ++++ gdb/x86-nat.c +@@ -260,6 +260,18 @@ x86_can_use_hw_breakpoint (struct target_ops *self, + return 1; + } + ++/* Return non-zero if the inferior has some breakpoint that triggered. ++ Otherwise return zero. */ ++ ++static int ++x86_stopped_by_hw_breakpoint (struct target_ops *ops) ++{ ++ struct x86_debug_reg_state *state ++ = x86_debug_reg_state (ptid_get_pid (inferior_ptid)); ++ ++ return x86_dr_stopped_by_hw_breakpoint (state); ++} ++ + static void + add_show_debug_regs_command (void) + { +@@ -297,6 +309,11 @@ x86_use_watchpoints (struct target_ops *t) + t->to_remove_watchpoint = x86_remove_watchpoint; + t->to_insert_hw_breakpoint = x86_insert_hw_breakpoint; + t->to_remove_hw_breakpoint = x86_remove_hw_breakpoint; ++ ++ /* A target must provide an implementation of the ++ "to_supports_stopped_by_hw_breakpoint" target method before this ++ callback will be used. */ ++ t->to_stopped_by_hw_breakpoint = x86_stopped_by_hw_breakpoint; + } + + void Property changes on: head/devel/gdb/files/commit-12279366d7 ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/devel/gdb/files/commit-262f62f57d =================================================================== --- head/devel/gdb/files/commit-262f62f57d (nonexistent) +++ head/devel/gdb/files/commit-262f62f57d (revision 464493) @@ -0,0 +1,43 @@ +commit 262f62f57d987269152412a55c458a03adc6ddd6 +Author: John Baldwin +Date: Tue Jan 9 13:35:17 2018 -0800 + + Use gdb::unique_xmalloc_ptr<> instead of a deleter that invokes free(). + + Since xfree() always wraps free(), it is safe to use the xfree deleter + for buffers allocated by library routines such as kinfo_getvmmap() that + must be released via free(). + + gdb/ChangeLog: + + * fbsd-nat.c (struct free_deleter): Remove. + (fbsd_find_memory_regions): Use gdb::unique_xmalloc_ptr<>. + +diff --git gdb/fbsd-nat.c gdb/fbsd-nat.c +index d0aaf89145..81f8e27a2d 100644 +--- gdb/fbsd-nat.c ++++ gdb/fbsd-nat.c +@@ -81,14 +81,6 @@ fbsd_pid_to_exec_file (struct target_ops *self, int pid) + } + + #ifdef HAVE_KINFO_GETVMMAP +-/* Deleter for std::unique_ptr that invokes free. */ +- +-template +-struct free_deleter +-{ +- void operator() (T *ptr) const { free (ptr); } +-}; +- + /* Iterate over all the memory regions in the current inferior, + calling FUNC for each memory region. OBFD is passed as the last + argument to FUNC. */ +@@ -102,7 +94,7 @@ fbsd_find_memory_regions (struct target_ops *self, + uint64_t size; + int i, nitems; + +- std::unique_ptr> ++ gdb::unique_xmalloc_ptr + vmentl (kinfo_getvmmap (pid, &nitems)); + if (vmentl == NULL) + perror_with_name (_("Couldn't fetch VM map entries.")); Property changes on: head/devel/gdb/files/commit-262f62f57d ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/devel/gdb/files/commit-2d97a5d9d3 =================================================================== --- head/devel/gdb/files/commit-2d97a5d9d3 (nonexistent) +++ head/devel/gdb/files/commit-2d97a5d9d3 (revision 464493) @@ -0,0 +1,169 @@ +commit 2d97a5d9d33aea87c3bd02fd1fa417f5d4e1fa05 +Author: John Baldwin +Date: Tue Jan 9 13:35:17 2018 -0800 + + Document support for 'info proc' on FreeBSD. + + Since the 'info proc' support on FreeBSD does not use /proc, reword + the documentation for 'info proc' to not assume /proc. This includes + renaming the node to 'Process Information' and suggesting that + additional process information can be queried via different + OS-specific interfaces. This is also cleans up the description of + 'info proc' support for core files a bit as /proc is not used for core + file support on any current platform. + + gdb/ChangeLog: + + * NEWS: Document that 'info proc' now works on FreeBSD. + + gdb/doc/ChangeLog: + + * gdb.texinfo (pwd): Update cross-reference for Process Information + node and remove explicit /proc reference. + (Native): Rename subsection from SVR4 Process Information to + Process Information. + (Process Information): Reword introduction to be less /proc + centric. Document support for "info proc" on FreeBSD. + +diff --git gdb/NEWS gdb/NEWS +index 2f834c6ff4..f69173a245 100644 +--- gdb/NEWS ++++ gdb/NEWS +@@ -3,6 +3,9 @@ + + *** Changes since GDB 8.1 + ++* 'info proc' now works on running processes on FreeBSD systems and core ++ files created on FreeBSD systems. ++ + *** Changes in GDB 8.1 + + * GDB now supports dynamically creating arbitrary register groups specified +diff --git gdb/doc/gdb.texinfo gdb/doc/gdb.texinfo +index 8bdafb0ba4..096c82cc82 100644 +--- gdb/doc/gdb.texinfo ++++ gdb/doc/gdb.texinfo +@@ -2523,9 +2523,9 @@ Print the @value{GDBN} working directory. + + It is generally impossible to find the current working directory of + the process being debugged (since a program can change its directory +-during its run). If you work on a system where @value{GDBN} is +-configured with the @file{/proc} support, you can use the @code{info +-proc} command (@pxref{SVR4 Process Information}) to find out the ++during its run). If you work on a system where @value{GDBN} supports ++the @code {info proc} command (@pxref{Process Information}), you can ++use the @code{info proc} command to find out the + current working directory of the debuggee. + + @node Input/Output +@@ -21712,7 +21712,7 @@ configurations. + + @menu + * BSD libkvm Interface:: Debugging BSD kernel memory images +-* SVR4 Process Information:: SVR4 process information ++* Process Information:: Process information + * DJGPP Native:: Features specific to the DJGPP port + * Cygwin Native:: Features specific to the Cygwin port + * Hurd Native:: Features specific to @sc{gnu} Hurd +@@ -21759,24 +21759,32 @@ Set current context from proc address. This command isn't available on + modern FreeBSD systems. + @end table + +-@node SVR4 Process Information +-@subsection SVR4 Process Information ++@node Process Information ++@subsection Process Information + @cindex /proc + @cindex examine process image + @cindex process info via @file{/proc} + +-Many versions of SVR4 and compatible systems provide a facility called +-@samp{/proc} that can be used to examine the image of a running +-process using file-system subroutines. ++Some operating systems provide interfaces to fetch additional ++information about running processes beyond memory and per-thread ++register state. If @value{GDBN} is configured for an operating system ++with a supported interface, the command @code{info proc} is available ++to report information about the process running your program, or about ++any process running on your system. + +-If @value{GDBN} is configured for an operating system with this +-facility, the command @code{info proc} is available to report +-information about the process running your program, or about any +-process running on your system. This includes, as of this writing, +-@sc{gnu}/Linux and Solaris, for example. ++One supported interface is a facility called @samp{/proc} that can be ++used to examine the image of a running process using file-system ++subroutines. This facility is supported on @sc{gnu}/Linux and Solaris ++systems. + +-This command may also work on core files that were created on a system +-that has the @samp{/proc} facility. ++On FreeBSD systems, system control nodes are used to query process ++information. ++ ++In addition, some systems may provide additional process information ++in core files. Note that a core file may include a subset of the ++information available from a live process. Process information is ++currently avaiable from cores created on @sc{gnu}/Linux and FreeBSD ++systems. + + @table @code + @kindex info proc +@@ -21800,36 +21808,40 @@ a process ID rather than a thread ID). + @item info proc cmdline + @cindex info proc cmdline + Show the original command line of the process. This command is +-specific to @sc{gnu}/Linux. ++supported on @sc{gnu}/Linux and FreeBSD. + + @item info proc cwd + @cindex info proc cwd + Show the current working directory of the process. This command is +-specific to @sc{gnu}/Linux. ++supported on @sc{gnu}/Linux and FreeBSD. + + @item info proc exe + @cindex info proc exe +-Show the name of executable of the process. This command is specific +-to @sc{gnu}/Linux. ++Show the name of executable of the process. This command is supported ++on @sc{gnu}/Linux and FreeBSD. + + @item info proc mappings + @cindex memory address space mappings +-Report the memory address space ranges accessible in the program, with +-information on whether the process has read, write, or execute access +-rights to each range. On @sc{gnu}/Linux systems, each memory range +-includes the object file which is mapped to that range, instead of the +-memory access rights to that range. ++Report the memory address space ranges accessible in the program. On ++Solaris and FreeBSD systems, each memory range includes information on ++whether the process has read, write, or execute access rights to each ++range. On @sc{gnu}/Linux and FreeBSD systems, each memory range ++includes the object file which is mapped to that range. + + @item info proc stat + @itemx info proc status + @cindex process detailed status information +-These subcommands are specific to @sc{gnu}/Linux systems. They show +-the process-related information, including the user ID and group ID; +-how many threads are there in the process; its virtual memory usage; +-the signals that are pending, blocked, and ignored; its TTY; its +-consumption of system and user time; its stack size; its @samp{nice} +-value; etc. For more information, see the @samp{proc} man page +-(type @kbd{man 5 proc} from your shell prompt). ++Show additional process-related information, including the user ID and ++group ID; virtual memory usage; the signals that are pending, blocked, ++and ignored; its TTY; its consumption of system and user time; its ++stack size; its @samp{nice} value; etc. These commands are supported ++on @sc{gnu}/Linux and FreeBSD. ++ ++For @sc{gnu}/Linux systems, see the @samp{proc} man page for more ++information (type @kbd{man 5 proc} from your shell prompt). ++ ++For FreeBSD systems, @code{info proc stat} is an alias for @code{info ++proc status}. + + @item info proc all + Show all the information about the process described under all of the Property changes on: head/devel/gdb/files/commit-2d97a5d9d3 ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/devel/gdb/files/commit-386a867618 =================================================================== --- head/devel/gdb/files/commit-386a867618 (nonexistent) +++ head/devel/gdb/files/commit-386a867618 (revision 464493) @@ -0,0 +1,115 @@ +commit 386a86761838df16c1459275d465ed21a1c35d9f +Author: John Baldwin +Date: Sat Mar 3 21:25:33 2018 -0800 + + Add a new debug knob for the FreeBSD native target. + + For now this just logs information about the state of the current LWP + for each STOPPED event in fbsd_wait(). + + gdb/ChangeLog: + + * NEWS (Changes since GDB 8.1): Add "set/show debug fbsd-nat". + * fbsd-nat.c (debug_fbsd_nat): New variable. + (show_fbsd_nat_debug): New function. + (fbsd_wait): Log LWP info if "debug_fbsd_nat" is enabled. + (_initialize_fbsd_nat): Add "fbsd-nat" debug boolean command. + + gdb/doc/ChangeLog: + + * gdb.texinfo (Debugging Output): Document "set/show debug + fbsd-nat". + +diff --git gdb/NEWS gdb/NEWS +index 1767cef920..867e268a2a 100644 +--- gdb/NEWS ++++ gdb/NEWS +@@ -6,6 +6,12 @@ + * 'info proc' now works on running processes on FreeBSD systems and core + files created on FreeBSD systems. + ++* New commands ++ ++set debug fbsd-nat ++show debug fbsd-nat ++ Control display of debugging info regarding the FreeBSD native target. ++ + *** Changes in GDB 8.1 + + * GDB now supports dynamically creating arbitrary register groups specified +diff --git gdb/doc/gdb.texinfo gdb/doc/gdb.texinfo +index ee7adc8df2..74e0fdb4a4 100644 +--- gdb/doc/gdb.texinfo ++++ gdb/doc/gdb.texinfo +@@ -24554,6 +24554,11 @@ Displays the current state of displaying debugging info about + Turns on or off debugging messages from the FreeBSD LWP debug support. + @item show debug fbsd-lwp + Show the current state of FreeBSD LWP debugging messages. ++@item set debug fbsd-nat ++@cindex FreeBSD native target debug messages ++Turns on or off debugging messages from the FreeBSD native target. ++@item show debug fbsd-nat ++Show the current state of FreeBSD native target debugging messages. + @item set debug frame + @cindex frame debugging info + Turns on or off display of @value{GDBN} frame debugging info. The +diff --git gdb/fbsd-nat.c gdb/fbsd-nat.c +index 3a216abf18..2516ac5552 100644 +--- gdb/fbsd-nat.c ++++ gdb/fbsd-nat.c +@@ -765,6 +765,7 @@ fbsd_xfer_partial (struct target_ops *ops, enum target_object object, + + #ifdef PT_LWPINFO + static int debug_fbsd_lwp; ++static int debug_fbsd_nat; + + static void (*super_resume) (struct target_ops *, + ptid_t, +@@ -782,6 +783,14 @@ show_fbsd_lwp_debug (struct ui_file *file, int from_tty, + fprintf_filtered (file, _("Debugging of FreeBSD lwp module is %s.\n"), value); + } + ++static void ++show_fbsd_nat_debug (struct ui_file *file, int from_tty, ++ struct cmd_list_element *c, const char *value) ++{ ++ fprintf_filtered (file, _("Debugging of FreeBSD native target is %s.\n"), ++ value); ++} ++ + /* + FreeBSD's first thread support was via a "reentrant" version of libc + (libc_r) that first shipped in 2.2.7. This library multiplexed all +@@ -1212,6 +1221,18 @@ fbsd_wait (struct target_ops *ops, + + wptid = ptid_build (pid, pl.pl_lwpid, 0); + ++ if (debug_fbsd_nat) ++ { ++ fprintf_unfiltered (gdb_stdlog, ++ "FNAT: stop for LWP %u event %d flags %#x\n", ++ pl.pl_lwpid, pl.pl_event, pl.pl_flags); ++ if (pl.pl_flags & PL_FLAG_SI) ++ fprintf_unfiltered (gdb_stdlog, ++ "FNAT: si_signo %u si_code %u\n", ++ pl.pl_siginfo.si_signo, ++ pl.pl_siginfo.si_code); ++ } ++ + #ifdef PT_LWP_EVENTS + if (pl.pl_flags & PL_FLAG_EXITED) + { +@@ -1569,5 +1590,13 @@ Enables printf debugging output."), + NULL, + &show_fbsd_lwp_debug, + &setdebuglist, &showdebuglist); ++ add_setshow_boolean_cmd ("fbsd-nat", class_maintenance, ++ &debug_fbsd_nat, _("\ ++Set debugging of FreeBSD native target."), _("\ ++Show debugging of FreeBSD native target."), _("\ ++Enables printf debugging output."), ++ NULL, ++ &show_fbsd_nat_debug, ++ &setdebuglist, &showdebuglist); + #endif + } Property changes on: head/devel/gdb/files/commit-386a867618 ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/devel/gdb/files/commit-7efba073e2 =================================================================== --- head/devel/gdb/files/commit-7efba073e2 (nonexistent) +++ head/devel/gdb/files/commit-7efba073e2 (revision 464493) @@ -0,0 +1,184 @@ +commit 7efba073e2b83803a47fd89e701fe60b98f2debc +Author: John Baldwin +Date: Sat Mar 3 21:25:33 2018 -0800 + + Use signal information to determine SIGTRAP type for FreeBSD. + + Use the signal code from siginfo_t to distinguish SIGTRAP events due + to trace traps (TRAP_TRACE) and software breakpoints (TRAP_BRKPT). + For software breakpoints, adjust the PC when the event is reported as + part of the API when supplying "stopped_by_sw_breakpoint". Currently + FreeBSD only supports hardware watchpoints and breakpoints on x86 + which are reported as trace traps. Signal information is not used on + MIPS and sparc64 kernels which do not reliably report TRAP_BRKPT for + software breakpoints. + + gdb/ChangeLog: + + * fbsd-nat.c: Include "inf-ptrace.h". + (USE_SIGTRAP_SIGINFO): Conditionally define. + [USE_SIGTRAP_SIGINFO] (fbsd_handle_debug_trap): New function. + (fbsd_wait) [USE_SIGTRAP_SIGINFO]: Call "fbsd_handle_debug_trap". + [USE_SIGTRAP_SIGINFO] (fbsd_stopped_by_sw_breakpoint): New + function. + [USE_SIGTRAP_SIGINFO] (fbsd_supports_stopped_by_sw_breakpoint): + Likewise. + [USE_SIGTRAP_SIGINFO] (fbsd_supports_stopped_by_hw_breakpoint): + Likewise. + (fbsd_nat_add_target) [USE_SIGTRAP_SIGINFO]: Set + "stopped_by_sw_breakpoint", "supports_stopped_by_sw_breakpoint", + "supports_stopped_by_hw_breakpoint" target methods. + +diff --git gdb/fbsd-nat.c gdb/fbsd-nat.c +index 2516ac5552..bea7f42c7e 100644 +--- gdb/fbsd-nat.c ++++ gdb/fbsd-nat.c +@@ -26,6 +26,7 @@ + #include "gdbcmd.h" + #include "gdbthread.h" + #include "gdb_wait.h" ++#include "inf-ptrace.h" + #include + #include + #include +@@ -45,6 +46,14 @@ + + #include + ++#ifdef TRAP_BRKPT ++/* MIPS does not set si_code for SIGTRAP. sparc64 reports ++ non-standard values in si_code for SIGTRAP. */ ++# if !defined(__mips__) && !defined(__sparc64__) ++# define USE_SIGTRAP_SIGINFO ++# endif ++#endif ++ + /* Return the name of a file that can be opened to get the symbols for + the child process identified by PID. */ + +@@ -1187,6 +1196,56 @@ fbsd_resume (struct target_ops *ops, + super_resume (ops, ptid, step, signo); + } + ++#ifdef USE_SIGTRAP_SIGINFO ++/* Handle breakpoint and trace traps reported via SIGTRAP. If the ++ trap was a breakpoint or trace trap that should be reported to the ++ core, return true. */ ++ ++static bool ++fbsd_handle_debug_trap (struct target_ops *ops, ptid_t ptid, ++ const struct ptrace_lwpinfo &pl) ++{ ++ ++ /* Ignore traps without valid siginfo or for signals other than ++ SIGTRAP. */ ++ if (! (pl.pl_flags & PL_FLAG_SI) || pl.pl_siginfo.si_signo != SIGTRAP) ++ return false; ++ ++ /* Trace traps are either a single step or a hardware watchpoint or ++ breakpoint. */ ++ if (pl.pl_siginfo.si_code == TRAP_TRACE) ++ { ++ if (debug_fbsd_nat) ++ fprintf_unfiltered (gdb_stdlog, ++ "FNAT: trace trap for LWP %ld\n", ptid.lwp ()); ++ return true; ++ } ++ ++ if (pl.pl_siginfo.si_code == TRAP_BRKPT) ++ { ++ /* Fixup PC for the software breakpoint. */ ++ struct regcache *regcache = get_thread_regcache (ptid); ++ struct gdbarch *gdbarch = regcache->arch (); ++ int decr_pc = gdbarch_decr_pc_after_break (gdbarch); ++ ++ if (debug_fbsd_nat) ++ fprintf_unfiltered (gdb_stdlog, ++ "FNAT: sw breakpoint trap for LWP %ld\n", ++ ptid.lwp ()); ++ if (decr_pc != 0) ++ { ++ CORE_ADDR pc; ++ ++ pc = regcache_read_pc (regcache); ++ regcache_write_pc (regcache, pc - decr_pc); ++ } ++ return true; ++ } ++ ++ return false; ++} ++#endif ++ + /* Wait for the child specified by PTID to do something. Return the + process ID of the child, or MINUS_ONE_PTID in case of error; store + the status in *OURSTATUS. */ +@@ -1372,6 +1431,11 @@ fbsd_wait (struct target_ops *ops, + } + #endif + ++#ifdef USE_SIGTRAP_SIGINFO ++ if (fbsd_handle_debug_trap (ops, wptid, pl)) ++ return wptid; ++#endif ++ + /* Note that PL_FLAG_SCE is set for any event reported while + a thread is executing a system call in the kernel. In + particular, signals that interrupt a sleep in a system +@@ -1410,6 +1474,42 @@ fbsd_wait (struct target_ops *ops, + } + } + ++#ifdef USE_SIGTRAP_SIGINFO ++/* Implement the "to_stopped_by_sw_breakpoint" target_ops method. */ ++ ++static int ++fbsd_stopped_by_sw_breakpoint (struct target_ops *ops) ++{ ++ struct ptrace_lwpinfo pl; ++ ++ if (ptrace (PT_LWPINFO, get_ptrace_pid (inferior_ptid), (caddr_t) &pl, ++ sizeof pl) == -1) ++ return 0; ++ ++ return ((pl.pl_flags & PL_FLAG_SI) ++ && pl.pl_siginfo.si_signo == SIGTRAP ++ && pl.pl_siginfo.si_code == TRAP_BRKPT); ++} ++ ++/* Implement the "to_supports_stopped_by_sw_breakpoint" target_ops ++ method. */ ++ ++static int ++fbsd_supports_stopped_by_sw_breakpoint (struct target_ops *ops) ++{ ++ return 1; ++} ++ ++/* Implement the "to_supports_stopped_by_hw_breakpoint" target_ops ++ method. */ ++ ++static int ++fbsd_supports_stopped_by_hw_breakpoint (struct target_ops *ops) ++{ ++ return ops->to_stopped_by_hw_breakpoint != NULL; ++} ++#endif ++ + #ifdef TDP_RFPPWAIT + /* Target hook for follow_fork. On entry and at return inferior_ptid is + the ptid of the followed inferior. */ +@@ -1560,6 +1660,13 @@ fbsd_nat_add_target (struct target_ops *t) + t->to_wait = fbsd_wait; + t->to_post_startup_inferior = fbsd_post_startup_inferior; + t->to_post_attach = fbsd_post_attach; ++#ifdef USE_SIGTRAP_SIGINFO ++ t->to_stopped_by_sw_breakpoint = fbsd_stopped_by_sw_breakpoint; ++ t->to_supports_stopped_by_sw_breakpoint ++ = fbsd_supports_stopped_by_sw_breakpoint; ++ t->to_supports_stopped_by_hw_breakpoint ++ = fbsd_supports_stopped_by_hw_breakpoint; ++#endif + #ifdef TDP_RFPPWAIT + t->to_follow_fork = fbsd_follow_fork; + t->to_insert_fork_catchpoint = fbsd_insert_fork_catchpoint; Property changes on: head/devel/gdb/files/commit-7efba073e2 ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/devel/gdb/files/commit-906b4aac4c =================================================================== --- head/devel/gdb/files/commit-906b4aac4c (nonexistent) +++ head/devel/gdb/files/commit-906b4aac4c (revision 464493) @@ -0,0 +1,29 @@ +commit 906b4aac4c1d3cdb2b1ea7105133cfbe25e04e14 +Author: John Baldwin +Date: Fri Jan 12 12:05:50 2018 -0800 + + Use the correct value for the offset of 'kve_protection'. + + I had forgotten to convert the decimal output of 'ptype /o' to hex + (but still used a 0x prefix) for the KVE_PROTECTION constant defining + the offset of the 'kve_protection' field in the 'kinfo_vmentry' + structure. This resulted in garbage permissions for entries in 'info + proc mappings' for FreeBSD core dumps. + + gdb/ChangeLog: + + * fbsd-tdep.c (KVE_PROTECTION): Correct value. + +diff --git gdb/fbsd-tdep.c gdb/fbsd-tdep.c +index 8aa0243d54..e49a9aff09 100644 +--- gdb/fbsd-tdep.c ++++ gdb/fbsd-tdep.c +@@ -62,7 +62,7 @@ + #define KVE_END 0x10 + #define KVE_OFFSET 0x18 + #define KVE_FLAGS 0x2c +-#define KVE_PROTECTION 0x56 ++#define KVE_PROTECTION 0x38 + #define KVE_PATH 0x88 + + /* Flags in the 'kve_protection' field in struct kinfo_vmentry. These Property changes on: head/devel/gdb/files/commit-906b4aac4c ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/devel/gdb/files/commit-92fce24de2 =================================================================== --- head/devel/gdb/files/commit-92fce24de2 (nonexistent) +++ head/devel/gdb/files/commit-92fce24de2 (revision 464493) @@ -0,0 +1,548 @@ +commit 92fce24de299a8b9a9a1c0c6b98e0e9c1656f99c +Author: John Baldwin +Date: Tue Jan 9 13:35:17 2018 -0800 + + Support 'info proc' for native FreeBSD processes. + + - Command line arguments are fetched via the kern.proc.args. + sysctl. + - The 'cwd' and 'exe' values are obtained from the per-process + file descriptor table returned by kinfo_getfile() from libutil. + - 'mappings' is implemented by walking the array of VM map entries + returned by kinfo_getvmmap() from libutil. + - 'status' output is generated by outputting fields from the structure + returned by the kern.proc.pid. sysctl. + - 'stat' is aliased to 'status'. + + gdb/ChangeLog: + + * configure.ac: Check for kinfo_getfile in libutil. + * configure: Regenerate. + * config.in: Regenerate. + * fbsd-nat.c: Include "fbsd-tdep.h". + (fbsd_fetch_cmdline): New. + (fbsd_fetch_kinfo_proc): Move earlier and change to return a bool + rather than calling error. + (fbsd_info_proc): New. + (fbsd_thread_name): Report error if fbsd_fetch_kinfo_proc fails. + (fbsd_wait): Report warning if fbsd_fetch_kinfo_proc fails. + (fbsd_nat_add_target): Set "to_info_proc" to "fbsd_info_proc". + +diff --git gdb/config.in gdb/config.in +index 1d11a97080..ad2cc1754e 100644 +--- gdb/config.in ++++ gdb/config.in +@@ -219,6 +219,9 @@ + /* Define to 1 if you have the header file. */ + #undef HAVE_INTTYPES_H + ++/* Define to 1 if your system has the kinfo_getfile function. */ ++#undef HAVE_KINFO_GETFILE ++ + /* Define to 1 if your system has the kinfo_getvmmap function. */ + #undef HAVE_KINFO_GETVMMAP + +diff --git gdb/configure gdb/configure +index db610f32fc..68b9aad02d 100755 +--- gdb/configure ++++ gdb/configure +@@ -7927,6 +7927,66 @@ $as_echo "#define HAVE_KINFO_GETVMMAP 1" >>confdefs.h + fi + + ++# fbsd-nat.c can also use kinfo_getfile. ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing kinfo_getfile" >&5 ++$as_echo_n "checking for library containing kinfo_getfile... " >&6; } ++if test "${ac_cv_search_kinfo_getfile+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 kinfo_getfile (); ++int ++main () ++{ ++return kinfo_getfile (); ++ ; ++ return 0; ++} ++_ACEOF ++for ac_lib in '' util util-freebsd; 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_kinfo_getfile=$ac_res ++fi ++rm -f core conftest.err conftest.$ac_objext \ ++ conftest$ac_exeext ++ if test "${ac_cv_search_kinfo_getfile+set}" = set; then : ++ break ++fi ++done ++if test "${ac_cv_search_kinfo_getfile+set}" = set; then : ++ ++else ++ ac_cv_search_kinfo_getfile=no ++fi ++rm conftest.$ac_ext ++LIBS=$ac_func_search_save_LIBS ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_kinfo_getfile" >&5 ++$as_echo "$ac_cv_search_kinfo_getfile" >&6; } ++ac_res=$ac_cv_search_kinfo_getfile ++if test "$ac_res" != no; then : ++ test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" ++ ++$as_echo "#define HAVE_KINFO_GETFILE 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 3db44ae758..551afc727e 100644 +--- gdb/configure.ac ++++ gdb/configure.ac +@@ -523,6 +523,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. ])]) + ++# fbsd-nat.c can also use kinfo_getfile. ++AC_SEARCH_LIBS(kinfo_getfile, util util-freebsd, ++ [AC_DEFINE(HAVE_KINFO_GETFILE, 1, ++ [Define to 1 if your system has the kinfo_getfile function. ])]) ++ + AM_ICONV + + # GDB may fork/exec the iconv program to get the list of supported character +diff --git gdb/fbsd-nat.c gdb/fbsd-nat.c +index 81f8e27a2d..b352418813 100644 +--- gdb/fbsd-nat.c ++++ gdb/fbsd-nat.c +@@ -32,14 +32,16 @@ + #include + #include + #include +-#ifdef HAVE_KINFO_GETVMMAP ++#if defined(HAVE_KINFO_GETFILE) || defined(HAVE_KINFO_GETVMMAP) + #include +-#else ++#endif ++#if !defined(HAVE_KINFO_GETVMMAP) + #include "filestuff.h" + #endif + + #include "elf-bfd.h" + #include "fbsd-nat.h" ++#include "fbsd-tdep.h" + + #include + +@@ -205,6 +207,331 @@ fbsd_find_memory_regions (struct target_ops *self, + } + #endif + ++/* Fetch the command line for a running process. */ ++ ++static gdb::unique_xmalloc_ptr ++fbsd_fetch_cmdline (pid_t pid) ++{ ++ size_t len; ++ int mib[4]; ++ ++ len = 0; ++ mib[0] = CTL_KERN; ++ mib[1] = KERN_PROC; ++ mib[2] = KERN_PROC_ARGS; ++ mib[3] = pid; ++ if (sysctl (mib, 4, NULL, &len, NULL, 0) == -1) ++ return nullptr; ++ ++ if (len == 0) ++ return nullptr; ++ ++ gdb::unique_xmalloc_ptr cmdline ((char *) xmalloc (len)); ++ if (sysctl (mib, 4, cmdline.get (), &len, NULL, 0) == -1) ++ return nullptr; ++ ++ return cmdline; ++} ++ ++/* Fetch the external variant of the kernel's internal process ++ structure for the process PID into KP. */ ++ ++static bool ++fbsd_fetch_kinfo_proc (pid_t pid, struct kinfo_proc *kp) ++{ ++ size_t len; ++ int mib[4]; ++ ++ len = sizeof *kp; ++ mib[0] = CTL_KERN; ++ mib[1] = KERN_PROC; ++ mib[2] = KERN_PROC_PID; ++ mib[3] = pid; ++ return (sysctl (mib, 4, kp, &len, NULL, 0) == 0); ++} ++ ++/* Implement the "to_info_proc target_ops" method. */ ++ ++static void ++fbsd_info_proc (struct target_ops *ops, const char *args, ++ enum info_proc_what what) ++{ ++#ifdef HAVE_KINFO_GETFILE ++ gdb::unique_xmalloc_ptr fdtbl; ++ int nfd = 0; ++#endif ++ struct kinfo_proc kp; ++ char *tmp; ++ pid_t pid; ++ bool do_cmdline = false; ++ bool do_cwd = false; ++ bool do_exe = false; ++#ifdef HAVE_KINFO_GETVMMAP ++ bool do_mappings = false; ++#endif ++ bool do_status = false; ++ ++ switch (what) ++ { ++ case IP_MINIMAL: ++ do_cmdline = true; ++ do_cwd = true; ++ do_exe = true; ++ break; ++#ifdef HAVE_KINFO_GETVMMAP ++ case IP_MAPPINGS: ++ do_mappings = true; ++ break; ++#endif ++ case IP_STATUS: ++ case IP_STAT: ++ do_status = true; ++ break; ++ case IP_CMDLINE: ++ do_cmdline = true; ++ break; ++ case IP_EXE: ++ do_exe = true; ++ break; ++ case IP_CWD: ++ do_cwd = true; ++ break; ++ case IP_ALL: ++ do_cmdline = true; ++ do_cwd = true; ++ do_exe = true; ++#ifdef HAVE_KINFO_GETVMMAP ++ do_mappings = true; ++#endif ++ do_status = true; ++ break; ++ default: ++ error (_("Not supported on this target.")); ++ } ++ ++ gdb_argv built_argv (args); ++ if (built_argv.count () == 0) ++ { ++ pid = ptid_get_pid (inferior_ptid); ++ if (pid == 0) ++ error (_("No current process: you must name one.")); ++ } ++ else if (built_argv.count () == 1 && isdigit (built_argv[0][0])) ++ pid = strtol (built_argv[0], NULL, 10); ++ else ++ error (_("Invalid arguments.")); ++ ++ printf_filtered (_("process %d\n"), pid); ++#ifdef HAVE_KINFO_GETFILE ++ if (do_cwd || do_exe) ++ fdtbl.reset (kinfo_getfile (pid, &nfd)); ++#endif ++ ++ if (do_cmdline) ++ { ++ gdb::unique_xmalloc_ptr cmdline = fbsd_fetch_cmdline (pid); ++ if (cmdline != nullptr) ++ printf_filtered ("cmdline = '%s'\n", cmdline.get ()); ++ else ++ warning (_("unable to fetch command line")); ++ } ++ if (do_cwd) ++ { ++ const char *cwd = NULL; ++#ifdef HAVE_KINFO_GETFILE ++ struct kinfo_file *kf = fdtbl.get (); ++ for (int i = 0; i < nfd; i++, kf++) ++ { ++ if (kf->kf_type == KF_TYPE_VNODE && kf->kf_fd == KF_FD_TYPE_CWD) ++ { ++ cwd = kf->kf_path; ++ break; ++ } ++ } ++#endif ++ if (cwd != NULL) ++ printf_filtered ("cwd = '%s'\n", cwd); ++ else ++ warning (_("unable to fetch current working directory")); ++ } ++ if (do_exe) ++ { ++ const char *exe = NULL; ++#ifdef HAVE_KINFO_GETFILE ++ struct kinfo_file *kf = fdtbl.get (); ++ for (int i = 0; i < nfd; i++, kf++) ++ { ++ if (kf->kf_type == KF_TYPE_VNODE && kf->kf_fd == KF_FD_TYPE_TEXT) ++ { ++ exe = kf->kf_path; ++ break; ++ } ++ } ++#endif ++ if (exe == NULL) ++ exe = fbsd_pid_to_exec_file (ops, pid); ++ if (exe != NULL) ++ printf_filtered ("exe = '%s'\n", exe); ++ else ++ warning (_("unable to fetch executable path name")); ++ } ++#ifdef HAVE_KINFO_GETVMMAP ++ if (do_mappings) ++ { ++ int nvment; ++ gdb::unique_xmalloc_ptr ++ vmentl (kinfo_getvmmap (pid, &nvment)); ++ ++ if (vmentl != nullptr) ++ { ++ printf_filtered (_("Mapped address spaces:\n\n")); ++#ifdef __LP64__ ++ printf_filtered (" %18s %18s %10s %10s %9s %s\n", ++ "Start Addr", ++ " End Addr", ++ " Size", " Offset", "Flags ", "File"); ++#else ++ printf_filtered ("\t%10s %10s %10s %10s %9s %s\n", ++ "Start Addr", ++ " End Addr", ++ " Size", " Offset", "Flags ", "File"); ++#endif ++ ++ struct kinfo_vmentry *kve = vmentl.get (); ++ for (int i = 0; i < nvment; i++, kve++) ++ { ++ ULONGEST start, end; ++ ++ start = kve->kve_start; ++ end = kve->kve_end; ++#ifdef __LP64__ ++ printf_filtered (" %18s %18s %10s %10s %9s %s\n", ++ hex_string (start), ++ hex_string (end), ++ hex_string (end - start), ++ hex_string (kve->kve_offset), ++ fbsd_vm_map_entry_flags (kve->kve_flags, ++ kve->kve_protection), ++ kve->kve_path); ++#else ++ printf_filtered ("\t%10s %10s %10s %10s %9s %s\n", ++ hex_string (start), ++ hex_string (end), ++ hex_string (end - start), ++ hex_string (kve->kve_offset), ++ fbsd_vm_map_entry_flags (kve->kve_flags, ++ kve->kve_protection), ++ kve->kve_path); ++#endif ++ } ++ } ++ else ++ warning (_("unable to fetch virtual memory map")); ++ } ++#endif ++ if (do_status) ++ { ++ if (!fbsd_fetch_kinfo_proc (pid, &kp)) ++ warning (_("Failed to fetch process information")); ++ else ++ { ++ const char *state; ++ int pgtok; ++ ++ printf_filtered ("Name: %s\n", kp.ki_comm); ++ switch (kp.ki_stat) ++ { ++ case SIDL: ++ state = "I (idle)"; ++ break; ++ case SRUN: ++ state = "R (running)"; ++ break; ++ case SSTOP: ++ state = "T (stopped)"; ++ break; ++ case SZOMB: ++ state = "Z (zombie)"; ++ break; ++ case SSLEEP: ++ state = "S (sleeping)"; ++ break; ++ case SWAIT: ++ state = "W (interrupt wait)"; ++ break; ++ case SLOCK: ++ state = "L (blocked on lock)"; ++ break; ++ default: ++ state = "? (unknown)"; ++ break; ++ } ++ printf_filtered ("State: %s\n", state); ++ printf_filtered ("Parent process: %d\n", kp.ki_ppid); ++ printf_filtered ("Process group: %d\n", kp.ki_pgid); ++ printf_filtered ("Session id: %d\n", kp.ki_sid); ++ printf_filtered ("TTY: %ju\n", (uintmax_t) kp.ki_tdev); ++ printf_filtered ("TTY owner process group: %d\n", kp.ki_tpgid); ++ printf_filtered ("User IDs (real, effective, saved): %d %d %d\n", ++ kp.ki_ruid, kp.ki_uid, kp.ki_svuid); ++ printf_filtered ("Group IDs (real, effective, saved): %d %d %d\n", ++ kp.ki_rgid, kp.ki_groups[0], kp.ki_svgid); ++ printf_filtered ("Groups: "); ++ for (int i = 0; i < kp.ki_ngroups; i++) ++ printf_filtered ("%d ", kp.ki_groups[i]); ++ printf_filtered ("\n"); ++ printf_filtered ("Minor faults (no memory page): %ld\n", ++ kp.ki_rusage.ru_minflt); ++ printf_filtered ("Minor faults, children: %ld\n", ++ kp.ki_rusage_ch.ru_minflt); ++ printf_filtered ("Major faults (memory page faults): %ld\n", ++ kp.ki_rusage.ru_majflt); ++ printf_filtered ("Major faults, children: %ld\n", ++ kp.ki_rusage_ch.ru_majflt); ++ printf_filtered ("utime: %jd.%06ld\n", ++ (intmax_t) kp.ki_rusage.ru_utime.tv_sec, ++ kp.ki_rusage.ru_utime.tv_usec); ++ printf_filtered ("stime: %jd.%06ld\n", ++ (intmax_t) kp.ki_rusage.ru_stime.tv_sec, ++ kp.ki_rusage.ru_stime.tv_usec); ++ printf_filtered ("utime, children: %jd.%06ld\n", ++ (intmax_t) kp.ki_rusage_ch.ru_utime.tv_sec, ++ kp.ki_rusage_ch.ru_utime.tv_usec); ++ printf_filtered ("stime, children: %jd.%06ld\n", ++ (intmax_t) kp.ki_rusage_ch.ru_stime.tv_sec, ++ kp.ki_rusage_ch.ru_stime.tv_usec); ++ printf_filtered ("'nice' value: %d\n", kp.ki_nice); ++ printf_filtered ("Start time: %jd.%06ld\n", kp.ki_start.tv_sec, ++ kp.ki_start.tv_usec); ++ pgtok = getpagesize () / 1024; ++ printf_filtered ("Virtual memory size: %ju kB\n", ++ (uintmax_t) kp.ki_size / 1024); ++ printf_filtered ("Data size: %ju kB\n", ++ (uintmax_t) kp.ki_dsize * pgtok); ++ printf_filtered ("Stack size: %ju kB\n", ++ (uintmax_t) kp.ki_ssize * pgtok); ++ printf_filtered ("Text size: %ju kB\n", ++ (uintmax_t) kp.ki_tsize * pgtok); ++ printf_filtered ("Resident set size: %ju kB\n", ++ (uintmax_t) kp.ki_rssize * pgtok); ++ printf_filtered ("Maximum RSS: %ju kB\n", ++ (uintmax_t) kp.ki_rusage.ru_maxrss); ++ printf_filtered ("Pending Signals: "); ++ for (int i = 0; i < _SIG_WORDS; i++) ++ printf_filtered ("%08x ", kp.ki_siglist.__bits[i]); ++ printf_filtered ("\n"); ++ printf_filtered ("Ignored Signals: "); ++ for (int i = 0; i < _SIG_WORDS; i++) ++ printf_filtered ("%08x ", kp.ki_sigignore.__bits[i]); ++ printf_filtered ("\n"); ++ printf_filtered ("Caught Signals: "); ++ for (int i = 0; i < _SIG_WORDS; i++) ++ printf_filtered ("%08x ", kp.ki_sigcatch.__bits[i]); ++ printf_filtered ("\n"); ++ } ++ } ++} ++ + #ifdef KERN_PROC_AUXV + static enum target_xfer_status (*super_xfer_partial) (struct target_ops *ops, + enum target_object object, +@@ -455,26 +782,6 @@ show_fbsd_lwp_debug (struct ui_file *file, int from_tty, + fprintf_filtered (file, _("Debugging of FreeBSD lwp module is %s.\n"), value); + } + +-#if defined(TDP_RFPPWAIT) || defined(HAVE_STRUCT_PTRACE_LWPINFO_PL_TDNAME) +-/* Fetch the external variant of the kernel's internal process +- structure for the process PID into KP. */ +- +-static void +-fbsd_fetch_kinfo_proc (pid_t pid, struct kinfo_proc *kp) +-{ +- size_t len; +- int mib[4]; +- +- len = sizeof *kp; +- mib[0] = CTL_KERN; +- mib[1] = KERN_PROC; +- mib[2] = KERN_PROC_PID; +- mib[3] = pid; +- if (sysctl (mib, 4, kp, &len, NULL, 0) == -1) +- perror_with_name (("sysctl")); +-} +-#endif +- + /* + FreeBSD's first thread support was via a "reentrant" version of libc + (libc_r) that first shipped in 2.2.7. This library multiplexed all +@@ -560,7 +867,8 @@ fbsd_thread_name (struct target_ops *self, struct thread_info *thr) + /* Note that ptrace_lwpinfo returns the process command in pl_tdname + if a name has not been set explicitly. Return a NULL name in + that case. */ +- fbsd_fetch_kinfo_proc (pid, &kp); ++ if (!fbsd_fetch_kinfo_proc (pid, &kp)) ++ perror_with_name (_("Failed to fetch process information")); + if (ptrace (PT_LWPINFO, lwp, (caddr_t) &pl, sizeof pl) == -1) + perror_with_name (("ptrace")); + if (strcmp (kp.ki_comm, pl.pl_tdname) == 0) +@@ -970,9 +1278,13 @@ fbsd_wait (struct target_ops *ops, + #ifndef PTRACE_VFORK + /* For vfork, the child process will have the P_PPWAIT + flag set. */ +- fbsd_fetch_kinfo_proc (child, &kp); +- if (kp.ki_flag & P_PPWAIT) +- ourstatus->kind = TARGET_WAITKIND_VFORKED; ++ if (fbsd_fetch_kinfo_proc (child, &kp)) ++ { ++ if (kp.ki_flag & P_PPWAIT) ++ ourstatus->kind = TARGET_WAITKIND_VFORKED; ++ } ++ else ++ warning (_("Failed to fetch process information")); + #endif + ourstatus->value.related_pid = child_ptid; + +@@ -1176,6 +1488,7 @@ fbsd_nat_add_target (struct target_ops *t) + { + t->to_pid_to_exec_file = fbsd_pid_to_exec_file; + t->to_find_memory_regions = fbsd_find_memory_regions; ++ t->to_info_proc = fbsd_info_proc; + #ifdef KERN_PROC_AUXV + super_xfer_partial = t->to_xfer_partial; + t->to_xfer_partial = fbsd_xfer_partial; Property changes on: head/devel/gdb/files/commit-92fce24de2 ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/devel/gdb/files/commit-b999e2038d =================================================================== --- head/devel/gdb/files/commit-b999e2038d (nonexistent) +++ head/devel/gdb/files/commit-b999e2038d (revision 464493) @@ -0,0 +1,32 @@ +commit b999e2038dbc54e2c8b1c390f8b8fe50d0f1d10a +Author: John Baldwin +Date: Tue Jan 9 13:35:17 2018 -0800 + + Don't return stale data from fbsd_pid_to_exec_file for kernel processes. + + For processes without an associated executable (such as kernel processes), + the kern.proc.pathname. system control node returns a length of zero + without modifying the user's buffer. Detect this case and return NULL + rather than the previous contents of the static buffer 'buf'. + + gdb/ChangeLog: + + * fbsd-nat.c (fbsd_pid_to_exec_file) [KERN_PROC_PATHNAME]: Return + NULL for an empty pathname. + +diff --git gdb/fbsd-nat.c gdb/fbsd-nat.c +index ec4eed9abe..d0aaf89145 100644 +--- gdb/fbsd-nat.c ++++ gdb/fbsd-nat.c +@@ -63,7 +63,10 @@ fbsd_pid_to_exec_file (struct target_ops *self, int pid) + mib[3] = pid; + buflen = sizeof buf; + if (sysctl (mib, 4, buf, &buflen, NULL, 0) == 0) +- return buf; ++ /* The kern.proc.pathname. sysctl returns a length of zero ++ for processes without an associated executable such as kernel ++ processes. */ ++ return buflen == 0 ? NULL : buf; + #endif + + xsnprintf (name, PATH_MAX, "/proc/%d/exe", pid); Property changes on: head/devel/gdb/files/commit-b999e2038d ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/devel/gdb/files/commit-d2176225dc =================================================================== --- head/devel/gdb/files/commit-d2176225dc (nonexistent) +++ head/devel/gdb/files/commit-d2176225dc (revision 464493) @@ -0,0 +1,725 @@ +commit d2176225dc982c22640215a0e611e997e8eeb030 +Author: John Baldwin +Date: Tue Jan 9 13:35:17 2018 -0800 + + Support 'info proc' for FreeBSD process core dumps. + + - Command line arguments are obtained from the pr_psargs[] array + saved in the NT_PRPSINFO note. + - The 'cwd' and 'exe' values are obtained from the per-process file + descriptor table stored in the NT_PROCSTAT_FILES core note. + - 'mappings' is implemented by walking the array of VM map entries + stored in the NT_PROCSTAT_VMMAP core note. + - 'status' output is generated by outputting fields from + the first structure stored in the NT_PROCSTAT_PROC core note. + - 'stat' is aliased to 'status'. + + gdb/ChangeLog: + + * fbsd-tdep.c (KVE_STRUCTSIZE, KVE_START, KVE_END, KVE_OFFSET) + (KVE_FLAGS, KVE_PROTECTION, KVE_PATH, KINFO_VME_PROT_READ) + (KINFO_VME_PROT_WRITE, KINFO_VME_PROT_EXEC, KINFO_VME_FLAG_COW) + (KINFO_VME_FLAG_NEEDS_COPY, KINFO_VME_FLAG_NOCOREDUMP) + (KINFO_VME_FLAG_SUPER, KINFO_VME_FLAG_GROWS_UP) + (KINFO_VME_FLAG_GROWS_DOWN, KF_STRUCTSIZE, KF_TYPE, KF_FD) + (KF_PATH, KINFO_FILE_TYPE_VNODE, KINFO_FILE_FD_TYPE_CWD) + (KINFO_FILE_FD_TYPE_TEXT, SIG_WORDS, struct kinfo_proc_layout) + (kinfo_proc_layout_32, kinfo_proc_layout_i386) + (kinfo_proc_layout_64, fbsd_vm_map_entry_flags) + (fbsd_core_info_proc_mappings, fbsd_core_vnode_path) + (fbsd_core_fetch_timeval, fbsd_print_sigset) + (fbsd_core_info_proc_status, fbsd_core_info_proc): New. + (fbsd_init_abi): Install gdbarch "core_info_proc" method. + * fbsd-tdep.h (fbsd_vm_map_entry_flags): New. + +diff --git gdb/fbsd-tdep.c gdb/fbsd-tdep.c +index ce17c672d9..8aa0243d54 100644 +--- gdb/fbsd-tdep.c ++++ gdb/fbsd-tdep.c +@@ -52,6 +52,228 @@ + #define SIZE64_SIGINFO_T 80 + #define SIZE32_SIGINFO_T 64 + ++/* Offsets in data structure used in NT_FREEBSD_PROCSTAT_VMMAP core ++ dump notes. See for the definition of struct ++ kinfo_vmentry. This data structure should have the same layout on ++ all architectures. */ ++ ++#define KVE_STRUCTSIZE 0x0 ++#define KVE_START 0x8 ++#define KVE_END 0x10 ++#define KVE_OFFSET 0x18 ++#define KVE_FLAGS 0x2c ++#define KVE_PROTECTION 0x56 ++#define KVE_PATH 0x88 ++ ++/* Flags in the 'kve_protection' field in struct kinfo_vmentry. These ++ match the KVME_PROT_* constants in . */ ++ ++#define KINFO_VME_PROT_READ 0x00000001 ++#define KINFO_VME_PROT_WRITE 0x00000002 ++#define KINFO_VME_PROT_EXEC 0x00000004 ++ ++/* Flags in the 'kve_flags' field in struct kinfo_vmentry. These ++ match the KVME_FLAG_* constants in . */ ++ ++#define KINFO_VME_FLAG_COW 0x00000001 ++#define KINFO_VME_FLAG_NEEDS_COPY 0x00000002 ++#define KINFO_VME_FLAG_NOCOREDUMP 0x00000004 ++#define KINFO_VME_FLAG_SUPER 0x00000008 ++#define KINFO_VME_FLAG_GROWS_UP 0x00000010 ++#define KINFO_VME_FLAG_GROWS_DOWN 0x00000020 ++ ++/* Offsets in data structure used in NT_FREEBSD_PROCSTAT_FILES core ++ dump notes. See for the definition of struct ++ kinfo_file. This data structure should have the same layout on all ++ architectures. */ ++ ++#define KF_STRUCTSIZE 0x0 ++#define KF_TYPE 0x4 ++#define KF_FD 0x8 ++#define KF_PATH 0x170 ++ ++/* Constants for the 'kf_type' field in struct kinfo_file. These ++ match the KF_TYPE_* constants in . */ ++ ++#define KINFO_FILE_TYPE_VNODE 1 ++ ++/* Special values for the 'kf_fd' field in struct kinfo_file. These ++ match the KF_FD_TYPE_* constants in . */ ++ ++#define KINFO_FILE_FD_TYPE_CWD -1 ++#define KINFO_FILE_FD_TYPE_TEXT -5 ++ ++/* Number of 32-bit words in a signal set. This matches _SIG_WORDS in ++ and is the same value on all architectures. */ ++ ++#define SIG_WORDS 4 ++ ++/* Offsets in data structure used in NT_FREEBSD_PROCSTAT_PROC core ++ dump notes. See for the definition of struct ++ kinfo_proc. This data structure has different layouts on different ++ architectures mostly due to ILP32 vs LP64. However, FreeBSD/i386 ++ uses a 32-bit time_t while all other architectures use a 64-bit ++ time_t. ++ ++ The core dump note actually contains one kinfo_proc structure for ++ each thread, but all of the process-wide data can be obtained from ++ the first structure. One result of this note's format is that some ++ of the process-wide status available in the native target method ++ from the kern.proc.pid. sysctl such as ki_stat and ki_siglist ++ is not available from a core dump. Instead, the per-thread data ++ structures contain the value of these fields for individual ++ threads. */ ++ ++struct kinfo_proc_layout ++{ ++ /* Offsets of struct kinfo_proc members. */ ++ int ki_layout; ++ int ki_pid; ++ int ki_ppid; ++ int ki_pgid; ++ int ki_tpgid; ++ int ki_sid; ++ int ki_tdev_freebsd11; ++ int ki_sigignore; ++ int ki_sigcatch; ++ int ki_uid; ++ int ki_ruid; ++ int ki_svuid; ++ int ki_rgid; ++ int ki_svgid; ++ int ki_ngroups; ++ int ki_groups; ++ int ki_size; ++ int ki_rssize; ++ int ki_tsize; ++ int ki_dsize; ++ int ki_ssize; ++ int ki_start; ++ int ki_nice; ++ int ki_comm; ++ int ki_tdev; ++ int ki_rusage; ++ int ki_rusage_ch; ++ ++ /* Offsets of struct rusage members. */ ++ int ru_utime; ++ int ru_stime; ++ int ru_maxrss; ++ int ru_minflt; ++ int ru_majflt; ++}; ++ ++const struct kinfo_proc_layout kinfo_proc_layout_32 = ++ { ++ .ki_layout = 0x4, ++ .ki_pid = 0x28, ++ .ki_ppid = 0x2c, ++ .ki_pgid = 0x30, ++ .ki_tpgid = 0x34, ++ .ki_sid = 0x38, ++ .ki_tdev_freebsd11 = 0x44, ++ .ki_sigignore = 0x68, ++ .ki_sigcatch = 0x78, ++ .ki_uid = 0x88, ++ .ki_ruid = 0x8c, ++ .ki_svuid = 0x90, ++ .ki_rgid = 0x94, ++ .ki_svgid = 0x98, ++ .ki_ngroups = 0x9c, ++ .ki_groups = 0xa0, ++ .ki_size = 0xe0, ++ .ki_rssize = 0xe4, ++ .ki_tsize = 0xec, ++ .ki_dsize = 0xf0, ++ .ki_ssize = 0xf4, ++ .ki_start = 0x118, ++ .ki_nice = 0x145, ++ .ki_comm = 0x17f, ++ .ki_tdev = 0x1f0, ++ .ki_rusage = 0x220, ++ .ki_rusage_ch = 0x278, ++ ++ .ru_utime = 0x0, ++ .ru_stime = 0x10, ++ .ru_maxrss = 0x20, ++ .ru_minflt = 0x30, ++ .ru_majflt = 0x34, ++ }; ++ ++const struct kinfo_proc_layout kinfo_proc_layout_i386 = ++ { ++ .ki_layout = 0x4, ++ .ki_pid = 0x28, ++ .ki_ppid = 0x2c, ++ .ki_pgid = 0x30, ++ .ki_tpgid = 0x34, ++ .ki_sid = 0x38, ++ .ki_tdev_freebsd11 = 0x44, ++ .ki_sigignore = 0x68, ++ .ki_sigcatch = 0x78, ++ .ki_uid = 0x88, ++ .ki_ruid = 0x8c, ++ .ki_svuid = 0x90, ++ .ki_rgid = 0x94, ++ .ki_svgid = 0x98, ++ .ki_ngroups = 0x9c, ++ .ki_groups = 0xa0, ++ .ki_size = 0xe0, ++ .ki_rssize = 0xe4, ++ .ki_tsize = 0xec, ++ .ki_dsize = 0xf0, ++ .ki_ssize = 0xf4, ++ .ki_start = 0x118, ++ .ki_nice = 0x135, ++ .ki_comm = 0x16f, ++ .ki_tdev = 0x1e0, ++ .ki_rusage = 0x210, ++ .ki_rusage_ch = 0x258, ++ ++ .ru_utime = 0x0, ++ .ru_stime = 0x8, ++ .ru_maxrss = 0x10, ++ .ru_minflt = 0x20, ++ .ru_majflt = 0x24, ++ }; ++ ++const struct kinfo_proc_layout kinfo_proc_layout_64 = ++ { ++ .ki_layout = 0x4, ++ .ki_pid = 0x48, ++ .ki_ppid = 0x4c, ++ .ki_pgid = 0x50, ++ .ki_tpgid = 0x54, ++ .ki_sid = 0x58, ++ .ki_tdev_freebsd11 = 0x64, ++ .ki_sigignore = 0x88, ++ .ki_sigcatch = 0x98, ++ .ki_uid = 0xa8, ++ .ki_ruid = 0xac, ++ .ki_svuid = 0xb0, ++ .ki_rgid = 0xb4, ++ .ki_svgid = 0xb8, ++ .ki_ngroups = 0xbc, ++ .ki_groups = 0xc0, ++ .ki_size = 0x100, ++ .ki_rssize = 0x108, ++ .ki_tsize = 0x118, ++ .ki_dsize = 0x120, ++ .ki_ssize = 0x128, ++ .ki_start = 0x150, ++ .ki_nice = 0x185, ++ .ki_comm = 0x1bf, ++ .ki_tdev = 0x230, ++ .ki_rusage = 0x260, ++ .ki_rusage_ch = 0x2f0, ++ ++ .ru_utime = 0x0, ++ .ru_stime = 0x10, ++ .ru_maxrss = 0x20, ++ .ru_minflt = 0x40, ++ .ru_majflt = 0x48, ++ }; ++ + static struct gdbarch_data *fbsd_gdbarch_data_handle; + + struct fbsd_gdbarch_data +@@ -367,6 +589,433 @@ fbsd_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size) + return note_data; + } + ++/* Helper function to generate mappings flags for a single VM map ++ entry in 'info proc mappings'. */ ++ ++const char * ++fbsd_vm_map_entry_flags (int kve_flags, int kve_protection) ++{ ++ static char vm_flags[9]; ++ ++ vm_flags[0] = (kve_protection & KINFO_VME_PROT_READ) ? 'r' : '-'; ++ vm_flags[1] = (kve_protection & KINFO_VME_PROT_WRITE) ? 'w' : '-'; ++ vm_flags[2] = (kve_protection & KINFO_VME_PROT_EXEC) ? 'x' : '-'; ++ vm_flags[3] = ' '; ++ vm_flags[4] = (kve_flags & KINFO_VME_FLAG_COW) ? 'C' : '-'; ++ vm_flags[5] = (kve_flags & KINFO_VME_FLAG_NEEDS_COPY) ? 'N' : '-'; ++ vm_flags[6] = (kve_flags & KINFO_VME_FLAG_SUPER) ? 'S' : '-'; ++ vm_flags[7] = (kve_flags & KINFO_VME_FLAG_GROWS_UP) ? 'U' ++ : (kve_flags & KINFO_VME_FLAG_GROWS_DOWN) ? 'D' : '-'; ++ vm_flags[8] = '\0'; ++ ++ return vm_flags; ++} ++ ++/* Implement "info proc mappings" for a corefile. */ ++ ++static void ++fbsd_core_info_proc_mappings (struct gdbarch *gdbarch) ++{ ++ asection *section; ++ unsigned char *descdata, *descend; ++ size_t note_size; ++ ++ section = bfd_get_section_by_name (core_bfd, ".note.freebsdcore.vmmap"); ++ if (section == NULL) ++ { ++ warning (_("unable to find mappings in core file")); ++ return; ++ } ++ ++ note_size = bfd_get_section_size (section); ++ if (note_size < 4) ++ error (_("malformed core note - too short for header")); ++ ++ gdb::def_vector contents (note_size); ++ if (!bfd_get_section_contents (core_bfd, section, contents.data (), ++ 0, note_size)) ++ error (_("could not get core note contents")); ++ ++ descdata = contents.data (); ++ descend = descdata + note_size; ++ ++ /* Skip over the structure size. */ ++ descdata += 4; ++ ++ printf_filtered (_("Mapped address spaces:\n\n")); ++ if (gdbarch_addr_bit (gdbarch) == 64) ++ { ++ printf_filtered (" %18s %18s %10s %10s %9s %s\n", ++ "Start Addr", ++ " End Addr", ++ " Size", " Offset", "Flags ", "File"); ++ } ++ else ++ { ++ printf_filtered ("\t%10s %10s %10s %10s %9s %s\n", ++ "Start Addr", ++ " End Addr", ++ " Size", " Offset", "Flags ", "File"); ++ } ++ ++ while (descdata + KVE_PATH < descend) ++ { ++ ULONGEST start, end, offset, flags, prot, structsize; ++ ++ structsize = bfd_get_32 (core_bfd, descdata + KVE_STRUCTSIZE); ++ if (structsize < KVE_PATH) ++ error (_("malformed core note - vmmap entry too small")); ++ ++ start = bfd_get_64 (core_bfd, descdata + KVE_START); ++ end = bfd_get_64 (core_bfd, descdata + KVE_END); ++ offset = bfd_get_64 (core_bfd, descdata + KVE_OFFSET); ++ flags = bfd_get_32 (core_bfd, descdata + KVE_FLAGS); ++ prot = bfd_get_32 (core_bfd, descdata + KVE_PROTECTION); ++ if (gdbarch_addr_bit (gdbarch) == 64) ++ { ++ printf_filtered (" %18s %18s %10s %10s %9s %s\n", ++ paddress (gdbarch, start), ++ paddress (gdbarch, end), ++ hex_string (end - start), ++ hex_string (offset), ++ fbsd_vm_map_entry_flags (flags, prot), ++ descdata + KVE_PATH); ++ } ++ else ++ { ++ printf_filtered ("\t%10s %10s %10s %10s %9s %s\n", ++ paddress (gdbarch, start), ++ paddress (gdbarch, end), ++ hex_string (end - start), ++ hex_string (offset), ++ fbsd_vm_map_entry_flags (flags, prot), ++ descdata + KVE_PATH); ++ } ++ ++ descdata += structsize; ++ } ++} ++ ++/* Fetch the pathname of a vnode for a single file descriptor from the ++ file table core note. */ ++ ++static gdb::unique_xmalloc_ptr ++fbsd_core_vnode_path (struct gdbarch *gdbarch, int fd) ++{ ++ asection *section; ++ unsigned char *descdata, *descend; ++ size_t note_size; ++ ++ section = bfd_get_section_by_name (core_bfd, ".note.freebsdcore.files"); ++ if (section == NULL) ++ return nullptr; ++ ++ note_size = bfd_get_section_size (section); ++ if (note_size < 4) ++ error (_("malformed core note - too short for header")); ++ ++ gdb::def_vector contents (note_size); ++ if (!bfd_get_section_contents (core_bfd, section, contents.data (), ++ 0, note_size)) ++ error (_("could not get core note contents")); ++ ++ descdata = contents.data (); ++ descend = descdata + note_size; ++ ++ /* Skip over the structure size. */ ++ descdata += 4; ++ ++ while (descdata + KVE_PATH < descend) ++ { ++ ULONGEST structsize; ++ ++ structsize = bfd_get_32 (core_bfd, descdata + KF_STRUCTSIZE); ++ if (structsize < KVE_PATH) ++ error (_("malformed core note - vmmap entry too small")); ++ ++ if (bfd_get_32 (core_bfd, descdata + KF_TYPE) == KINFO_FILE_TYPE_VNODE ++ && bfd_get_signed_32 (core_bfd, descdata + KF_FD) == fd) ++ { ++ char *path = (char *) descdata + KF_PATH; ++ return gdb::unique_xmalloc_ptr (xstrdup (path)); ++ } ++ ++ descdata += structsize; ++ } ++ return nullptr; ++} ++ ++/* Helper function to read a struct timeval. */ ++ ++static void ++fbsd_core_fetch_timeval (struct gdbarch *gdbarch, unsigned char *data, ++ LONGEST &sec, ULONGEST &usec) ++{ ++ if (gdbarch_addr_bit (gdbarch) == 64) ++ { ++ sec = bfd_get_signed_64 (core_bfd, data); ++ usec = bfd_get_64 (core_bfd, data + 8); ++ } ++ else if (bfd_get_arch (core_bfd) == bfd_arch_i386) ++ { ++ sec = bfd_get_signed_32 (core_bfd, data); ++ usec = bfd_get_32 (core_bfd, data + 4); ++ } ++ else ++ { ++ sec = bfd_get_signed_64 (core_bfd, data); ++ usec = bfd_get_32 (core_bfd, data + 8); ++ } ++} ++ ++/* Print out the contents of a signal set. */ ++ ++static void ++fbsd_print_sigset (const char *descr, unsigned char *sigset) ++{ ++ printf_filtered ("%s: ", descr); ++ for (int i = 0; i < SIG_WORDS; i++) ++ printf_filtered ("%08x ", ++ (unsigned int) bfd_get_32 (core_bfd, sigset + i * 4)); ++ printf_filtered ("\n"); ++} ++ ++/* Implement "info proc status" for a corefile. */ ++ ++static void ++fbsd_core_info_proc_status (struct gdbarch *gdbarch) ++{ ++ const struct kinfo_proc_layout *kp; ++ asection *section; ++ const char *state; ++ unsigned char *descdata; ++ int addr_bit, long_bit; ++ size_t note_size; ++ ULONGEST value; ++ LONGEST sec; ++ ++ section = bfd_get_section_by_name (core_bfd, ".note.freebsdcore.proc"); ++ if (section == NULL) ++ { ++ warning (_("unable to find process info in core file")); ++ return; ++ } ++ ++ addr_bit = gdbarch_addr_bit (gdbarch); ++ if (addr_bit == 64) ++ kp = &kinfo_proc_layout_64; ++ else if (bfd_get_arch (core_bfd) == bfd_arch_i386) ++ kp = &kinfo_proc_layout_i386; ++ else ++ kp = &kinfo_proc_layout_32; ++ long_bit = gdbarch_long_bit (gdbarch); ++ ++ /* ++ * Ensure that the note is large enough for all of the fields fetched ++ * by this function. In particular, the note must contain the 32-bit ++ * structure size, then it must be long enough to access the last ++ * field used (ki_rusage_ch.ru_majflt) which is the size of a long. ++ */ ++ note_size = bfd_get_section_size (section); ++ if (note_size < (4 + kp->ki_rusage_ch + kp->ru_majflt ++ + long_bit / TARGET_CHAR_BIT)) ++ error (_("malformed core note - too short")); ++ ++ gdb::def_vector contents (note_size); ++ if (!bfd_get_section_contents (core_bfd, section, contents.data (), ++ 0, note_size)) ++ error (_("could not get core note contents")); ++ ++ descdata = contents.data (); ++ ++ /* Skip over the structure size. */ ++ descdata += 4; ++ ++ /* Verify 'ki_layout' is 0. */ ++ if (bfd_get_32 (core_bfd, descdata + kp->ki_layout) != 0) ++ { ++ warning (_("unsupported process information in core file")); ++ return; ++ } ++ ++ printf_filtered ("Name: %.19s\n", descdata + kp->ki_comm); ++ printf_filtered ("Process ID: %s\n", ++ pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_pid))); ++ printf_filtered ("Parent process: %s\n", ++ pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_ppid))); ++ printf_filtered ("Process group: %s\n", ++ pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_pgid))); ++ printf_filtered ("Session id: %s\n", ++ pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_sid))); ++ ++ /* FreeBSD 12.0 and later store a 64-bit dev_t at 'ki_tdev'. Older ++ kernels store a 32-bit dev_t at 'ki_tdev_freebsd11'. In older ++ kernels the 64-bit 'ki_tdev' field is in a reserved section of ++ the structure that is cleared to zero. Assume that a zero value ++ in ki_tdev indicates a core dump from an older kernel and use the ++ value in 'ki_tdev_freebsd11' instead. */ ++ value = bfd_get_64 (core_bfd, descdata + kp->ki_tdev); ++ if (value == 0) ++ value = bfd_get_32 (core_bfd, descdata + kp->ki_tdev_freebsd11); ++ printf_filtered ("TTY: %s\n", pulongest (value)); ++ printf_filtered ("TTY owner process group: %s\n", ++ pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_tpgid))); ++ printf_filtered ("User IDs (real, effective, saved): %s %s %s\n", ++ pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_ruid)), ++ pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_uid)), ++ pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_svuid))); ++ printf_filtered ("Group IDs (real, effective, saved): %s %s %s\n", ++ pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_rgid)), ++ pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_groups)), ++ pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_svgid))); ++ printf_filtered ("Groups: "); ++ uint16_t ngroups = bfd_get_16 (core_bfd, descdata + kp->ki_ngroups); ++ for (int i = 0; i < ngroups; i++) ++ printf_filtered ("%s ", ++ pulongest (bfd_get_32 (core_bfd, ++ descdata + kp->ki_groups + i * 4))); ++ printf_filtered ("\n"); ++ value = bfd_get (long_bit, core_bfd, ++ descdata + kp->ki_rusage + kp->ru_minflt); ++ printf_filtered ("Minor faults (no memory page): %s\n", pulongest (value)); ++ value = bfd_get (long_bit, core_bfd, ++ descdata + kp->ki_rusage_ch + kp->ru_minflt); ++ printf_filtered ("Minor faults, children: %s\n", pulongest (value)); ++ value = bfd_get (long_bit, core_bfd, ++ descdata + kp->ki_rusage + kp->ru_majflt); ++ printf_filtered ("Major faults (memory page faults): %s\n", ++ pulongest (value)); ++ value = bfd_get (long_bit, core_bfd, ++ descdata + kp->ki_rusage_ch + kp->ru_majflt); ++ printf_filtered ("Major faults, children: %s\n", pulongest (value)); ++ fbsd_core_fetch_timeval (gdbarch, ++ descdata + kp->ki_rusage + kp->ru_utime, ++ sec, value); ++ printf_filtered ("utime: %s.%06d\n", plongest (sec), (int) value); ++ fbsd_core_fetch_timeval (gdbarch, ++ descdata + kp->ki_rusage + kp->ru_stime, ++ sec, value); ++ printf_filtered ("stime: %s.%06d\n", plongest (sec), (int) value); ++ fbsd_core_fetch_timeval (gdbarch, ++ descdata + kp->ki_rusage_ch + kp->ru_utime, ++ sec, value); ++ printf_filtered ("utime, children: %s.%06d\n", plongest (sec), (int) value); ++ fbsd_core_fetch_timeval (gdbarch, ++ descdata + kp->ki_rusage_ch + kp->ru_stime, ++ sec, value); ++ printf_filtered ("stime, children: %s.%06d\n", plongest (sec), (int) value); ++ printf_filtered ("'nice' value: %d\n", ++ bfd_get_signed_8 (core_bfd, descdata + kp->ki_nice)); ++ fbsd_core_fetch_timeval (gdbarch, descdata + kp->ki_start, sec, value); ++ printf_filtered ("Start time: %s.%06d\n", plongest (sec), (int) value); ++ printf_filtered ("Virtual memory size: %s kB\n", ++ pulongest (bfd_get (addr_bit, core_bfd, ++ descdata + kp->ki_size) / 1024)); ++ printf_filtered ("Data size: %s pages\n", ++ pulongest (bfd_get (addr_bit, core_bfd, ++ descdata + kp->ki_dsize))); ++ printf_filtered ("Stack size: %s pages\n", ++ pulongest (bfd_get (addr_bit, core_bfd, ++ descdata + kp->ki_ssize))); ++ printf_filtered ("Text size: %s pages\n", ++ pulongest (bfd_get (addr_bit, core_bfd, ++ descdata + kp->ki_tsize))); ++ printf_filtered ("Resident set size: %s pages\n", ++ pulongest (bfd_get (addr_bit, core_bfd, ++ descdata + kp->ki_rssize))); ++ printf_filtered ("Maximum RSS: %s pages\n", ++ pulongest (bfd_get (long_bit, core_bfd, ++ descdata + kp->ki_rusage ++ + kp->ru_maxrss))); ++ fbsd_print_sigset ("Ignored Signals", descdata + kp->ki_sigignore); ++ fbsd_print_sigset ("Caught Signals", descdata + kp->ki_sigcatch); ++} ++ ++/* Implement the "core_info_proc" gdbarch method. */ ++ ++static void ++fbsd_core_info_proc (struct gdbarch *gdbarch, const char *args, ++ enum info_proc_what what) ++{ ++ bool do_cmdline = false; ++ bool do_cwd = false; ++ bool do_exe = false; ++ bool do_mappings = false; ++ bool do_status = false; ++ int pid; ++ ++ switch (what) ++ { ++ case IP_MINIMAL: ++ do_cmdline = true; ++ do_cwd = true; ++ do_exe = true; ++ break; ++ case IP_MAPPINGS: ++ do_mappings = true; ++ break; ++ case IP_STATUS: ++ case IP_STAT: ++ do_status = true; ++ break; ++ case IP_CMDLINE: ++ do_cmdline = true; ++ break; ++ case IP_EXE: ++ do_exe = true; ++ break; ++ case IP_CWD: ++ do_cwd = true; ++ break; ++ case IP_ALL: ++ do_cmdline = true; ++ do_cwd = true; ++ do_exe = true; ++ do_mappings = true; ++ do_status = true; ++ break; ++ default: ++ return; ++ } ++ ++ pid = bfd_core_file_pid (core_bfd); ++ if (pid != 0) ++ printf_filtered (_("process %d\n"), pid); ++ ++ if (do_cmdline) ++ { ++ const char *cmdline; ++ ++ cmdline = bfd_core_file_failing_command (core_bfd); ++ if (cmdline) ++ printf_filtered ("cmdline = '%s'\n", cmdline); ++ else ++ warning (_("Command line unavailable")); ++ } ++ if (do_cwd) ++ { ++ gdb::unique_xmalloc_ptr cwd = ++ fbsd_core_vnode_path (gdbarch, KINFO_FILE_FD_TYPE_CWD); ++ if (cwd) ++ printf_filtered ("cwd = '%s'\n", cwd.get ()); ++ else ++ warning (_("unable to read current working directory")); ++ } ++ if (do_exe) ++ { ++ gdb::unique_xmalloc_ptr exe = ++ fbsd_core_vnode_path (gdbarch, KINFO_FILE_FD_TYPE_TEXT); ++ if (exe) ++ printf_filtered ("exe = '%s'\n", exe.get ()); ++ else ++ warning (_("unable to read executable path name")); ++ } ++ if (do_mappings) ++ fbsd_core_info_proc_mappings (gdbarch); ++ if (do_status) ++ fbsd_core_info_proc_status (gdbarch); ++} ++ + /* Print descriptions of FreeBSD-specific AUXV entries to FILE. */ + + static void +@@ -519,6 +1168,7 @@ fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) + set_gdbarch_core_thread_name (gdbarch, fbsd_core_thread_name); + set_gdbarch_core_xfer_siginfo (gdbarch, fbsd_core_xfer_siginfo); + set_gdbarch_make_corefile_notes (gdbarch, fbsd_make_corefile_notes); ++ set_gdbarch_core_info_proc (gdbarch, fbsd_core_info_proc); + set_gdbarch_print_auxv_entry (gdbarch, fbsd_print_auxv_entry); + set_gdbarch_get_siginfo_type (gdbarch, fbsd_get_siginfo_type); + +diff --git gdb/fbsd-tdep.h gdb/fbsd-tdep.h +index 9769903dec..0b293e5a25 100644 +--- gdb/fbsd-tdep.h ++++ gdb/fbsd-tdep.h +@@ -22,4 +22,11 @@ + + extern void fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch); + ++/* Helper function to generate mappings flags for a single VM map ++ entry in 'info proc mappings'. The KVE_FLAGS and KVE_PROTECTION ++ parameters should contain the values of the corresponding fields in ++ a 'struct kinfo_vmentry'. */ ++ ++extern const char *fbsd_vm_map_entry_flags (int kve_flags, int kve_protection); ++ + #endif /* fbsd-tdep.h */ Property changes on: head/devel/gdb/files/commit-d2176225dc ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/devel/gdb/files/commit-f169cfdc08 =================================================================== --- head/devel/gdb/files/commit-f169cfdc08 (nonexistent) +++ head/devel/gdb/files/commit-f169cfdc08 (revision 464493) @@ -0,0 +1,84 @@ +commit f169cfdc08761a3d9fcd587ad8661102672403ec +Author: John Baldwin +Date: Tue Oct 24 21:06:00 2017 -0700 + + Workaround a FreeBSD ptrace() bug with clearing thread events. + + When multiple threads within a process wish to report STOPPED events + from wait(), the kernel picks one thread event as the thread event to + report. The chosen thread event is retrieved via PT_LWPINFO by + passing the process ID as the request pid. If multiple events are + pending, then the subsequent wait() after resuming a process will + report another STOPPED event after resuming the process to handle the + next thread event and so on. + + A single thread event is cleared as a side effect of resuming the + process with PT_CONTINUE, PT_STEP, etc. In older kernels, however, + the request pid was used to select which thread's event was cleared + rather than always clearing the event that was just reported. To + avoid clearing the event of the wrong LWP, always pass the process ID + instead of an LWP ID to PT_CONTINUE or PT_SYSCALL. + + In the case of stepping, the process ID cannot be used with PT_STEP + since it would step the thread that reported an event which may not be + the thread indicated by PTID. For stepping, use PT_SETSTEP to enable + stepping on the desired thread before resuming the process via + PT_CONTINUE instead of using PT_STEP. + + This manifested as a failure in the + gdb.threads/continue-pending-status.exp test. Specifically, if thread + 2 reported a breakpoint and the test thus switched to thread 3 before + continuing, thread 3's event (if any) was discarded and thread 2's + breakpoint remained pending and was reported a second time as a + duplicate event. As a result, the PC was decremented twice for the + same breakpoint resulting in an illegal instruction fault on x86. + + gdb/ChangeLog: + + * fbsd-nat.c (fbsd_resume): Use PT_SETSTEP for stepping and a + wildcard process pid for super_resume for kernels with a + specific bug. + +diff --git gdb/fbsd-nat.c gdb/fbsd-nat.c +index b352418813..3a216abf18 100644 +--- gdb/fbsd-nat.c ++++ gdb/fbsd-nat.c +@@ -1143,6 +1143,38 @@ fbsd_resume (struct target_ops *ops, + } + ptid = inferior_ptid; + } ++ ++#if __FreeBSD_version < 1200052 ++ /* When multiple threads within a process wish to report STOPPED ++ events from wait(), the kernel picks one thread event as the ++ thread event to report. The chosen thread event is retrieved via ++ PT_LWPINFO by passing the process ID as the request pid. If ++ multiple events are pending, then the subsequent wait() after ++ resuming a process will report another STOPPED event after ++ resuming the process to handle the next thread event and so on. ++ ++ A single thread event is cleared as a side effect of resuming the ++ process with PT_CONTINUE, PT_STEP, etc. In older kernels, ++ however, the request pid was used to select which thread's event ++ was cleared rather than always clearing the event that was just ++ reported. To avoid clearing the event of the wrong LWP, always ++ pass the process ID instead of an LWP ID to PT_CONTINUE or ++ PT_SYSCALL. ++ ++ In the case of stepping, the process ID cannot be used with ++ PT_STEP since it would step the thread that reported an event ++ which may not be the thread indicated by PTID. For stepping, use ++ PT_SETSTEP to enable stepping on the desired thread before ++ resuming the process via PT_CONTINUE instead of using ++ PT_STEP. */ ++ if (step) ++ { ++ if (ptrace (PT_SETSTEP, get_ptrace_pid (ptid), NULL, 0) == -1) ++ perror_with_name (("ptrace")); ++ step = 0; ++ } ++ ptid = ptid_t (ptid.pid ()); ++#endif + super_resume (ops, ptid, step, signo); + } + Property changes on: head/devel/gdb/files/commit-f169cfdc08 ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/devel/gdb/files/extrapatch-kgdb =================================================================== --- head/devel/gdb/files/extrapatch-kgdb (revision 464492) +++ head/devel/gdb/files/extrapatch-kgdb (revision 464493) @@ -1,416 +1,424 @@ diff --git gdb/Makefile.in gdb/Makefile.in -index cf59ae7143..0dd72d35d1 100644 +index 17b71c6e7c..282522187b 100644 --- gdb/Makefile.in +++ gdb/Makefile.in -@@ -227,7 +227,8 @@ INCGNU = -I$(srcdir)/gnulib/import -I$(GNULIB_BUILDDIR)/import +@@ -230,7 +230,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@ +@@ -629,6 +630,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 = \ + aarch64-newlib-tdep.o \ +@@ -642,6 +644,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 = \ +@@ -656,6 +659,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 = \ +@@ -684,6 +688,8 @@ 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 = \ +@@ -700,6 +706,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 = \ +@@ -724,6 +731,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 = \ +@@ -741,6 +749,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 = \ +@@ -1610,7 +1619,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) +@@ -1920,6 +1929,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) +@@ -1964,7 +1979,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 = +@@ -2178,6 +2193,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 = \ +@@ -2195,6 +2211,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 \ +@@ -2228,6 +2245,9 @@ ALLDEPFILES = \ + darwin-nat.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 = \ +@@ -2249,6 +2269,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 = \ +@@ -2290,6 +2311,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 = \ +@@ -2307,6 +2329,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 = \ +@@ -2351,6 +2374,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 +@@ -2638,7 +2662,7 @@ endif -@@ -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 + # All the .deps files to include. diff --git gdb/config.in gdb/config.in -index 3f8a72326b..bb1e8c23bf 100644 +index 1d11a97080..50a5a5b322 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 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 +index 84a0790c0d..f4c323d4ab 100755 --- gdb/configure +++ gdb/configure -@@ -7968,6 +7968,66 @@ $as_echo "#define HAVE_KINFO_GETVMMAP 1" >>confdefs.h +@@ -7927,6 +7927,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 +index d4133ea71e..bac85c53e0 100644 --- gdb/configure.ac +++ gdb/configure.ac -@@ -530,6 +530,11 @@ AC_SEARCH_LIBS(kinfo_getvmmap, util util-freebsd, +@@ -523,6 +523,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.nat gdb/configure.nat +index 8e14892722..ada205f34d 100644 +--- gdb/configure.nat ++++ gdb/configure.nat +@@ -62,7 +62,8 @@ case ${gdb_host} in + LOADLIBES='-ldl $(RDYNAMIC)' + ;; + fbsd*) +- NATDEPFILES='fork-child.o fork-inferior.o inf-ptrace.o fbsd-nat.o' ++ NATDEPFILES='fork-child.o fork-inferior.o inf-ptrace.o fbsd-nat.o \ ++ fbsd-kvm.o' + HAVE_NATIVE_GCORE_HOST=1 + LOADLIBES='-lkvm' + ;; diff --git gdb/configure.tgt gdb/configure.tgt -index f72a0dbbc1..2d73300961 100644 +index fb8014a8e8..1a86608840 100644 --- gdb/configure.tgt +++ gdb/configure.tgt -@@ -203,7 +203,13 @@ i[34567]86-*-dicos*) +@@ -92,7 +92,7 @@ esac + + case "${targ}" in + *-*-freebsd* | *-*-kfreebsd*-gnu) +- os_obs="fbsd-tdep.o solib-svr4.o";; ++ os_obs="fbsd-tdep.o solib-svr4.o fbsd-kld.o fbsd-kthr.o";; + *-*-netbsd* | *-*-knetbsd*-gnu) + os_obs="nbsd-tdep.o solib-svr4.o";; + *-*-openbsd*) +@@ -249,7 +249,11 @@ 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" +- gdb_target_obs="i386-bsd-tdep.o i386-fbsd-tdep.o " ++ gdb_target_obs="i386-bsd-tdep.o i386-fbsd-tdep.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}" ++ gdb_target_obs="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) +@@ -408,7 +412,7 @@ 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_target_obs="mips-tdep.o mips-fbsd-tdep.o" ++ gdb_target_obs="mips-tdep.o mips-fbsd-tdep.o mipsfbsd-kern.o" gdb_sim=../sim/mips/libsim.a ;; mips64*-*-openbsd*) -@@ -436,7 +443,8 @@ powerpc*-*-freebsd*) +@@ -472,7 +476,7 @@ or1k-*-* | or1knd-*-*) + 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" +- ppc-fbsd-tdep.o \ ++ ppc-fbsd-tdep.o ppcfbsd-kern.o \ + ravenscar-thread.o ppc-ravenscar-thread.o" ;; - powerpc-*-netbsd* | powerpc-*-knetbsd*-gnu) -@@ -560,7 +568,8 @@ sparc*-*-freebsd* | sparc*-*-kfreebsd*-gnu) +@@ -594,6 +598,7 @@ sparc64-*-linux*) + 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" ++ sparc64fbsd-kern.o \ + ravenscar-thread.o sparc-ravenscar-thread.o" ;; sparc-*-netbsd* | sparc-*-knetbsd*-gnu) - # Target: NetBSD/sparc -@@ -691,7 +700,9 @@ x86_64-*-freebsd* | x86_64-*-kfreebsd*-gnu) +@@ -716,8 +721,8 @@ x86_64-*-linux*) + ;; + 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" +- gdb_target_obs="amd64-fbsd-tdep.o ${i386_tobjs} \ +- i386-bsd-tdep.o i386-fbsd-tdep.o" ++ gdb_target_obs="amd64-fbsd-tdep.o amd64fbsd-kern.o ${i386_tobjs} \ ++ i386-bsd-tdep.o i386-fbsd-tdep.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 +index 4fb2129b30..0cb0bad5c5 100644 --- gdb/defs.h +++ gdb/defs.h -@@ -590,6 +590,7 @@ enum gdb_osabi +@@ -516,6 +516,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/gnulib/configure gdb/gnulib/configure +index 37efd06b67..a23fc0a81c 100644 +--- gdb/gnulib/configure ++++ gdb/gnulib/configure +@@ -16790,6 +16790,7 @@ else + case "$host_os" in + # Guess all is fine on glibc systems. + *-gnu*) gl_cv_func_gettimeofday_clobber="guessing no" ;; ++ freebsd*) gl_cv_func_gettimeofday_clobber="guessing no" ;; + # If we don't know, assume the worst. + *) gl_cv_func_gettimeofday_clobber="guessing yes" ;; + esac diff --git gdb/osabi.c gdb/osabi.c -index 84fa9c0273..5c49e22657 100644 +index 129164f51e..4eacc074a3 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 +index fb6a904dec..f9b7105b8f 100644 --- gdb/regcache.c +++ gdb/regcache.c -@@ -1105,6 +1105,20 @@ regcache_raw_supply (struct regcache *regcache, int regnum, const void *buf) - } +@@ -1079,6 +1079,23 @@ regcache::raw_supply_zeroed (int regnum) + m_register_status[regnum] = REG_VALID; } +void -+regcache_raw_supply_unsigned (struct regcache *regcache, int regnum, -+ ULONGEST val) ++regcache::raw_supply_unsigned (int regnum, ULONGEST val) +{ -+ gdb_byte *buf; ++ enum bfd_endian byte_order = gdbarch_byte_order (m_descr->gdbarch); ++ gdb_byte *regbuf; ++ size_t regsize; + -+ 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); ++ assert_regnum (regnum); ++ gdb_assert (!m_readonly_p); ++ ++ regbuf = register_buffer (regnum); ++ regsize = m_descr->sizeof_register[regnum]; ++ ++ store_unsigned_integer (regbuf, regsize, byte_order, val); ++ m_register_status[regnum] = REG_VALID; +} + /* Collect register REGNUM from REGCACHE and store its contents in BUF. */ void diff --git gdb/regcache.h gdb/regcache.h -index 1d60fa7616..9b8a4723a3 100644 +index 9e3da8c3fc..5c65a9be1e 100644 --- gdb/regcache.h +++ gdb/regcache.h -@@ -149,6 +149,8 @@ extern void regcache_write_pc (struct regcache *regcache, CORE_ADDR pc); +@@ -294,6 +294,8 @@ public: + void raw_supply_integer (int regnum, const gdb_byte *addr, int addr_len, + bool is_signed); - 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); ++ void raw_supply_unsigned (int regnum, ULONGEST val); ++ + void raw_supply_zeroed (int regnum); + enum register_status get_register_status (int regnum) const; Index: head/devel/gdb/files/kgdb/amd64fbsd-kern.c =================================================================== --- head/devel/gdb/files/kgdb/amd64fbsd-kern.c (revision 464492) +++ head/devel/gdb/files/kgdb/amd64fbsd-kern.c (revision 464493) @@ -1,305 +1,304 @@ /* * Copyright (c) 2004 Marcel Moolenaar * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include __FBSDID("$FreeBSD$"); -#include -#ifdef __amd64__ -#include -#include -#endif -#include - -#include -#include +#include "defs.h" +#include "frame-unwind.h" #include "gdbcore.h" #include "osabi.h" -#include +#include "regcache.h" #include "solib.h" #include "stack.h" #include "symtab.h" #include "trad-frame.h" -#include +#include "amd64-tdep.h" +#include "x86-xstate.h" +#ifdef __amd64__ +#include +#include +#endif + #include "kgdb.h" static const int amd64fbsd_pcb_offset[] = { -1, /* %rax */ 6 * 8, /* %rbx */ -1, /* %rcx */ -1, /* %rdx */ -1, /* %rsi */ -1, /* %rdi */ 4 * 8, /* %rbp */ 5 * 8, /* %rsp */ -1, /* %r8 ... */ -1, -1, -1, 3 * 8, 2 * 8, 1 * 8, 0 * 8, /* ... %r15 */ 7 * 8, /* %rip */ -1, /* %eflags */ -1, /* %cs */ -1, /* %ss */ -1, /* %ds */ -1, /* %es */ -1, /* %fs */ -1 /* %gs */ }; #define CODE_SEL (4 << 3) #define DATA_SEL (5 << 3) static void amd64fbsd_supply_pcb(struct regcache *regcache, CORE_ADDR pcb_addr) { gdb_byte buf[8]; int i; for (i = 0; i < ARRAY_SIZE (amd64fbsd_pcb_offset); i++) if (amd64fbsd_pcb_offset[i] != -1) { if (target_read_memory(pcb_addr + amd64fbsd_pcb_offset[i], buf, sizeof buf) != 0) continue; - regcache_raw_supply(regcache, i, buf); + regcache->raw_supply(i, buf); } - regcache_raw_supply_unsigned(regcache, AMD64_CS_REGNUM, CODE_SEL); - regcache_raw_supply_unsigned(regcache, AMD64_SS_REGNUM, DATA_SEL); + regcache->raw_supply_unsigned(AMD64_CS_REGNUM, CODE_SEL); + regcache->raw_supply_unsigned(AMD64_SS_REGNUM, DATA_SEL); } static const int amd64fbsd_trapframe_offset[] = { 6 * 8, /* %rax */ 7 * 8, /* %rbx */ 3 * 8, /* %rcx */ 2 * 8, /* %rdx */ 1 * 8, /* %rsi */ 0 * 8, /* %rdi */ 8 * 8, /* %rbp */ 22 * 8, /* %rsp */ 4 * 8, /* %r8 ... */ 5 * 8, 9 * 8, 10 * 8, 11 * 8, 12 * 8, 13 * 8, 14 * 8, /* ... %r15 */ 19 * 8, /* %rip */ 21 * 8, /* %eflags */ 20 * 8, /* %cs */ 23 * 8, /* %ss */ -1, /* %ds */ -1, /* %es */ -1, /* %fs */ -1 /* %gs */ }; #define TRAPFRAME_SIZE 192 static struct trad_frame_cache * amd64fbsd_trapframe_cache (struct frame_info *this_frame, void **this_cache) { struct gdbarch *gdbarch = get_frame_arch (this_frame); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); struct trad_frame_cache *cache; CORE_ADDR addr, func, pc, sp; const char *name; int i; if (*this_cache != NULL) return ((struct trad_frame_cache *)*this_cache); cache = trad_frame_cache_zalloc (this_frame); *this_cache = cache; func = get_frame_func (this_frame); sp = get_frame_register_unsigned (this_frame, AMD64_RSP_REGNUM); find_pc_partial_function (func, &name, NULL, NULL); if (strcmp(name, "fork_trampoline") == 0 && get_frame_pc (this_frame) == func) { /* fork_exit hasn't been called (kthread has never run), so %rsp in the pcb points to the trapframe. GDB has auto-adjusted %rsp for this frame to account for the "call" into fork_trampoline, so "undo" the adjustment. */ sp += 8; } for (i = 0; i < ARRAY_SIZE (amd64fbsd_trapframe_offset); i++) if (amd64fbsd_trapframe_offset[i] != -1) trad_frame_set_reg_addr (cache, i, sp + amd64fbsd_trapframe_offset[i]); /* Read %rip from trap frame. */ addr = sp + amd64fbsd_trapframe_offset[AMD64_RIP_REGNUM]; pc = read_memory_unsigned_integer (addr, 8, byte_order); if (pc == 0 && strcmp(name, "fork_trampoline") == 0) { /* Initial frame of a kthread; terminate backtrace. */ trad_frame_set_id (cache, outer_frame_id); } else { /* Construct the frame ID using the function start. */ trad_frame_set_id (cache, frame_id_build (sp + TRAPFRAME_SIZE, func)); } return cache; } static void amd64fbsd_trapframe_this_id (struct frame_info *this_frame, void **this_cache, struct frame_id *this_id) { struct trad_frame_cache *cache = amd64fbsd_trapframe_cache (this_frame, this_cache); trad_frame_get_id (cache, this_id); } static struct value * amd64fbsd_trapframe_prev_register (struct frame_info *this_frame, void **this_cache, int regnum) { struct trad_frame_cache *cache = amd64fbsd_trapframe_cache (this_frame, this_cache); return trad_frame_get_register (cache, this_frame, regnum); } static int amd64fbsd_trapframe_sniffer (const struct frame_unwind *self, struct frame_info *this_frame, void **this_prologue_cache) { const char *name; find_pc_partial_function (get_frame_func (this_frame), &name, NULL, NULL); return (name && ((strcmp (name, "calltrap") == 0) + || (strcmp (name, "fast_syscall_common") == 0) || (strcmp (name, "fork_trampoline") == 0) || (strcmp (name, "mchk_calltrap") == 0) || (strcmp (name, "nmi_calltrap") == 0) || (name[0] == 'X' && name[1] != '_'))); } static const struct frame_unwind amd64fbsd_trapframe_unwind = { SIGTRAMP_FRAME, default_frame_unwind_stop_reason, amd64fbsd_trapframe_this_id, amd64fbsd_trapframe_prev_register, NULL, amd64fbsd_trapframe_sniffer }; static void amd64fbsd_kernel_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch) { - amd64_init_abi(info, gdbarch); + amd64_init_abi(info, gdbarch, + amd64_target_description (X86_XSTATE_SSE_MASK)); frame_unwind_prepend_unwinder(gdbarch, &amd64fbsd_trapframe_unwind); set_solib_ops(gdbarch, &kld_so_ops); fbsd_vmcore_set_supply_pcb(gdbarch, amd64fbsd_supply_pcb); fbsd_vmcore_set_cpu_pcb_addr(gdbarch, kgdb_trgt_stop_pcb); } - -void _initialize_amd64_kgdb_tdep(void); void _initialize_amd64_kgdb_tdep(void) { gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x86_64, GDB_OSABI_FREEBSD_KERNEL, amd64fbsd_kernel_init_abi); #ifdef __amd64__ gdb_assert(offsetof(struct pcb, pcb_rbx) == amd64fbsd_pcb_offset[AMD64_RBX_REGNUM]); gdb_assert(offsetof(struct pcb, pcb_rbp) == amd64fbsd_pcb_offset[AMD64_RBP_REGNUM]); gdb_assert(offsetof(struct pcb, pcb_rsp) == amd64fbsd_pcb_offset[AMD64_RSP_REGNUM]); gdb_assert(offsetof(struct pcb, pcb_r12) == amd64fbsd_pcb_offset[AMD64_R12_REGNUM]); gdb_assert(offsetof(struct pcb, pcb_r13) == amd64fbsd_pcb_offset[AMD64_R13_REGNUM]); gdb_assert(offsetof(struct pcb, pcb_r14) == amd64fbsd_pcb_offset[AMD64_R14_REGNUM]); gdb_assert(offsetof(struct pcb, pcb_r15) == amd64fbsd_pcb_offset[AMD64_R15_REGNUM]); gdb_assert(offsetof(struct pcb, pcb_rip) == amd64fbsd_pcb_offset[AMD64_RIP_REGNUM]); gdb_assert(CODE_SEL == GSEL(GCODE_SEL, SEL_KPL)); gdb_assert(DATA_SEL == GSEL(GDATA_SEL, SEL_KPL)); gdb_assert(sizeof(struct trapframe) == TRAPFRAME_SIZE); gdb_assert(offsetof(struct trapframe, tf_rax) == amd64fbsd_trapframe_offset[AMD64_RAX_REGNUM]); gdb_assert(offsetof(struct trapframe, tf_rbx) == amd64fbsd_trapframe_offset[AMD64_RBX_REGNUM]); gdb_assert(offsetof(struct trapframe, tf_rcx) == amd64fbsd_trapframe_offset[AMD64_RCX_REGNUM]); gdb_assert(offsetof(struct trapframe, tf_rdx) == amd64fbsd_trapframe_offset[AMD64_RDX_REGNUM]); gdb_assert(offsetof(struct trapframe, tf_rsi) == amd64fbsd_trapframe_offset[AMD64_RSI_REGNUM]); gdb_assert(offsetof(struct trapframe, tf_rdi) == amd64fbsd_trapframe_offset[AMD64_RDI_REGNUM]); gdb_assert(offsetof(struct trapframe, tf_rbp) == amd64fbsd_trapframe_offset[AMD64_RBP_REGNUM]); gdb_assert(offsetof(struct trapframe, tf_rsp) == amd64fbsd_trapframe_offset[AMD64_RSP_REGNUM]); gdb_assert(offsetof(struct trapframe, tf_r8) == amd64fbsd_trapframe_offset[AMD64_R8_REGNUM]); gdb_assert(offsetof(struct trapframe, tf_r9) == amd64fbsd_trapframe_offset[AMD64_R9_REGNUM]); gdb_assert(offsetof(struct trapframe, tf_r10) == amd64fbsd_trapframe_offset[AMD64_R10_REGNUM]); gdb_assert(offsetof(struct trapframe, tf_r11) == amd64fbsd_trapframe_offset[AMD64_R11_REGNUM]); gdb_assert(offsetof(struct trapframe, tf_r12) == amd64fbsd_trapframe_offset[AMD64_R12_REGNUM]); gdb_assert(offsetof(struct trapframe, tf_r13) == amd64fbsd_trapframe_offset[AMD64_R13_REGNUM]); gdb_assert(offsetof(struct trapframe, tf_r14) == amd64fbsd_trapframe_offset[AMD64_R14_REGNUM]); gdb_assert(offsetof(struct trapframe, tf_r15) == amd64fbsd_trapframe_offset[AMD64_R15_REGNUM]); gdb_assert(offsetof(struct trapframe, tf_rip) == amd64fbsd_trapframe_offset[AMD64_RIP_REGNUM]); gdb_assert(offsetof(struct trapframe, tf_rflags) == amd64fbsd_trapframe_offset[AMD64_EFLAGS_REGNUM]); gdb_assert(offsetof(struct trapframe, tf_cs) == amd64fbsd_trapframe_offset[AMD64_CS_REGNUM]); gdb_assert(offsetof(struct trapframe, tf_ss) == amd64fbsd_trapframe_offset[AMD64_SS_REGNUM]); #endif } Index: head/devel/gdb/files/kgdb/fbsd-kld.c =================================================================== --- head/devel/gdb/files/kgdb/fbsd-kld.c (revision 464492) +++ head/devel/gdb/files/kgdb/fbsd-kld.c (revision 464493) @@ -1,582 +1,582 @@ /* * Copyright (c) 2004 Marcel Moolenaar * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include __FBSDID("$FreeBSD$"); -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "defs.h" +#include "command.h" +#include "completer.h" +#include "environ.h" +#include "exec.h" +#include "frame-unwind.h" +#include "inferior.h" +#include "objfiles.h" +#include "gdbcore.h" +#include "language.h" #include "solib.h" -#include +#include "solist.h" #include "kgdb.h" -struct lm_info { +struct lm_info_kld : public lm_info_base { CORE_ADDR base_address; }; struct kld_info { /* Offsets of fields in linker_file structure. */ CORE_ADDR off_address, off_filename, off_pathname, off_next; /* KVA of 'linker_path' which corresponds to the kern.module_path sysctl .*/ CORE_ADDR module_path_addr; CORE_ADDR linker_files_addr; CORE_ADDR kernel_file_addr; }; struct target_so_ops kld_so_ops; /* Per-program-space data key. */ static const struct program_space_data *kld_pspace_data; static void kld_pspace_data_cleanup (struct program_space *pspace, void *arg) { struct kld_info *info = (struct kld_info *)arg; xfree (info); } /* Get the current kld data. If none is found yet, add it now. This function always returns a valid object. */ static struct kld_info * get_kld_info (void) { struct kld_info *info; info = (struct kld_info *) program_space_data (current_program_space, kld_pspace_data); if (info != NULL) return info; info = XCNEW (struct kld_info); set_program_space_data (current_program_space, kld_pspace_data, info); return info; } static int kld_ok (char *path) { struct stat sb; if (stat(path, &sb) == 0 && S_ISREG(sb.st_mode)) return (1); return (0); } /* * Look for a matching file checking for debug suffixes before the raw file: * - filename + ".debug" (e.g. foo.ko.debug) * - filename (e.g. foo.ko) */ static const char *kld_suffixes[] = { ".debug", ".symbols", "", NULL }; static int check_kld_path (char *path, size_t path_size) { const char **suffix; char *ep; ep = path + strlen(path); suffix = kld_suffixes; while (*suffix != NULL) { if (strlcat(path, *suffix, path_size) < path_size) { if (kld_ok(path)) return (1); } /* Restore original path to remove suffix. */ *ep = '\0'; suffix++; } return (0); } /* * Try to find the path for a kld by looking in the kernel's directory and * in the various paths in the module path. */ static int find_kld_path (const char *filename, char *path, size_t path_size) { struct kld_info *info; struct cleanup *cleanup; char *module_path; char *module_dir, *cp; int error; info = get_kld_info(); if (exec_bfd) { std::string kernel_dir = ldirname(bfd_get_filename(exec_bfd)); if (!kernel_dir.empty()) { snprintf(path, path_size, "%s/%s", kernel_dir.c_str(), filename); if (check_kld_path(path, path_size)) return (1); } } if (info->module_path_addr != 0) { target_read_string(info->module_path_addr, &module_path, PATH_MAX, &error); if (error == 0) { cleanup = make_cleanup(xfree, module_path); cp = module_path; while ((module_dir = strsep(&cp, ";")) != NULL) { snprintf(path, path_size, "%s/%s", module_dir, filename); if (check_kld_path(path, path_size)) { do_cleanups(cleanup); return (1); } } do_cleanups(cleanup); } } return (0); } /* * Read a kernel pointer given a KVA in 'address'. */ static CORE_ADDR read_pointer (CORE_ADDR address) { struct type *ptr_type; gdb_byte ptr_buf[8]; int arch_size; arch_size = bfd_get_arch_size (exec_bfd); if (arch_size == -1) return (0); ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr; if (target_read_memory(address, ptr_buf, arch_size / 8) != 0) return (0); return (extract_typed_address (ptr_buf, ptr_type)); } /* * Try to find this kld in the kernel linker's list of linker files. */ static int -find_kld_address (char *arg, CORE_ADDR *address) +find_kld_address (const char *arg, CORE_ADDR *address) { struct kld_info *info; CORE_ADDR kld; char *kld_filename; const char *filename; int error; info = get_kld_info(); if (info->linker_files_addr == 0 || info->off_address == 0 || info->off_filename == 0 || info->off_next == 0) return (0); filename = lbasename(arg); for (kld = read_pointer(info->linker_files_addr); kld != 0; kld = read_pointer(kld + info->off_next)) { /* Try to read this linker file's filename. */ target_read_string(read_pointer(kld + info->off_filename), &kld_filename, PATH_MAX, &error); if (error) continue; /* Compare this kld's filename against our passed in name. */ if (strcmp(kld_filename, filename) != 0) { xfree(kld_filename); continue; } xfree(kld_filename); /* * We found a match, use its address as the base * address if we can read it. */ *address = read_pointer(kld + info->off_address); if (*address == 0) return (0); return (1); } return (0); } static void adjust_section_address (struct target_section *sec, CORE_ADDR *curr_base) { struct bfd_section *asect = sec->the_bfd_section; bfd *abfd = asect->owner; if ((abfd->flags & (EXEC_P | DYNAMIC)) != 0) { sec->addr += *curr_base; sec->endaddr += *curr_base; return; } *curr_base = align_power(*curr_base, bfd_get_section_alignment(abfd, asect)); sec->addr = *curr_base; sec->endaddr = sec->addr + bfd_section_size(abfd, asect); *curr_base = sec->endaddr; } static void load_kld (char *path, CORE_ADDR base_addr, int from_tty) { struct section_addr_info *sap; struct target_section *sections = NULL, *sections_end = NULL, *s; struct cleanup *cleanup; gdb_bfd_ref_ptr bfd; CORE_ADDR curr_addr; symfile_add_flags add_flags; int i; /* Open the kld. */ bfd = gdb_bfd_openr(path, gnutarget); if (bfd == NULL) error("\"%s\": can't open: %s", path, bfd_errmsg(bfd_get_error())); if (!bfd_check_format(bfd.get(), bfd_object)) error("\%s\": not an object file", path); /* Make sure we have a .text section. */ if (bfd_get_section_by_name (bfd.get(), ".text") == NULL) error("\"%s\": can't find text section", path); /* Build a section table from the bfd and relocate the sections. */ if (build_section_table (bfd.get(), §ions, §ions_end)) error("\"%s\": can't find file sections", path); cleanup = make_cleanup(xfree, sections); curr_addr = base_addr; for (s = sections; s < sections_end; s++) adjust_section_address(s, &curr_addr); /* Build a section addr info to pass to symbol_file_add(). */ sap = build_section_addr_info_from_section_table (sections, sections_end); make_cleanup((make_cleanup_ftype *)free_section_addr_info, sap); printf_unfiltered("add symbol table from file \"%s\" at\n", path); for (i = 0; i < sap->num_sections; i++) printf_unfiltered("\t%s_addr = %s\n", sap->other[i].name, paddress(target_gdbarch(), sap->other[i].addr)); if (from_tty && (!query("%s", ""))) error("Not confirmed."); add_flags = 0; if (from_tty) add_flags |= SYMFILE_VERBOSE; symbol_file_add_from_bfd(bfd.get(), path, add_flags, sap, OBJF_USERLOADED, NULL); do_cleanups(cleanup); } static void -kgdb_add_kld_cmd (char *arg, int from_tty) +kgdb_add_kld_cmd (const char *arg, int from_tty) { char path[PATH_MAX]; CORE_ADDR base_addr; if (!exec_bfd) error("No kernel symbol file"); /* Try to open the raw path to handle absolute paths first. */ snprintf(path, sizeof(path), "%s", arg); if (!check_kld_path(path, sizeof(path))) { /* * If that didn't work, look in the various possible * paths for the module. */ if (!find_kld_path(arg, path, sizeof(path))) { error("Unable to locate kld"); return; } } if (!find_kld_address(arg, &base_addr)) { error("Unable to find kld in kernel"); return; } load_kld(path, base_addr, from_tty); reinit_frame_cache(); } static void kld_relocate_section_addresses (struct so_list *so, struct target_section *sec) { - static CORE_ADDR curr_addr; + lm_info_kld *li = (lm_info_kld *) so->lm_info; + static CORE_ADDR curr_addr; - if (sec == so->sections) - curr_addr = so->lm_info->base_address; + if (sec == so->sections) + curr_addr = li->base_address; - adjust_section_address(sec, &curr_addr); + adjust_section_address(sec, &curr_addr); } static void kld_free_so (struct so_list *so) { + lm_info_kld *li = (lm_info_kld *) so->lm_info; - xfree(so->lm_info); + delete li; } static void kld_clear_so (struct so_list *so) { - if (so->lm_info != NULL) - so->lm_info->base_address = 0; + lm_info_kld *li = (lm_info_kld *) so->lm_info; + + if (li != NULL) + li->base_address = 0; } static void kld_clear_solib (void) { struct kld_info *info; info = get_kld_info(); memset(info, 0, sizeof(*info)); } static void kld_solib_create_inferior_hook (int from_tty) { struct kld_info *info; info = get_kld_info(); /* * Compute offsets of relevant members in struct linker_file * and the addresses of global variables. Newer kernels * include constants we can use without requiring debug * symbols. If those aren't present, fall back to using * home-grown offsetof() equivalents. */ TRY { info->off_address = parse_and_eval_long("kld_off_address"); info->off_filename = parse_and_eval_long("kld_off_filename"); info->off_pathname = parse_and_eval_long("kld_off_pathname"); info->off_next = parse_and_eval_long("kld_off_next"); } CATCH(e, RETURN_MASK_ERROR) { TRY { info->off_address = parse_and_eval_address( "&((struct linker_file *)0)->address"); info->off_filename = parse_and_eval_address( "&((struct linker_file *)0)->filename"); info->off_pathname = parse_and_eval_address( "&((struct linker_file *)0)->pathname"); info->off_next = parse_and_eval_address( "&((struct linker_file *)0)->link.tqe_next"); } CATCH(e, RETURN_MASK_ERROR) { return; } END_CATCH } END_CATCH TRY { info->module_path_addr = parse_and_eval_address("linker_path"); info->linker_files_addr = kgdb_lookup("linker_files"); info->kernel_file_addr = kgdb_lookup("linker_kernel_file"); } CATCH(e, RETURN_MASK_ERROR) { return; } END_CATCH solib_add(NULL, from_tty, auto_solib_add); } static struct so_list * kld_current_sos (void) { struct so_list *head, **prev, *newobj; struct kld_info *info; CORE_ADDR kld, kernel; char *path; int error; info = get_kld_info(); if (info->linker_files_addr == 0 || info->kernel_file_addr == 0 || info->off_address == 0 || info->off_filename == 0 || info->off_next == 0) return (NULL); head = NULL; prev = &head; /* * Walk the list of linker files creating so_list entries for * each non-kernel file. */ kernel = read_pointer(info->kernel_file_addr); for (kld = read_pointer(info->linker_files_addr); kld != 0; kld = read_pointer(kld + info->off_next)) { /* Skip the main kernel file. */ if (kld == kernel) continue; newobj = XCNEW (struct so_list); - newobj->lm_info = XNEW (struct lm_info); - newobj->lm_info->base_address = 0; + lm_info_kld *li = new lm_info_kld; + li->base_address = 0; + newobj->lm_info = li; + /* Read the base filename and store it in so_original_name. */ target_read_string(read_pointer(kld + info->off_filename), &path, sizeof(newobj->so_original_name), &error); if (error != 0) { warning("kld_current_sos: Can't read filename: %s\n", safe_strerror(error)); free_so(newobj); continue; } strlcpy(newobj->so_original_name, path, sizeof(newobj->so_original_name)); xfree(path); /* * Try to read the pathname (if it exists) and store * it in so_name. */ if (find_kld_path(newobj->so_original_name, newobj->so_name, sizeof(newobj->so_name))) { /* we found the kld */; } else if (info->off_pathname != 0) { target_read_string(read_pointer(kld + info->off_pathname), &path, sizeof(newobj->so_name), &error); if (error != 0) { warning( "kld_current_sos: Can't read pathname for \"%s\": %s\n", newobj->so_original_name, safe_strerror(error)); strlcpy(newobj->so_name, newobj->so_original_name, sizeof(newobj->so_name)); } else { strlcpy(newobj->so_name, path, sizeof(newobj->so_name)); xfree(path); } } else strlcpy(newobj->so_name, newobj->so_original_name, sizeof(newobj->so_name)); /* Read this kld's base address. */ - newobj->lm_info->base_address = read_pointer(kld + - info->off_address); - if (newobj->lm_info->base_address == 0) { + li->base_address = read_pointer(kld + info->off_address); + if (li->base_address == 0) { warning( "kld_current_sos: Invalid address for kld \"%s\"", newobj->so_original_name); free_so(newobj); continue; } /* Append to the list. */ *prev = newobj; prev = &newobj->next; } return (head); } static int -kld_open_symbol_file_object (void *from_ttyp) +kld_open_symbol_file_object (int from_tty) { return (0); } static int kld_in_dynsym_resolve_code (CORE_ADDR pc) { return (0); } static int kld_find_and_open_solib (const char *solib, unsigned o_flags, char **temp_pathname) { char path[PATH_MAX]; int fd; *temp_pathname = NULL; if (!find_kld_path(solib, path, sizeof(path))) { errno = ENOENT; return (-1); } fd = open(path, o_flags, 0); if (fd >= 0) *temp_pathname = xstrdup(path); return (fd); } - -void _initialize_kld_target(void); void _initialize_kld_target(void) { struct cmd_list_element *c; kld_so_ops.relocate_section_addresses = kld_relocate_section_addresses; kld_so_ops.free_so = kld_free_so; kld_so_ops.clear_so = kld_clear_so; kld_so_ops.clear_solib = kld_clear_solib; kld_so_ops.solib_create_inferior_hook = kld_solib_create_inferior_hook; kld_so_ops.current_sos = kld_current_sos; kld_so_ops.open_symbol_file_object = kld_open_symbol_file_object; kld_so_ops.in_dynsym_resolve_code = kld_in_dynsym_resolve_code; kld_so_ops.bfd_open = solib_bfd_open; kld_so_ops.find_and_open_solib = kld_find_and_open_solib; c = add_com("add-kld", class_files, kgdb_add_kld_cmd, "Usage: add-kld FILE\n\ Load the symbols from the kernel loadable module FILE."); set_cmd_completer(c, filename_completer); kld_pspace_data = register_program_space_data_with_cleanup (NULL, kld_pspace_data_cleanup); } Index: head/devel/gdb/files/kgdb/fbsd-kvm.c =================================================================== --- head/devel/gdb/files/kgdb/fbsd-kvm.c (revision 464492) +++ head/devel/gdb/files/kgdb/fbsd-kvm.c (revision 464493) @@ -1,618 +1,604 @@ /* * Copyright (c) 2004 Marcel Moolenaar * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include +#include "defs.h" +#include "command.h" #include "elf-bfd.h" -#include #include "filenames.h" -#include -#include -#include -#include +#include "gdbcore.h" +#include "gdbthread.h" #include "gdb_obstack.h" -#include -#include +#include "inferior.h" #include "objfiles.h" #include "osabi.h" -#include -#include -#include -#include +#include "solib.h" +#include "target.h" +#include "value.h" +#include "readline/tilde.h" +#include +#include +#include + #include "kgdb.h" static CORE_ADDR stoppcbs; static LONGEST pcb_size; static void kgdb_core_cleanup(void *); static char *vmcore; struct target_ops kgdb_trgt_ops; /* Per-architecture data key. */ static struct gdbarch_data *fbsd_vmcore_data; struct fbsd_vmcore_ops { /* Supply registers for a pcb to a register cache. */ void (*supply_pcb)(struct regcache *, CORE_ADDR); /* Return address of pcb for thread running on a CPU. */ CORE_ADDR (*cpu_pcb_addr)(u_int); }; static void * fbsd_vmcore_init (struct obstack *obstack) { struct fbsd_vmcore_ops *ops; ops = OBSTACK_ZALLOC (obstack, struct fbsd_vmcore_ops); return ops; } /* Set the function that supplies registers from a pcb for architecture GDBARCH to SUPPLY_PCB. */ void fbsd_vmcore_set_supply_pcb (struct gdbarch *gdbarch, void (*supply_pcb) (struct regcache *, CORE_ADDR)) { struct fbsd_vmcore_ops *ops = (struct fbsd_vmcore_ops *) gdbarch_data (gdbarch, fbsd_vmcore_data); ops->supply_pcb = supply_pcb; } /* Set the function that returns the address of the pcb for a thread running on a CPU for architecture GDBARCH to CPU_PCB_ADDR. */ void fbsd_vmcore_set_cpu_pcb_addr (struct gdbarch *gdbarch, CORE_ADDR (*cpu_pcb_addr) (u_int)) { struct fbsd_vmcore_ops *ops = (struct fbsd_vmcore_ops *) gdbarch_data (gdbarch, fbsd_vmcore_data); ops->cpu_pcb_addr = cpu_pcb_addr; } static CORE_ADDR kernstart; static kvm_t *kvm; static char kvm_err[_POSIX2_LINE_MAX]; int kgdb_quiet; static ptid_t fbsd_vmcore_ptid(int tid) { if (kvm == NULL) /* * The remote target stores the 'tid' in the lwp * field. */ return ptid_build(ptid_get_pid(inferior_ptid), tid, 0); /* * This follows the model described in bsd-kvm.c except that * in kernel tids are used as the tid of the ptid instead of a * process ID. */ return ptid_build(1, 1, tid); } #define MSGBUF_SEQ_TO_POS(size, seq) ((seq) % (size)) static void kgdb_dmesg(void) { CORE_ADDR bufp; int size, rseq, wseq; gdb_byte c; /* * Display the unread portion of the message buffer. This gives the * user a some initial data to work from. */ if (kgdb_quiet) return; TRY { bufp = parse_and_eval_address("msgbufp->msg_ptr"); size = parse_and_eval_long("msgbufp->msg_size"); rseq = parse_and_eval_long("msgbufp->msg_rseq"); wseq = parse_and_eval_long("msgbufp->msg_wseq"); } CATCH(e, RETURN_MASK_ERROR) { return; } END_CATCH rseq = MSGBUF_SEQ_TO_POS(size, rseq); wseq = MSGBUF_SEQ_TO_POS(size, wseq); if (rseq == wseq) return; printf("\nUnread portion of the kernel message buffer:\n"); while (rseq < wseq) { read_memory(bufp + rseq, &c, 1); putchar(c); rseq++; if (rseq == size) rseq = 0; } if (c != '\n') putchar('\n'); putchar('\n'); } #define KERNEL_INTERP "/red/herring" enum gdb_osabi fbsd_kernel_osabi_sniffer(bfd *abfd) { asection *s; bfd_byte buf[sizeof(KERNEL_INTERP)]; bfd_byte *bufp; /* First, determine if this is a FreeBSD/ELF binary. */ switch (elf_elfheader(abfd)->e_ident[EI_OSABI]) { case ELFOSABI_FREEBSD: break; case ELFOSABI_NONE: { enum gdb_osabi osabi = GDB_OSABI_UNKNOWN; bfd_map_over_sections (abfd, generic_elf_osabi_sniff_abi_tag_sections, &osabi); /* * aarch64 kernels don't have the right note tag for * kernels so just look for /red/herring anyway. */ if (osabi == GDB_OSABI_UNKNOWN && elf_elfheader(abfd)->e_machine == EM_AARCH64) break; if (osabi != GDB_OSABI_FREEBSD) return (GDB_OSABI_UNKNOWN); } default: return (GDB_OSABI_UNKNOWN); } /* FreeBSD ELF kernels have an interpreter path of "/red/herring". */ bufp = buf; s = bfd_get_section_by_name(abfd, ".interp"); if (s != NULL && bfd_section_size(abfd, s) == sizeof(buf) && bfd_get_full_section_contents(abfd, s, &bufp) && memcmp(buf, KERNEL_INTERP, sizeof(buf)) == 0) return (GDB_OSABI_FREEBSD_KERNEL); return (GDB_OSABI_UNKNOWN); } #ifdef HAVE_KVM_OPEN2 static int kgdb_resolve_symbol(const char *name, kvaddr_t *kva) { struct bound_minimal_symbol ms; ms = lookup_minimal_symbol (name, NULL, NULL); if (ms.minsym == NULL) return (1); *kva = BMSYMBOL_VALUE_ADDRESS (ms); return (0); } #endif static void kgdb_trgt_open(const char *arg, int from_tty) { struct fbsd_vmcore_ops *ops = (struct fbsd_vmcore_ops *) gdbarch_data (target_gdbarch(), fbsd_vmcore_data); struct inferior *inf; struct cleanup *old_chain; struct thread_info *ti; struct kthr *kt; kvm_t *nkvm; char *temp, *kernel, *filename; int ontop; if (ops == NULL || ops->supply_pcb == NULL || ops->cpu_pcb_addr == NULL) error ("ABI doesn't support a vmcore target"); target_preopen (from_tty); kernel = get_exec_file (1); if (kernel == NULL) error ("Can't open a vmcore without a kernel"); if (arg != NULL) { filename = tilde_expand (arg); if (!IS_ABSOLUTE_PATH (filename)) { temp = concat (current_directory, "/", filename, NULL); xfree(filename); filename = temp; } } else filename = NULL; old_chain = make_cleanup (xfree, filename); #ifdef HAVE_KVM_OPEN2 nkvm = kvm_open2(kernel, filename, write_files ? O_RDWR : O_RDONLY, kvm_err, kgdb_resolve_symbol); #else nkvm = kvm_openfiles(kernel, filename, NULL, write_files ? O_RDWR : O_RDONLY, kvm_err); #endif if (nkvm == NULL) error ("Failed to open vmcore: %s", kvm_err); /* Don't free the filename now and close any previous vmcore. */ discard_cleanups(old_chain); unpush_target(&kgdb_trgt_ops); /* * Determine the first address in KVA. Newer kernels export * VM_MAXUSER_ADDRESS and the first kernel address can be * determined by adding one. Older kernels do not provide a * symbol that is valid on all platforms, but kernbase is close * for most platforms. */ TRY { kernstart = parse_and_eval_address("vm_maxuser_address") + 1; } CATCH(e, RETURN_MASK_ERROR) { kernstart = kgdb_lookup("kernbase"); } END_CATCH /* * Lookup symbols needed for stoppcbs[] handling, but don't * fail if they aren't present. */ stoppcbs = kgdb_lookup("stoppcbs"); TRY { pcb_size = parse_and_eval_long("pcb_size"); } CATCH(e, RETURN_MASK_ERROR) { TRY { pcb_size = parse_and_eval_long("sizeof(struct pcb)"); } CATCH(e, RETURN_MASK_ERROR) { #ifdef HAVE_KVM_OPEN2 if (kvm_native(nkvm)) pcb_size = sizeof(struct pcb); else pcb_size = 0; #else pcb_size = sizeof(struct pcb); #endif } END_CATCH } END_CATCH kvm = nkvm; vmcore = filename; old_chain = make_cleanup(kgdb_core_cleanup, NULL); push_target (&kgdb_trgt_ops); discard_cleanups (old_chain); kgdb_dmesg(); inf = current_inferior(); if (inf->pid == 0) { inferior_appeared(inf, 1); inf->fake_pid_p = 1; } solib_create_inferior_hook(0); init_thread_list(); kt = kgdb_thr_init(ops->cpu_pcb_addr); while (kt != NULL) { ti = add_thread_silent(fbsd_vmcore_ptid(kt->tid)); kt = kgdb_thr_next(kt); } if (curkthr != 0) inferior_ptid = fbsd_vmcore_ptid(curkthr->tid); target_fetch_registers (get_current_regcache (), -1); reinit_frame_cache (); print_stack_frame (get_selected_frame (NULL), 0, SRC_AND_LOC, 1); } static void kgdb_trgt_close(struct target_ops *self) { if (kvm != NULL) { clear_solib(); if (kvm_close(kvm) != 0) warning("cannot close \"%s\": %s", vmcore, kvm_geterr(kvm)); kvm = NULL; xfree(vmcore); vmcore = NULL; } inferior_ptid = null_ptid; } static void kgdb_core_cleanup(void *arg) { kgdb_trgt_close(0); } static void kgdb_trgt_detach(struct target_ops *ops, const char *args, int from_tty) { if (args) error ("Too many arguments"); unpush_target(&kgdb_trgt_ops); reinit_frame_cache(); if (from_tty) printf_filtered("No vmcore file now.\n"); } static const char * kgdb_trgt_extra_thread_info(struct target_ops *ops, struct thread_info *ti) { return (kgdb_thr_extra_thread_info(ptid_get_tid(ti->ptid))); } static void kgdb_trgt_files_info(struct target_ops *target) { printf_filtered ("\t`%s', ", vmcore); wrap_here (" "); printf_filtered ("file type %s.\n", "FreeBSD kernel vmcore"); } static void kgdb_trgt_update_thread_list(struct target_ops *ops) { /* * XXX: We should probably rescan the thread list here and update * it if there are any changes. One nit though is that we'd have * to detect exited threads. */ gdb_assert(kvm != NULL); #if 0 prune_threads(); #endif #if 0 struct target_ops *tb; if (kvm != NULL) return; tb = find_target_beneath(ops); if (tb->to_update_thread_list != NULL) tb->to_update_thread_list(tb); #endif } static const char * kgdb_trgt_pid_to_str(struct target_ops *ops, ptid_t ptid) { static char buf[33]; snprintf(buf, sizeof(buf), "Thread %ld", ptid_get_tid(ptid)); return (buf); } static int kgdb_trgt_thread_alive(struct target_ops *ops, ptid_t ptid) { return (kgdb_thr_lookup_tid(ptid_get_tid(ptid)) != NULL); } static void kgdb_trgt_fetch_registers(struct target_ops *tops, struct regcache *regcache, int regnum) { struct fbsd_vmcore_ops *ops = (struct fbsd_vmcore_ops *) gdbarch_data (target_gdbarch(), fbsd_vmcore_data); struct kthr *kt; if (ops->supply_pcb == NULL) return; kt = kgdb_thr_lookup_tid(ptid_get_tid(inferior_ptid)); if (kt == NULL) return; ops->supply_pcb(regcache, kt->pcb); } static enum target_xfer_status kgdb_trgt_xfer_partial(struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len) { ssize_t nbytes; gdb_assert(kvm != NULL); switch (object) { case TARGET_OBJECT_MEMORY: nbytes = len; if (readbuf != NULL) #ifdef HAVE_KVM_OPEN2 nbytes = kvm_read2(kvm, offset, readbuf, len); #else nbytes = kvm_read(kvm, offset, readbuf, len); #endif if (writebuf != NULL && len > 0) nbytes = kvm_write(kvm, offset, writebuf, len); if (nbytes < 0) return TARGET_XFER_E_IO; if (nbytes == 0) return TARGET_XFER_EOF; *xfered_len = nbytes; return TARGET_XFER_OK; default: return TARGET_XFER_E_IO; } } static int kgdb_trgt_insert_breakpoint(struct target_ops *ops, struct gdbarch *gdbarch, struct bp_target_info *bp_tgt) { return 0; } static int kgdb_trgt_remove_breakpoint(struct target_ops *ops, struct gdbarch *gdbarch, struct bp_target_info *bp_tgt, enum remove_bp_reason reason) { return 0; } static void -kgdb_switch_to_thread(int tid) +kgdb_switch_to_thread(const char *arg, int tid) { - char buf[16]; - int thread_id; + struct thread_info *tp; - thread_id = ptid_to_global_thread_id(fbsd_vmcore_ptid(tid)); - if (thread_id == 0) - error ("invalid tid"); - snprintf(buf, sizeof(buf), "%d", thread_id); - gdb_thread_select(current_uiout, buf, NULL); + tp = find_thread_ptid (fbsd_vmcore_ptid (tid)); + if (tp == NULL) + error ("invalid tid"); + thread_select (arg, tp); } static void -kgdb_set_proc_cmd (char *arg, int from_tty) +kgdb_set_proc_cmd (const char *arg, int from_tty) { CORE_ADDR addr; struct kthr *thr; if (!arg) error_no_arg ("proc address for the new context"); if (kvm == NULL) error ("only supported for core file target"); addr = parse_and_eval_address (arg); if (addr < kernstart) { thr = kgdb_thr_lookup_pid((int)addr); if (thr == NULL) error ("invalid pid"); } else { thr = kgdb_thr_lookup_paddr(addr); if (thr == NULL) error("invalid proc address"); } - kgdb_switch_to_thread(thr->tid); + kgdb_switch_to_thread(arg, thr->tid); } static void -kgdb_set_tid_cmd (char *arg, int from_tty) +kgdb_set_tid_cmd (const char *arg, int from_tty) { CORE_ADDR addr; struct kthr *thr; if (!arg) error_no_arg ("TID or thread address for the new context"); addr = (CORE_ADDR) parse_and_eval_address (arg); if (kvm != NULL && addr >= kernstart) { thr = kgdb_thr_lookup_taddr(addr); if (thr == NULL) error("invalid thread address"); addr = thr->tid; } - kgdb_switch_to_thread(addr); + kgdb_switch_to_thread(arg, addr); } static int kgdb_trgt_return_one(struct target_ops *ops) { return 1; } - -void _initialize_kgdb_target(void); void _initialize_kgdb_target(void) { kgdb_trgt_ops.to_magic = OPS_MAGIC; kgdb_trgt_ops.to_shortname = "vmcore"; kgdb_trgt_ops.to_longname = "kernel core dump file"; kgdb_trgt_ops.to_doc = "Use a vmcore file as a target. Specify the filename of the vmcore file."; kgdb_trgt_ops.to_stratum = process_stratum; kgdb_trgt_ops.to_has_memory = kgdb_trgt_return_one; kgdb_trgt_ops.to_has_registers = kgdb_trgt_return_one; kgdb_trgt_ops.to_has_stack = kgdb_trgt_return_one; kgdb_trgt_ops.to_open = kgdb_trgt_open; kgdb_trgt_ops.to_close = kgdb_trgt_close; kgdb_trgt_ops.to_detach = kgdb_trgt_detach; kgdb_trgt_ops.to_extra_thread_info = kgdb_trgt_extra_thread_info; kgdb_trgt_ops.to_fetch_registers = kgdb_trgt_fetch_registers; kgdb_trgt_ops.to_files_info = kgdb_trgt_files_info; kgdb_trgt_ops.to_update_thread_list = kgdb_trgt_update_thread_list; kgdb_trgt_ops.to_pid_to_str = kgdb_trgt_pid_to_str; kgdb_trgt_ops.to_thread_alive = kgdb_trgt_thread_alive; kgdb_trgt_ops.to_xfer_partial = kgdb_trgt_xfer_partial; kgdb_trgt_ops.to_insert_breakpoint = kgdb_trgt_insert_breakpoint; kgdb_trgt_ops.to_remove_breakpoint = kgdb_trgt_remove_breakpoint; add_target(&kgdb_trgt_ops); fbsd_vmcore_data = gdbarch_data_register_pre_init(fbsd_vmcore_init); add_com ("proc", class_obscure, kgdb_set_proc_cmd, "Set current process context"); add_com ("tid", class_obscure, kgdb_set_tid_cmd, "Set current thread context"); } CORE_ADDR kgdb_trgt_stop_pcb(u_int cpuid) { if (stoppcbs == 0 || pcb_size == 0) return 0; return (stoppcbs + pcb_size * cpuid); } Index: head/devel/gdb/files/kgdb/i386fbsd-kern.c =================================================================== --- head/devel/gdb/files/kgdb/i386fbsd-kern.c (revision 464492) +++ head/devel/gdb/files/kgdb/i386fbsd-kern.c (revision 464493) @@ -1,577 +1,573 @@ /* * Copyright (c) 2004 Marcel Moolenaar * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include __FBSDID("$FreeBSD$"); -#include -#include +#include "defs.h" +#include "frame-unwind.h" +#include "gdbcore.h" +#include "inferior.h" +#include "osabi.h" +#include "regcache.h" +#include "progspace.h" +#include "solib.h" +#include "trad-frame.h" +#include "i386-tdep.h" + #ifdef __i386__ +#include #include #include #include #include #endif -#include -#include -#include -#include "gdbcore.h" -#include -#include "osabi.h" -#include -#include "progspace.h" -#include "solib.h" -#include "trad-frame.h" -#include - #include "kgdb.h" struct i386fbsd_info { int ofs_fix; }; /* Per-program-space data key. */ static const struct program_space_data *i386fbsd_pspace_data; static void i386fbsd_pspace_data_cleanup (struct program_space *pspace, void *arg) { struct i386fbsd_info *info = (struct i386fbsd_info *)arg; xfree (info); } /* Get the current i386fbsd data. If none is found yet, add it now. This function always returns a valid object. */ static struct i386fbsd_info * get_i386fbsd_info (void) { struct i386fbsd_info *info; info = (struct i386fbsd_info *) program_space_data (current_program_space, i386fbsd_pspace_data); if (info != NULL) return info; info = XCNEW (struct i386fbsd_info); set_program_space_data (current_program_space, i386fbsd_pspace_data, info); /* * In revision 1.117 of i386/i386/exception.S trap handlers * were changed to pass trapframes by reference rather than * by value. Detect this by seeing if the first instruction * at the 'calltrap' label is a "push %esp" which has the * opcode 0x54. */ if (parse_and_eval_long("((char *)calltrap)[0]") == 0x54) info->ofs_fix = 4; else info->ofs_fix = 0; return info; } /* * Even though the pcb contains fields for the segment selectors, only * %gs is updated on each context switch. The other selectors are * saved in stoppcbs[], but we just hardcode their known values rather * than handling that special case. */ static const int i386fbsd_pcb_offset[] = { -1, /* %eax */ -1, /* %ecx */ -1, /* %edx */ 4 * 4, /* %ebx */ 3 * 4, /* %esp */ 2 * 4, /* %ebp */ 1 * 4, /* %esi */ 0 * 4, /* %edi */ 5 * 4, /* %eip */ -1, /* %eflags */ -1, /* %cs */ -1, /* %ss */ -1, /* %ds */ -1, /* %es */ -1, /* %fs */ -1, /* %gs */ }; #define CODE_SEL (4 << 3) #define DATA_SEL (5 << 3) #define PRIV_SEL (1 << 3) static void i386fbsd_supply_pcb(struct regcache *regcache, CORE_ADDR pcb_addr) { gdb_byte buf[4]; int i; for (i = 0; i < ARRAY_SIZE (i386fbsd_pcb_offset); i++) if (i386fbsd_pcb_offset[i] != -1) { if (target_read_memory(pcb_addr + i386fbsd_pcb_offset[i], buf, sizeof buf) != 0) continue; - regcache_raw_supply(regcache, i, buf); + regcache->raw_supply(i, buf); } - regcache_raw_supply_unsigned(regcache, I386_CS_REGNUM, CODE_SEL); - regcache_raw_supply_unsigned(regcache, I386_DS_REGNUM, DATA_SEL); - regcache_raw_supply_unsigned(regcache, I386_ES_REGNUM, DATA_SEL); - regcache_raw_supply_unsigned(regcache, I386_FS_REGNUM, PRIV_SEL); - regcache_raw_supply_unsigned(regcache, I386_GS_REGNUM, DATA_SEL); - regcache_raw_supply_unsigned(regcache, I386_SS_REGNUM, DATA_SEL); + regcache->raw_supply_unsigned(I386_CS_REGNUM, CODE_SEL); + regcache->raw_supply_unsigned(I386_DS_REGNUM, DATA_SEL); + regcache->raw_supply_unsigned(I386_ES_REGNUM, DATA_SEL); + regcache->raw_supply_unsigned(I386_FS_REGNUM, PRIV_SEL); + regcache->raw_supply_unsigned(I386_GS_REGNUM, DATA_SEL); + regcache->raw_supply_unsigned(I386_SS_REGNUM, DATA_SEL); } #ifdef __i386__ /* TODO: Make this cross-debugger friendly. */ static const int i386fbsd_tss_offset[] = { 10 * 4, /* %eax */ 11 * 4, /* %ecx */ 12 * 4, /* %edx */ 13 * 4, /* %ebx */ 14 * 4, /* %esp */ 15 * 4, /* %ebp */ 16 * 4, /* %esi */ 17 * 4, /* %edi */ 8 * 4, /* %eip */ 9 * 4, /* %eflags */ 19 * 4, /* %cs */ 20 * 4, /* %ss */ 21 * 4, /* %ds */ 18 * 4, /* %es */ 22 * 4, /* %fs */ 23 * 4, /* %gs */ }; /* * If the current thread is executing on a CPU, fetch the common_tss * for that CPU. * * This is painful because 'struct pcpu' is variant sized, so we can't * use it. Instead, we lookup the GDT selector for this CPU and * extract the base of the TSS from there. */ static CORE_ADDR i386fbsd_fetch_tss(void) { struct kthr *kt; struct segment_descriptor sd; CORE_ADDR addr, cpu0prvpage, tss; kt = kgdb_thr_lookup_tid(ptid_get_tid(inferior_ptid)); if (kt == NULL || kt->cpu == NOCPU || kt->cpu < 0) return (0); addr = kgdb_lookup("gdt"); if (addr == 0) return (0); addr += (kt->cpu * NGDT + GPROC0_SEL) * sizeof(sd); if (target_read_memory(addr, (gdb_byte *)&sd, sizeof(sd)) != 0) return (0); if (sd.sd_type != SDT_SYS386BSY) { warning ("descriptor is not a busy TSS"); return (0); } tss = sd.sd_hibase << 24 | sd.sd_lobase; /* * In SMP kernels, the TSS is stored as part of the per-CPU * data. On older kernels, the CPU0's private page * is stored at an address that isn't mapped in minidumps. * However, the data is mapped at the alternate cpu0prvpage * address. Thus, if the TSS is at the invalid address, * change it to be relative to cpu0prvpage instead. */ if (trunc_page(tss) == 0xffc00000) { TRY { cpu0prvpage = parse_and_eval_address("cpu0prvpage"); } CATCH(e, RETURN_MASK_ERROR) { return (0); } END_CATCH tss = cpu0prvpage + (tss & PAGE_MASK); } return (tss); } static struct trad_frame_cache * i386fbsd_dblfault_cache (struct frame_info *this_frame, void **this_cache) { struct gdbarch *gdbarch = get_frame_arch (this_frame); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); struct trad_frame_cache *cache; CORE_ADDR addr, func, tss; int i; if (*this_cache != NULL) return (struct trad_frame_cache *)(*this_cache); cache = trad_frame_cache_zalloc (this_frame); *this_cache = cache; func = get_frame_func (this_frame); tss = i386fbsd_fetch_tss (); for (i = 0; i < ARRAY_SIZE (i386fbsd_tss_offset); i++) if (i386fbsd_tss_offset[i] != -1) trad_frame_set_reg_addr (cache, i, tss + i386fbsd_tss_offset[i]); /* Construct the frame ID using the function start. */ /* XXX: Stack address should be dbfault_stack + PAGE_SIZE. */ trad_frame_set_id (cache, frame_id_build (tss + sizeof(struct i386tss), func)); return cache; } static void i386fbsd_dblfault_this_id (struct frame_info *this_frame, void **this_cache, struct frame_id *this_id) { struct trad_frame_cache *cache = i386fbsd_dblfault_cache (this_frame, this_cache); trad_frame_get_id (cache, this_id); } static struct value * i386fbsd_dblfault_prev_register (struct frame_info *this_frame, void **this_cache, int regnum) { struct trad_frame_cache *cache = i386fbsd_dblfault_cache (this_frame, this_cache); return trad_frame_get_register (cache, this_frame, regnum); } static int i386fbsd_dblfault_sniffer (const struct frame_unwind *self, struct frame_info *this_frame, void **this_prologue_cache) { const char *name; find_pc_partial_function (get_frame_func (this_frame), &name, NULL, NULL); return (name && strcmp (name, "dblfault_handler") == 0); } static const struct frame_unwind i386fbsd_dblfault_unwind = { SIGTRAMP_FRAME, default_frame_unwind_stop_reason, i386fbsd_dblfault_this_id, i386fbsd_dblfault_prev_register, NULL, i386fbsd_dblfault_sniffer }; #endif static const int i386fbsd_trapframe_offset[] = { 10 * 4, /* %eax */ 9 * 4, /* %ecx */ 8 * 4, /* %edx */ 7 * 4, /* %ebx */ 16 * 4, /* %esp */ 5 * 4, /* %ebp */ 4 * 4, /* %esi */ 3 * 4, /* %edi */ 13 * 4, /* %eip */ 15 * 4, /* %eflags */ 14 * 4, /* %cs */ 17 * 4, /* %ss */ 2 * 4, /* %ds */ 1 * 4, /* %es */ 0 * 4, /* %fs */ -1 /* %gs */ }; #define TRAPFRAME_SIZE 72 static struct trad_frame_cache * i386fbsd_trapframe_cache (struct frame_info *this_frame, void **this_cache) { struct gdbarch *gdbarch = get_frame_arch (this_frame); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); struct trad_frame_cache *cache; struct i386fbsd_info *info; CORE_ADDR addr, cs, func, pc, sp; const char *name; int i; if (*this_cache != NULL) return ((struct trad_frame_cache *)*this_cache); info = get_i386fbsd_info(); cache = trad_frame_cache_zalloc (this_frame); *this_cache = cache; func = get_frame_func (this_frame); sp = get_frame_register_unsigned (this_frame, I386_ESP_REGNUM); find_pc_partial_function (func, &name, NULL, NULL); if (strcmp(name, "calltrap") == 0 || strcmp(name, "Xlcall_syscall") == 0 || strcmp(name, "Xint0x80_syscall") == 0) /* Traps in later kernels pass the trap frame by reference. */ sp += info->ofs_fix; else if (strcmp(name, "Xtimerint") == 0) /* Timer interrupts also pass the trap frame by reference. */ sp += info->ofs_fix; else if (strcmp(name, "Xcpustop") == 0 || strcmp(name, "Xrendezvous") == 0 || strcmp(name, "Xipi_intr_bitmap_handler") == 0 || strcmp(name, "Xlazypmap") == 0) /* These handlers push a trap frame only. */ ; else if (strcmp(name, "fork_trampoline") == 0) if (get_frame_pc (this_frame) == func) { /* fork_exit hasn't been called (kthread has never run), so %esp in the pcb points to the word above the trapframe. */ sp += 4; } else { /* fork_exit has been called, so %esp in fork_exit's frame is &tf - 12. */ sp += 12; } else { /* Interrupt frames pass the IDT vector in addition to the trap frame. */ sp += info->ofs_fix + 4; } addr = sp + i386fbsd_trapframe_offset[I386_CS_REGNUM]; cs = read_memory_unsigned_integer (addr, 4, byte_order); for (i = 0; i < ARRAY_SIZE (i386fbsd_trapframe_offset); i++) { /* %ss/%esp are only present in the trapframe for a trap from userland. */ if ((cs & I386_SEL_RPL) == I386_SEL_KPL) { if (i == I386_SS_REGNUM) continue; if (i == I386_ESP_REGNUM) { trad_frame_set_reg_value (cache, i, sp + TRAPFRAME_SIZE - 8); continue; } } if (i386fbsd_trapframe_offset[i] != -1) trad_frame_set_reg_addr (cache, i, sp + i386fbsd_trapframe_offset[i]); } /* Read %eip from trap frame. */ addr = sp + i386fbsd_trapframe_offset[I386_EIP_REGNUM]; pc = read_memory_unsigned_integer (addr, 4, byte_order); if (pc == 0 && strcmp(name, "fork_trampoline") == 0) { /* Initial frame of a kthread; terminate backtrace. */ trad_frame_set_id (cache, outer_frame_id); } else { /* Construct the frame ID using the function start. */ sp += TRAPFRAME_SIZE; if ((cs & I386_SEL_RPL) == I386_SEL_KPL) sp -= 8; trad_frame_set_id (cache, frame_id_build (sp, func)); } return cache; } static void i386fbsd_trapframe_this_id (struct frame_info *this_frame, void **this_cache, struct frame_id *this_id) { struct trad_frame_cache *cache = i386fbsd_trapframe_cache (this_frame, this_cache); trad_frame_get_id (cache, this_id); } static struct value * i386fbsd_trapframe_prev_register (struct frame_info *this_frame, void **this_cache, int regnum) { struct trad_frame_cache *cache = i386fbsd_trapframe_cache (this_frame, this_cache); return trad_frame_get_register (cache, this_frame, regnum); } static int i386fbsd_trapframe_sniffer (const struct frame_unwind *self, struct frame_info *this_frame, void **this_prologue_cache) { const char *name; find_pc_partial_function (get_frame_func (this_frame), &name, NULL, NULL); return (name && ((strcmp (name, "calltrap") == 0) || (strcmp (name, "fork_trampoline") == 0) || (name[0] == 'X' && name[1] != '_'))); } static const struct frame_unwind i386fbsd_trapframe_unwind = { SIGTRAMP_FRAME, default_frame_unwind_stop_reason, i386fbsd_trapframe_this_id, i386fbsd_trapframe_prev_register, NULL, i386fbsd_trapframe_sniffer }; static void i386fbsd_kernel_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch) { i386_elf_init_abi(info, gdbarch); #ifdef __i386__ frame_unwind_prepend_unwinder(gdbarch, &i386fbsd_dblfault_unwind); #endif frame_unwind_prepend_unwinder(gdbarch, &i386fbsd_trapframe_unwind); set_solib_ops(gdbarch, &kld_so_ops); fbsd_vmcore_set_supply_pcb(gdbarch, i386fbsd_supply_pcb); fbsd_vmcore_set_cpu_pcb_addr(gdbarch, kgdb_trgt_stop_pcb); } - -void _initialize_i386_kgdb_tdep(void); void _initialize_i386_kgdb_tdep(void) { /* This is used for both i386 and amd64, but amd64 always includes this target, so just include it here. */ gdbarch_register_osabi_sniffer(bfd_arch_i386, bfd_target_elf_flavour, fbsd_kernel_osabi_sniffer); gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_FREEBSD_KERNEL, i386fbsd_kernel_init_abi); i386fbsd_pspace_data = register_program_space_data_with_cleanup (NULL, i386fbsd_pspace_data_cleanup); #ifdef __i386__ /* * FreeBSD/i386 kernels prior to the introduction of AVX * support used a different layout for the PCB. If gdb is * compiled on these systems, these asserts will fail. The * package builders build packages on older systems which are * then run on newer systems. These binaries trip over these * assertions even when debugging user programs and even * though the running kernel is new enough. To cope, disable * the assertion checks unless gdb is built against a new * enough world. Note that this means kgdb is not going to * parse PCBs correctly on FreeBSD/i386 kernels before AVX was * merged. */ #if __FreeBSD_version >= 1001505 gdb_assert(offsetof(struct pcb, pcb_ebx) == i386fbsd_pcb_offset[I386_EBX_REGNUM]); gdb_assert(offsetof(struct pcb, pcb_esp) == i386fbsd_pcb_offset[I386_ESP_REGNUM]); gdb_assert(offsetof(struct pcb, pcb_ebp) == i386fbsd_pcb_offset[I386_EBP_REGNUM]); gdb_assert(offsetof(struct pcb, pcb_esi) == i386fbsd_pcb_offset[I386_ESI_REGNUM]); gdb_assert(offsetof(struct pcb, pcb_edi) == i386fbsd_pcb_offset[I386_EDI_REGNUM]); gdb_assert(offsetof(struct pcb, pcb_eip) == i386fbsd_pcb_offset[I386_EIP_REGNUM]); #endif gdb_assert(CODE_SEL == GSEL(GCODE_SEL, SEL_KPL)); gdb_assert(DATA_SEL == GSEL(GDATA_SEL, SEL_KPL)); gdb_assert(PRIV_SEL == GSEL(GPRIV_SEL, SEL_KPL)); gdb_assert(sizeof(struct trapframe) == TRAPFRAME_SIZE); gdb_assert(offsetof(struct trapframe, tf_eax) == i386fbsd_trapframe_offset[I386_EAX_REGNUM]); gdb_assert(offsetof(struct trapframe, tf_ecx) == i386fbsd_trapframe_offset[I386_ECX_REGNUM]); gdb_assert(offsetof(struct trapframe, tf_edx) == i386fbsd_trapframe_offset[I386_EDX_REGNUM]); gdb_assert(offsetof(struct trapframe, tf_ebx) == i386fbsd_trapframe_offset[I386_EBX_REGNUM]); gdb_assert(offsetof(struct trapframe, tf_esp) == i386fbsd_trapframe_offset[I386_ESP_REGNUM]); gdb_assert(offsetof(struct trapframe, tf_ebp) == i386fbsd_trapframe_offset[I386_EBP_REGNUM]); gdb_assert(offsetof(struct trapframe, tf_esi) == i386fbsd_trapframe_offset[I386_ESI_REGNUM]); gdb_assert(offsetof(struct trapframe, tf_edi) == i386fbsd_trapframe_offset[I386_EDI_REGNUM]); gdb_assert(offsetof(struct trapframe, tf_eip) == i386fbsd_trapframe_offset[I386_EIP_REGNUM]); gdb_assert(offsetof(struct trapframe, tf_eflags) == i386fbsd_trapframe_offset[I386_EFLAGS_REGNUM]); gdb_assert(offsetof(struct trapframe, tf_cs) == i386fbsd_trapframe_offset[I386_CS_REGNUM]); gdb_assert(offsetof(struct trapframe, tf_ss) == i386fbsd_trapframe_offset[I386_SS_REGNUM]); gdb_assert(offsetof(struct trapframe, tf_ds) == i386fbsd_trapframe_offset[I386_DS_REGNUM]); gdb_assert(offsetof(struct trapframe, tf_es) == i386fbsd_trapframe_offset[I386_ES_REGNUM]); gdb_assert(offsetof(struct trapframe, tf_fs) == i386fbsd_trapframe_offset[I386_FS_REGNUM]); gdb_assert(offsetof(struct i386tss, tss_eax) == i386fbsd_tss_offset[I386_EAX_REGNUM]); gdb_assert(offsetof(struct i386tss, tss_ecx) == i386fbsd_tss_offset[I386_ECX_REGNUM]); gdb_assert(offsetof(struct i386tss, tss_edx) == i386fbsd_tss_offset[I386_EDX_REGNUM]); gdb_assert(offsetof(struct i386tss, tss_ebx) == i386fbsd_tss_offset[I386_EBX_REGNUM]); gdb_assert(offsetof(struct i386tss, tss_esp) == i386fbsd_tss_offset[I386_ESP_REGNUM]); gdb_assert(offsetof(struct i386tss, tss_ebp) == i386fbsd_tss_offset[I386_EBP_REGNUM]); gdb_assert(offsetof(struct i386tss, tss_esi) == i386fbsd_tss_offset[I386_ESI_REGNUM]); gdb_assert(offsetof(struct i386tss, tss_edi) == i386fbsd_tss_offset[I386_EDI_REGNUM]); gdb_assert(offsetof(struct i386tss, tss_eip) == i386fbsd_tss_offset[I386_EIP_REGNUM]); gdb_assert(offsetof(struct i386tss, tss_eflags) == i386fbsd_tss_offset[I386_EFLAGS_REGNUM]); gdb_assert(offsetof(struct i386tss, tss_cs) == i386fbsd_tss_offset[I386_CS_REGNUM]); gdb_assert(offsetof(struct i386tss, tss_ss) == i386fbsd_tss_offset[I386_SS_REGNUM]); gdb_assert(offsetof(struct i386tss, tss_ds) == i386fbsd_tss_offset[I386_DS_REGNUM]); gdb_assert(offsetof(struct i386tss, tss_es) == i386fbsd_tss_offset[I386_ES_REGNUM]); gdb_assert(offsetof(struct i386tss, tss_fs) == i386fbsd_tss_offset[I386_FS_REGNUM]); gdb_assert(offsetof(struct i386tss, tss_gs) == i386fbsd_tss_offset[I386_GS_REGNUM]); #endif } Index: head/devel/gdb/files/kgdb/kgdb-main.c =================================================================== --- head/devel/gdb/files/kgdb/kgdb-main.c (revision 464492) +++ head/devel/gdb/files/kgdb/kgdb-main.c (revision 464493) @@ -1,407 +1,411 @@ /* * Copyright (c) 2004 Marcel Moolenaar * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include __FBSDID("$FreeBSD$"); #include #include #include #include #include #include #include #include #include #include #include #include #include /* libgdb stuff. */ #include #include #include #include #include #include #include #include #include "observer.h" #include #include #include #include #include #include #include "kgdb.h" static int verbose; static char crashdir[PATH_MAX]; static char *dumpnr; static char *kernel; static char *remote; static char *vmcore; /* * TODO: * - test remote kgdb (see if threads and klds work) * - possibly split kthr.c out into a separate thread_stratum target that * uses new_objfile test to push itself when a FreeBSD kernel is loaded * (check for kernel osabi) (probably don't bother with this) * + test alternate kgdb_lookup() * + fix kgdb build on amd64 to include i386 cross-debug support * - propose expanded libkvm interface that supports cross-debug and moves * MD bits of kgdb into the library (examining PCB's and exporting a * stable-ABI struct of registers, similarly for trapframe handling and * stop-pcb stuff * + use tid's as lwp IDs instead of PIDs in ptid's */ static void usage(void) { fprintf(stderr, "usage: %s [-afqvw] [-b rate] [-d crashdir] [-c core | -n dumpnr | -r device]\n" "\t[kernel [core]]\n", getprogname()); exit(1); } static void kernel_from_dumpnr(const char *nr) { char line[PATH_MAX], path[PATH_MAX]; FILE *info; char *dir; struct stat st; int l; /* * If there's a kernel image right here in the crash directory, then * use it. The kernel image is either called kernel. or is in a * subdirectory kernel. and called kernel. The latter allows us * to collect the modules in the same place. */ snprintf(path, sizeof(path), "%s/kernel.%s", crashdir, nr); if (stat(path, &st) == 0) { if (S_ISREG(st.st_mode)) { kernel = strdup(path); return; } if (S_ISDIR(st.st_mode)) { snprintf(path, sizeof(path), "%s/kernel.%s/kernel", crashdir, nr); if (stat(path, &st) == 0 && S_ISREG(st.st_mode)) { kernel = strdup(path); return; } } } /* * No kernel image here. Parse the dump header. The kernel object * directory can be found there and we probably have the kernel * image still in it. The object directory may also have a kernel * with debugging info (called either kernel.full or kernel.debug). * If we have a debug kernel, use it. */ snprintf(path, sizeof(path), "%s/info.%s", crashdir, nr); info = fopen(path, "r"); if (info == NULL) { warn("%s", path); return; } while (fgets(line, sizeof(line), info) != NULL) { l = strlen(line); if (l > 0 && line[l - 1] == '\n') line[--l] = '\0'; if (strncmp(line, " ", 4) == 0) { fclose(info); dir = strchr(line, ':'); dir = (dir == NULL) ? line + 4 : dir + 1; /* * Check for kernel.full first as if it exists * kernel.debug will also exist, but will only * contain debug symbols and not be recognized * as a valid kernel by the osabi sniffer. */ snprintf(path, sizeof(path), "%s/kernel.full", dir); if (stat(path, &st) == 0 && S_ISREG(st.st_mode)) { kernel = strdup(path); return; } snprintf(path, sizeof(path), "%s/kernel.debug", dir); if (stat(path, &st) == 0 && S_ISREG(st.st_mode)) { kernel = strdup(path); return; } snprintf(path, sizeof(path), "%s/kernel", dir); if (stat(path, &st) == 0 && S_ISREG(st.st_mode)) { kernel = strdup(path); return; } return; } } fclose(info); } /* * Remote targets can support any number of syntaxes and we want to * support them all with one addition: we support specifying a device * node for a serial device without the "/dev/" prefix. * * What we do is to stat(2) the existing remote target first. If that * fails, we try it with "/dev/" prepended. If that succeeds we use * the resulting path, otherwise we use the original target. If * either stat(2) succeeds make sure the file is either a character * device or a FIFO. */ static void verify_remote(void) { char path[PATH_MAX]; struct stat st; if (stat(remote, &st) != 0) { snprintf(path, sizeof(path), "/dev/%s", remote); if (stat(path, &st) != 0) return; free(remote); remote = strdup(path); } if (!S_ISCHR(st.st_mode) && !S_ISFIFO(st.st_mode)) errx(1, "%s: not a special file, FIFO or socket", remote); } static void add_arg(struct captured_main_args *args, char const *arg) { args->argc++; args->argv = (char **)reallocf(args->argv, (args->argc + 1) * sizeof(char *)); if (args->argv == NULL) err(1, "Out of memory building argument list"); args->argv[args->argc] = (char *)arg; } int main(int argc, char *argv[]) { char path[PATH_MAX]; struct stat st; struct captured_main_args args; char *s; int a, ch; dumpnr = NULL; strlcpy(crashdir, "/var/crash", sizeof(crashdir)); s = getenv("KGDB_CRASH_DIR"); if (s != NULL) strlcpy(crashdir, s, sizeof(crashdir)); /* Convert long options into short options. */ for (a = 1; a < argc; a++) { s = argv[a]; if (s[0] == '-') { s++; /* Long options take either 1 or 2 dashes. */ if (s[0] == '-') s++; if (strcmp(s, "quiet") == 0) argv[a] = (char *)"-q"; else if (strcmp(s, "fullname") == 0) argv[a] = (char *)"-f"; } } kgdb_quiet = 0; memset (&args, 0, sizeof args); args.interpreter_p = INTERP_CONSOLE; args.argv = (char **)xmalloc(sizeof(char *)); args.argv[0] = argv[0]; while ((ch = getopt(argc, argv, "ab:c:d:fn:qr:vw")) != -1) { switch (ch) { case 'a': annotation_level++; break; case 'b': { int i; char *p; i = strtol(optarg, &p, 0); if (*p != '\0' || p == optarg) warnx("warning: could not set baud rate to `%s'.\n", optarg); else baud_rate = i; break; } case 'c': /* use given core file. */ if (vmcore != NULL) { warnx("option %c: can only be specified once", optopt); usage(); /* NOTREACHED */ } vmcore = strdup(optarg); break; case 'd': /* lookup dumps in given directory. */ strlcpy(crashdir, optarg, sizeof(crashdir)); break; case 'f': annotation_level = 1; break; case 'n': /* use dump with given number. */ dumpnr = optarg; break; case 'q': kgdb_quiet = 1; add_arg(&args, "-q"); break; case 'r': /* use given device for remote session. */ if (remote != NULL) { warnx("option %c: can only be specified once", optopt); usage(); /* NOTREACHED */ } remote = strdup(optarg); break; case 'v': /* increase verbosity. */ verbose++; break; case 'w': /* core file is writeable. */ add_arg(&args, "--write"); break; case '?': default: usage(); } } if (((vmcore != NULL) ? 1 : 0) + ((dumpnr != NULL) ? 1 : 0) + ((remote != NULL) ? 1 : 0) > 1) { warnx("options -c, -n and -r are mutually exclusive"); usage(); /* NOTREACHED */ } if (verbose > 1) warnx("using %s as the crash directory", crashdir); if (argc > optind) kernel = strdup(argv[optind++]); if (argc > optind && (dumpnr != NULL || remote != NULL)) { warnx("options -n and -r do not take a core file. Ignored"); optind = argc; } if (dumpnr != NULL) { snprintf(path, sizeof(path), "%s/vmcore.%s", crashdir, dumpnr); if (stat(path, &st) == -1) err(1, "%s", path); if (!S_ISREG(st.st_mode)) errx(1, "%s: not a regular file", path); vmcore = strdup(path); } else if (remote != NULL) { verify_remote(); } else if (argc > optind) { if (vmcore == NULL) vmcore = strdup(argv[optind++]); if (argc > optind) warnx("multiple core files specified. Ignored"); } else if (vmcore == NULL && kernel == NULL) { vmcore = strdup(_PATH_MEM); kernel = strdup(getbootfile()); } if (verbose) { if (vmcore != NULL) warnx("core file: %s", vmcore); if (remote != NULL) warnx("device file: %s", remote); if (kernel != NULL) warnx("kernel image: %s", kernel); } /* A remote target requires an explicit kernel argument. */ if (remote != NULL && kernel == NULL) { warnx("remote debugging requires a kernel"); usage(); /* NOTREACHED */ } /* If we don't have a kernel image yet, try to find one. */ if (kernel == NULL) { if (dumpnr != NULL) kernel_from_dumpnr(dumpnr); if (kernel == NULL) errx(1, "couldn't find a suitable kernel image"); if (verbose) warnx("kernel image: %s", kernel); } /* Set an alternate prompt. */ add_arg(&args, "-iex"); add_arg(&args, "set prompt (kgdb) "); + /* Change osabi to assume a FreeBSD kernel. */ + add_arg(&args, "-iex"); + add_arg(&args, "set osabi FreeBSD/kernel"); + /* Open the vmcore if requested. */ if (vmcore != NULL) { add_arg(&args, "-ex"); if (asprintf(&s, "target vmcore %s", vmcore) < 0) err(1, "couldn't build command line"); add_arg(&args, s); } /* Open the remote target if requested. */ if (remote != NULL) { add_arg(&args, "-ex"); if (asprintf(&s, "target remote %s", remote) < 0) err(1, "couldn't build command line"); add_arg(&args, s); } add_arg(&args, kernel); /* The libgdb code uses optind too. Reset it... */ optind = 0; /* Terminate argv list. */ add_arg(&args, NULL); return (gdb_main(&args)); } Index: head/devel/gdb/files/kgdb/mipsfbsd-kern.c =================================================================== --- head/devel/gdb/files/kgdb/mipsfbsd-kern.c (revision 464492) +++ head/devel/gdb/files/kgdb/mipsfbsd-kern.c (revision 464493) @@ -1,305 +1,298 @@ /* * Copyright (c) 2007 Juniper Networks, Inc. * Copyright (c) 2004 Marcel Moolenaar * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * from: src/gnu/usr.bin/gdb/kgdb/trgt_alpha.c,v 1.2.2.1 2005/09/15 05:32:10 marcel */ #include __FBSDID("$FreeBSD: head/gnu/usr.bin/gdb/kgdb/trgt_mips.c 249878 2013-04-25 04:53:01Z imp $"); -#include +#include "defs.h" +#include "frame-unwind.h" +#include "osabi.h" +#include "regcache.h" +#include "solib.h" +#include "trad-frame.h" +#include "mips-tdep.h" + #ifdef __mips__ #include #include #include #endif -#include -#include -#include -//#include -//#include -//#include -#include "osabi.h" -#include -#include "solib.h" -#include "trad-frame.h" -#include - #include "kgdb.h" /* Size of struct trapframe in registers. */ #define TRAPFRAME_WORDS 74 /* From sys/mips/include/pcb.h. Offsets in the pcb_context[] array. */ #define FBSD_PCB_REG_S0 0 #define FBSD_PCB_REG_S1 1 #define FBSD_PCB_REG_S2 2 #define FBSD_PCB_REG_S3 3 #define FBSD_PCB_REG_S4 4 #define FBSD_PCB_REG_S5 5 #define FBSD_PCB_REG_S6 6 #define FBSD_PCB_REG_S7 7 #define FBSD_PCB_REG_SP 8 #define FBSD_PCB_REG_S8 9 #define FBSD_PCB_REG_RA 10 #define FBSD_PCB_REG_SR 11 #define FBSD_PCB_REG_GP 12 #define FBSD_PCB_REG_PC 13 #ifdef __mips__ _Static_assert(TRAPFRAME_WORDS * sizeof(register_t) == sizeof(struct trapframe), "TRAPFRAME_WORDS mismatch"); _Static_assert(FBSD_PCB_REG_S0 == PCB_REG_S0, "PCB_REG_S0 mismatch"); _Static_assert(FBSD_PCB_REG_S1 == PCB_REG_S1, "PCB_REG_S1 mismatch"); _Static_assert(FBSD_PCB_REG_S2 == PCB_REG_S2, "PCB_REG_S2 mismatch"); _Static_assert(FBSD_PCB_REG_S3 == PCB_REG_S3, "PCB_REG_S3 mismatch"); _Static_assert(FBSD_PCB_REG_S4 == PCB_REG_S4, "PCB_REG_S4 mismatch"); _Static_assert(FBSD_PCB_REG_S5 == PCB_REG_S5, "PCB_REG_S5 mismatch"); _Static_assert(FBSD_PCB_REG_S6 == PCB_REG_S6, "PCB_REG_S6 mismatch"); _Static_assert(FBSD_PCB_REG_S7 == PCB_REG_S7, "PCB_REG_S7 mismatch"); _Static_assert(FBSD_PCB_REG_SP == PCB_REG_SP, "PCB_REG_SP mismatch"); _Static_assert(FBSD_PCB_REG_S8 == PCB_REG_S8, "PCB_REG_S8 mismatch"); _Static_assert(FBSD_PCB_REG_RA == PCB_REG_RA, "PCB_REG_RA mismatch"); _Static_assert(FBSD_PCB_REG_SR == PCB_REG_SR, "PCB_REG_SR mismatch"); _Static_assert(FBSD_PCB_REG_GP == PCB_REG_GP, "PCB_REG_GP mismatch"); _Static_assert(FBSD_PCB_REG_PC == PCB_REG_PC, "PCB_REG_PC mismatch"); #endif static void mipsfbsd_supply_pcb(struct regcache *regcache, CORE_ADDR pcb_addr) { - struct gdbarch *gdbarch = get_regcache_arch (regcache); + struct gdbarch *gdbarch = regcache->arch (); size_t regsize = mips_isa_regsize (gdbarch); gdb_byte buf[regsize * (FBSD_PCB_REG_PC + 1)]; /* Read the entire pcb_context[] array in one go. The pcb_context[] array is after the pcb_regs member which is a trapframe. */ if (target_read_memory (pcb_addr + TRAPFRAME_WORDS * regsize, buf, sizeof(buf)) != 0) return; - regcache_raw_supply_unsigned (regcache, MIPS_ZERO_REGNUM, 0); - regcache_raw_supply (regcache, MIPS_S2_REGNUM - 2, - buf + (regsize * FBSD_PCB_REG_S0)); - regcache_raw_supply (regcache, MIPS_S2_REGNUM - 1, - buf + (regsize * FBSD_PCB_REG_S1)); - regcache_raw_supply (regcache, MIPS_S2_REGNUM, - buf + (regsize * FBSD_PCB_REG_S2)); - regcache_raw_supply (regcache, MIPS_S2_REGNUM + 1, - buf + (regsize * FBSD_PCB_REG_S3)); - regcache_raw_supply (regcache, MIPS_S2_REGNUM + 2, - buf + (regsize * FBSD_PCB_REG_S4)); - regcache_raw_supply (regcache, MIPS_S2_REGNUM + 3, - buf + (regsize * FBSD_PCB_REG_S5)); - regcache_raw_supply (regcache, MIPS_S2_REGNUM + 4, - buf + (regsize * FBSD_PCB_REG_S6)); - regcache_raw_supply (regcache, MIPS_S2_REGNUM + 5, - buf + (regsize * FBSD_PCB_REG_S7)); - regcache_raw_supply (regcache, MIPS_SP_REGNUM, - buf + (regsize * FBSD_PCB_REG_SP)); - regcache_raw_supply (regcache, MIPS_S2_REGNUM + 6, - buf + (regsize * FBSD_PCB_REG_S8)); - regcache_raw_supply (regcache, MIPS_RA_REGNUM, - buf + (regsize * FBSD_PCB_REG_RA)); - regcache_raw_supply (regcache, MIPS_PS_REGNUM, - buf + (regsize * FBSD_PCB_REG_SR)); - regcache_raw_supply (regcache, MIPS_GP_REGNUM, - buf + (regsize * FBSD_PCB_REG_GP)); - regcache_raw_supply (regcache, MIPS_EMBED_PC_REGNUM, - buf + (regsize * FBSD_PCB_REG_PC)); + regcache->raw_supply_unsigned (MIPS_ZERO_REGNUM, 0); + regcache->raw_supply (MIPS_S2_REGNUM - 2, + buf + (regsize * FBSD_PCB_REG_S0)); + regcache->raw_supply (MIPS_S2_REGNUM - 1, + buf + (regsize * FBSD_PCB_REG_S1)); + regcache->raw_supply (MIPS_S2_REGNUM, + buf + (regsize * FBSD_PCB_REG_S2)); + regcache->raw_supply (MIPS_S2_REGNUM + 1, + buf + (regsize * FBSD_PCB_REG_S3)); + regcache->raw_supply (MIPS_S2_REGNUM + 2, + buf + (regsize * FBSD_PCB_REG_S4)); + regcache->raw_supply (MIPS_S2_REGNUM + 3, + buf + (regsize * FBSD_PCB_REG_S5)); + regcache->raw_supply (MIPS_S2_REGNUM + 4, + buf + (regsize * FBSD_PCB_REG_S6)); + regcache->raw_supply (MIPS_S2_REGNUM + 5, + buf + (regsize * FBSD_PCB_REG_S7)); + regcache->raw_supply (MIPS_SP_REGNUM, + buf + (regsize * FBSD_PCB_REG_SP)); + regcache->raw_supply (MIPS_S2_REGNUM + 6, + buf + (regsize * FBSD_PCB_REG_S8)); + regcache->raw_supply (MIPS_RA_REGNUM, + buf + (regsize * FBSD_PCB_REG_RA)); + regcache->raw_supply (MIPS_PS_REGNUM, + buf + (regsize * FBSD_PCB_REG_SR)); + regcache->raw_supply (MIPS_GP_REGNUM, + buf + (regsize * FBSD_PCB_REG_GP)); + regcache->raw_supply (MIPS_EMBED_PC_REGNUM, + buf + (regsize * FBSD_PCB_REG_PC)); } static struct trad_frame_cache * mipsfbsd_trapframe_cache (struct frame_info *this_frame, void **this_cache) { struct gdbarch *gdbarch = get_frame_arch (this_frame); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); size_t regsize = mips_isa_regsize (gdbarch); struct trad_frame_cache *cache; CORE_ADDR addr, func, pc, sp; int regnum; if (*this_cache != NULL) return ((struct trad_frame_cache *)*this_cache); cache = trad_frame_cache_zalloc (this_frame); *this_cache = cache; func = get_frame_func (this_frame); sp = get_frame_register_signed (this_frame, MIPS_SP_REGNUM + gdbarch_num_regs (gdbarch)); /* Skip over CALLFRAME_SIZ. */ addr = sp; if (regsize == 8) addr += regsize * 4; else addr += regsize * (4 + 2); /* GPRs. Skip zero. */ addr += regsize; for (regnum = MIPS_AT_REGNUM; regnum <= MIPS_RA_REGNUM; regnum++) { trad_frame_set_reg_addr (cache, regnum + gdbarch_num_regs (gdbarch), addr); addr += regsize; } regnum = MIPS_PS_REGNUM; trad_frame_set_reg_addr (cache, regnum + gdbarch_num_regs (gdbarch), addr); addr += regsize; /* HI and LO. */ regnum = mips_regnum (gdbarch)->lo; trad_frame_set_reg_addr (cache, regnum + gdbarch_num_regs (gdbarch), addr); addr += regsize; regnum = mips_regnum (gdbarch)->hi; trad_frame_set_reg_addr (cache, regnum + gdbarch_num_regs (gdbarch), addr); addr += regsize; /* BADVADDR. */ regnum = mips_regnum (gdbarch)->badvaddr; trad_frame_set_reg_addr (cache, regnum + gdbarch_num_regs (gdbarch), addr); addr += regsize; /* CAUSE. */ regnum = mips_regnum (gdbarch)->cause; trad_frame_set_reg_addr (cache, regnum + gdbarch_num_regs (gdbarch), addr); addr += regsize; /* PC. */ regnum = mips_regnum (gdbarch)->pc; trad_frame_set_reg_addr (cache, regnum + gdbarch_num_regs (gdbarch), addr); trad_frame_set_id (cache, frame_id_build (sp + TRAPFRAME_WORDS * regsize, func)); return cache; } static void mipsfbsd_trapframe_this_id (struct frame_info *this_frame, void **this_cache, struct frame_id *this_id) { struct trad_frame_cache *cache = mipsfbsd_trapframe_cache (this_frame, this_cache); trad_frame_get_id (cache, this_id); } static struct value * mipsfbsd_trapframe_prev_register (struct frame_info *this_frame, void **this_cache, int regnum) { struct trad_frame_cache *cache = mipsfbsd_trapframe_cache (this_frame, this_cache); return trad_frame_get_register (cache, this_frame, regnum); } static int mipsfbsd_trapframe_sniffer (const struct frame_unwind *self, struct frame_info *this_frame, void **this_prologue_cache) { const char *name; find_pc_partial_function (get_frame_func (this_frame), &name, NULL, NULL); return (name && ((strcmp(name, "MipsKernIntr") == 0) || (strcmp(name, "MipsKernGenException") == 0) || (strcmp(name, "MipsTLBInvalidException") == 0))); } static const struct frame_unwind mipsfbsd_trapframe_unwind = { SIGTRAMP_FRAME, default_frame_unwind_stop_reason, mipsfbsd_trapframe_this_id, mipsfbsd_trapframe_prev_register, NULL, mipsfbsd_trapframe_sniffer }; static void mipsfbsd_kernel_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { enum mips_abi abi = mips_abi (gdbarch); set_gdbarch_software_single_step (gdbarch, mips_software_single_step); switch (abi) { case MIPS_ABI_O32: break; case MIPS_ABI_N32: set_gdbarch_long_double_bit (gdbarch, 128); /* These floatformats should probably be renamed. MIPS uses the same 128-bit IEEE floating point format that IA-64 uses, except that the quiet/signalling NaN bit is reversed (GDB does not distinguish between quiet and signalling NaNs). */ set_gdbarch_long_double_format (gdbarch, floatformats_ia64_quad); break; case MIPS_ABI_N64: set_gdbarch_long_double_bit (gdbarch, 128); /* These floatformats should probably be renamed. MIPS uses the same 128-bit IEEE floating point format that IA-64 uses, except that the quiet/signalling NaN bit is reversed (GDB does not distinguish between quiet and signalling NaNs). */ set_gdbarch_long_double_format (gdbarch, floatformats_ia64_quad); break; } frame_unwind_prepend_unwinder (gdbarch, &mipsfbsd_trapframe_unwind); set_solib_ops (gdbarch, &kld_so_ops); fbsd_vmcore_set_supply_pcb (gdbarch, mipsfbsd_supply_pcb); fbsd_vmcore_set_cpu_pcb_addr (gdbarch, kgdb_trgt_stop_pcb); } - -void _initialize_mips_kgdb_tdep (void); void _initialize_mips_kgdb_tdep (void) { gdbarch_register_osabi_sniffer(bfd_arch_mips, bfd_target_elf_flavour, fbsd_kernel_osabi_sniffer); gdbarch_register_osabi (bfd_arch_mips, 0, GDB_OSABI_FREEBSD_KERNEL, mipsfbsd_kernel_init_abi); } Index: head/devel/gdb/files/kgdb/ppcfbsd-kern.c =================================================================== --- head/devel/gdb/files/kgdb/ppcfbsd-kern.c (revision 464492) +++ head/devel/gdb/files/kgdb/ppcfbsd-kern.c (revision 464493) @@ -1,254 +1,249 @@ /*- * Copyright (c) 2006 Marcel Moolenaar * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include __FBSDID("$FreeBSD$"); -#include -#ifdef __powerpc__ -#include -#include -#endif -#include - -#include -#include +#include "defs.h" +#include "frame-unwind.h" #include "gdbcore.h" #include "osabi.h" #include "regcache.h" #include "solib.h" #include "symtab.h" #include "trad-frame.h" - -#include +#include "ppc-tdep.h" #include "ppc64-tdep.h" +#ifdef __powerpc__ +#include +#include +#endif + #include "kgdb.h" #ifdef __powerpc__ static void ppcfbsd_supply_pcb(struct regcache *regcache, CORE_ADDR pcb_addr) { struct pcb pcb; struct gdbarch_tdep *tdep; int i; - tdep = gdbarch_tdep (target_gdbarch()); + tdep = gdbarch_tdep (regcache->arch ()); if (target_read_memory(pcb_addr, (gdb_byte *)&pcb, sizeof(pcb)) != 0) memset(&pcb, 0, sizeof(pcb)); /* * r14-r31 are saved in the pcb */ for (i = 14; i <= 31; i++) { - regcache_raw_supply(regcache, tdep->ppc_gp0_regnum + i, + regcache->raw_supply(tdep->ppc_gp0_regnum + i, (char *)&pcb.pcb_context[i]); } /* r1 is saved in the sp field */ - regcache_raw_supply(regcache, tdep->ppc_gp0_regnum + 1, + regcache->raw_supply(tdep->ppc_gp0_regnum + 1, (char *)&pcb.pcb_sp); if (tdep->wordsize == 8) /* r2 is saved in the toc field */ - regcache_raw_supply(regcache, tdep->ppc_gp0_regnum + 2, + regcache->raw_supply(tdep->ppc_gp0_regnum + 2, (char *)&pcb.pcb_toc); - regcache_raw_supply(regcache, tdep->ppc_lr_regnum, (char *)&pcb.pcb_lr); - regcache_raw_supply(regcache, tdep->ppc_cr_regnum, (char *)&pcb.pcb_cr); + regcache->raw_supply(tdep->ppc_lr_regnum, (char *)&pcb.pcb_lr); + regcache->raw_supply(tdep->ppc_cr_regnum, (char *)&pcb.pcb_cr); } #endif #define OFF_FIXREG 0 #define OFF_LR 32 #define OFF_CR 33 #define OFF_XER 34 #define OFF_CTR 35 #define OFF_SRR0 36 #define TRAPFRAME_SIZE 42 #ifdef __powerpc__ _Static_assert(sizeof(struct trapframe) == TRAPFRAME_SIZE * sizeof(register_t), "trapframe size"); _Static_assert(offsetof(struct trapframe, fixreg) == OFF_FIXREG * sizeof(register_t), "fixreg offset"); _Static_assert(offsetof(struct trapframe, lr) == OFF_LR * sizeof(register_t), "lr offset"); _Static_assert(offsetof(struct trapframe, cr) == OFF_CR * sizeof(register_t), "cr offset"); _Static_assert(offsetof(struct trapframe, xer) == OFF_XER * sizeof(register_t), "xer offset"); _Static_assert(offsetof(struct trapframe, ctr) == OFF_CTR * sizeof(register_t), "ctr offset"); _Static_assert(offsetof(struct trapframe, srr0) == OFF_SRR0 * sizeof(register_t), "srr0 offset"); #endif static struct trad_frame_cache * ppcfbsd_trapframe_cache (struct frame_info *this_frame, void **this_cache) { struct gdbarch *gdbarch = get_frame_arch (this_frame); struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); struct trad_frame_cache *cache; CORE_ADDR base; int i, regnum; if (*this_cache) return (struct trad_frame_cache *)*this_cache; cache = trad_frame_cache_zalloc (this_frame); *this_cache = cache; base = get_frame_register_unsigned (this_frame, gdbarch_sp_regnum (gdbarch)); if (tdep->wordsize == 8) base += 48; else base += 8; for (i = 0; i < ppc_num_gprs; i++) trad_frame_set_reg_addr (cache, tdep->ppc_gp0_regnum + i, base + (OFF_FIXREG + i) * tdep->wordsize); trad_frame_set_reg_addr (cache, tdep->ppc_lr_regnum, base + OFF_LR * tdep->wordsize); trad_frame_set_reg_addr (cache, tdep->ppc_cr_regnum, base + OFF_CR * tdep->wordsize); trad_frame_set_reg_addr (cache, tdep->ppc_xer_regnum, base + OFF_XER * tdep->wordsize); trad_frame_set_reg_addr (cache, tdep->ppc_ctr_regnum, base + OFF_CTR * tdep->wordsize); /* SRR0? */ trad_frame_set_reg_addr (cache, gdbarch_pc_regnum (gdbarch), base + OFF_SRR0 * tdep->wordsize); /* Construct the frame ID using the function start. */ trad_frame_set_id (cache, frame_id_build (base, get_frame_func (this_frame))); return cache; } static void ppcfbsd_trapframe_this_id (struct frame_info *this_frame, void **this_cache, struct frame_id *this_id) { struct trad_frame_cache *cache = ppcfbsd_trapframe_cache (this_frame, this_cache); trad_frame_get_id (cache, this_id); } static struct value * ppcfbsd_trapframe_prev_register (struct frame_info *this_frame, void **this_cache, int regnum) { struct trad_frame_cache *cache = ppcfbsd_trapframe_cache (this_frame, this_cache); return trad_frame_get_register (cache, this_frame, regnum); } static int ppcfbsd_trapframe_sniffer (const struct frame_unwind *self, struct frame_info *this_frame, void **this_cache) { CORE_ADDR pc; const char *name; pc = get_frame_func (this_frame); find_pc_partial_function (pc, &name, NULL, NULL); if (name && (strcmp(name, "asttrapexit") == 0 || strcmp(name, "trapexit") == 0)) return 1; return 0; } static const struct frame_unwind ppcfbsd_trapframe_unwind = { SIGTRAMP_FRAME, default_frame_unwind_stop_reason, ppcfbsd_trapframe_this_id, ppcfbsd_trapframe_prev_register, NULL, ppcfbsd_trapframe_sniffer }; static void ppcfbsd_kernel_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch) { struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); frame_unwind_prepend_unwinder(gdbarch, &ppcfbsd_trapframe_unwind); set_solib_ops(gdbarch, &kld_so_ops); #ifdef __powerpc__ if (tdep->wordsize == sizeof(register_t)) { fbsd_vmcore_set_supply_pcb(gdbarch, ppcfbsd_supply_pcb); fbsd_vmcore_set_cpu_pcb_addr(gdbarch, kgdb_trgt_stop_pcb); } #endif /* FreeBSD doesn't support the 128-bit `long double' from the psABI. */ set_gdbarch_long_double_bit (gdbarch, 64); set_gdbarch_long_double_format (gdbarch, floatformats_ieee_double); if (tdep->wordsize == 4) { set_gdbarch_return_value (gdbarch, ppc_sysv_abi_broken_return_value); } if (tdep->wordsize == 8) { set_gdbarch_convert_from_func_ptr_addr (gdbarch, ppc64_convert_from_func_ptr_addr); set_gdbarch_elf_make_msymbol_special (gdbarch, ppc64_elf_make_msymbol_special); } } - -void _initialize_ppc_kgdb_tdep(void); void _initialize_ppc_kgdb_tdep(void) { gdbarch_register_osabi_sniffer(bfd_arch_powerpc, bfd_target_elf_flavour, fbsd_kernel_osabi_sniffer); gdbarch_register_osabi (bfd_arch_powerpc, bfd_mach_ppc, GDB_OSABI_FREEBSD_KERNEL, ppcfbsd_kernel_init_abi); gdbarch_register_osabi (bfd_arch_powerpc, bfd_mach_ppc64, GDB_OSABI_FREEBSD_KERNEL, ppcfbsd_kernel_init_abi); /* Not sure about this one. */ gdbarch_register_osabi_sniffer(bfd_arch_rs6000, bfd_target_elf_flavour, fbsd_kernel_osabi_sniffer); gdbarch_register_osabi (bfd_arch_rs6000, 0, GDB_OSABI_FREEBSD_KERNEL, ppcfbsd_kernel_init_abi); } Index: head/devel/gdb/files/kgdb/sparc64fbsd-kern.c =================================================================== --- head/devel/gdb/files/kgdb/sparc64fbsd-kern.c (revision 464492) +++ head/devel/gdb/files/kgdb/sparc64fbsd-kern.c (revision 464493) @@ -1,319 +1,314 @@ /* * Copyright (c) 2004 Marcel Moolenaar * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include __FBSDID("$FreeBSD$"); -#include -#ifdef __sparc64__ -#include -#include -#include -#endif -#include - -#include +#include "defs.h" #include "gdbcore.h" #include "osabi.h" #include "regcache.h" -#include -#include +#include "target.h" +#include "frame-unwind.h" #include "solib.h" #include "trad-frame.h" +#include "sparc-tdep.h" +#include "sparc64-tdep.h" -#include -#include +#ifdef __sparc64__ +#include +#include +#include +#endif #include "kgdb.h" #ifdef __sparc64__ static void sparc64fbsd_supply_pcb(struct regcache *regcache, CORE_ADDR pcb_addr) { struct pcb pcb; if (target_read_memory(pcb_addr, &pcb, sizeof(pcb)) != 0) memset(&pcb, 0, sizeof(pcb)); regcache_raw_supply(regcache, SPARC_SP_REGNUM, (char *)&pcb.pcb_sp); sparc_supply_rwindow(regcache, pcb.pcb_sp, -1); regcache_raw_supply(regcache, SPARC64_PC_REGNUM, (char *)&pcb.pcb_pc); pcb.pcb_pc += 4; regcache_raw_supply(regcache, SPARC64_NPC_REGNUM, (char *)&pcb.pcb_pc); } #endif #define OFF_TF_SP (14 * 8) #define OFF_TF_TPC (25 * 8) #define OFF_TF_TNPC (24 * 8) #define OFF_TF_OUT (8 * 8) #define TRAPFRAME_SIZE (32 * 8) #ifdef __sparc64__ _Static_assert(sizeof(struct trapframe) == TRAPFRAME_SIZE, "trapframe size"); _Static_assert(offsetof(struct trapframe, tf_sp) == OFF_TF_SP, "tf_sp offset"); _Static_assert(offsetof(struct trapframe, tf_tpc) == OFF_TF_TPC, "tf_tpc offset"); _Static_assert(offsetof(struct trapframe, tf_tnpc) == OFF_TF_TNPC, "tf_tnpc offset"); _Static_assert(offsetof(struct trapframe, tf_out) == OFF_TF_OUT, "tf_out offset"); #endif static struct sparc_frame_cache * sparc64fbsd_trapframe_cache (struct frame_info *this_frame, void **this_cache) { struct sparc_frame_cache *cache; CORE_ADDR fp, sp, trapframe_addr; int regnum; if (*this_cache) return (struct sparc_frame_cache *)*this_cache; cache = sparc_frame_cache (this_frame, this_cache); gdb_assert (cache == *this_cache); fp = get_frame_register_unsigned (this_frame, SPARC_FP_REGNUM); trapframe_addr = fp + BIAS - TRAPFRAME_SIZE; sp = get_frame_register_unsigned (this_frame, SPARC_SP_REGNUM); cache->saved_regs = trad_frame_alloc_saved_regs (this_frame); cache->saved_regs[SPARC_SP_REGNUM].addr = trapframe_addr + OFF_TF_SP; #ifdef notyet cache->saved_regs[SPARC64_STATE_REGNUM].addr = trapframe_addr + OFF_TF_TSTATE; #endif cache->saved_regs[SPARC64_PC_REGNUM].addr = trapframe_addr + OFF_TF_TPC; cache->saved_regs[SPARC64_NPC_REGNUM].addr = trapframe_addr + OFF_TF_TNPC; for (regnum = SPARC_O0_REGNUM; regnum <= SPARC_O7_REGNUM; regnum++) cache->saved_regs[regnum].addr = trapframe_addr + OFF_TF_OUT + (regnum - SPARC_O0_REGNUM) * 8; for (regnum = SPARC_L0_REGNUM; regnum <= SPARC_I7_REGNUM; regnum++) cache->saved_regs[regnum].addr = sp + BIAS + (regnum - SPARC_L0_REGNUM) * 8; return cache; } static void sparc64fbsd_trapframe_this_id (struct frame_info *this_frame, void **this_cache, struct frame_id *this_id) { struct sparc_frame_cache *cache = sparc64fbsd_trapframe_cache (this_frame, this_cache); (*this_id) = frame_id_build (cache->base, cache->pc); } static struct value * sparc64fbsd_trapframe_prev_register (struct frame_info *this_frame, void **this_cache, int regnum) { struct sparc_frame_cache *cache = sparc64fbsd_trapframe_cache (this_frame, this_cache); return trad_frame_get_prev_register (this_frame, cache->saved_regs, regnum); } static int sparc64fbsd_trapframe_sniffer (const struct frame_unwind *self, struct frame_info *this_frame, void **this_cache) { CORE_ADDR pc; const char *name; pc = get_frame_address_in_block (this_frame); find_pc_partial_function (pc, &name, NULL, NULL); if (name && (strcmp(name, "tl0_intr") == 0 || strcmp(name, "tl0_trap") == 0 || strcmp(name, "tl1_intr") == 0 || strcmp(name, "tl1_trap") == 0)) return 1; return 0; } static const struct frame_unwind sparc64fbsd_trapframe_unwind = { SIGTRAMP_FRAME, default_frame_unwind_stop_reason, sparc64fbsd_trapframe_this_id, sparc64fbsd_trapframe_prev_register, NULL, sparc64fbsd_trapframe_sniffer }; #if 0 struct kgdb_frame_cache { CORE_ADDR pc; CORE_ADDR sp; CORE_ADDR fp; }; static struct kgdb_frame_cache * kgdb_trgt_frame_cache(struct frame_info *next_frame, void **this_cache) { char buf[MAX_REGISTER_SIZE]; struct kgdb_frame_cache *cache; cache = *this_cache; if (cache == NULL) { cache = FRAME_OBSTACK_ZALLOC(struct kgdb_frame_cache); *this_cache = cache; cache->pc = frame_func_unwind(next_frame); frame_unwind_register(next_frame, SPARC_SP_REGNUM, buf); cache->sp = extract_unsigned_integer(buf, register_size(current_gdbarch, SPARC_SP_REGNUM)); frame_unwind_register(next_frame, SPARC_FP_REGNUM, buf); cache->fp = extract_unsigned_integer(buf, register_size(current_gdbarch, SPARC_FP_REGNUM)); cache->fp += BIAS - sizeof(struct trapframe); } return (cache); } static void kgdb_trgt_trapframe_this_id(struct frame_info *next_frame, void **this_cache, struct frame_id *this_id) { struct kgdb_frame_cache *cache; cache = kgdb_trgt_frame_cache(next_frame, this_cache); *this_id = frame_id_build(cache->sp, cache->pc); } static void kgdb_trgt_trapframe_prev_register(struct frame_info *next_frame, void **this_cache, int regnum, int *optimizedp, enum lval_type *lvalp, CORE_ADDR *addrp, int *realnump, void *valuep) { char dummy_valuep[MAX_REGISTER_SIZE]; struct kgdb_frame_cache *cache; int ofs, regsz; regsz = register_size(current_gdbarch, regnum); if (valuep == NULL) valuep = dummy_valuep; memset(valuep, 0, regsz); *optimizedp = 0; *addrp = 0; *lvalp = not_lval; *realnump = -1; cache = kgdb_trgt_frame_cache(next_frame, this_cache); switch (regnum) { case SPARC_SP_REGNUM: ofs = offsetof(struct trapframe, tf_sp); break; case SPARC64_PC_REGNUM: ofs = offsetof(struct trapframe, tf_tpc); break; case SPARC64_NPC_REGNUM: ofs = offsetof(struct trapframe, tf_tnpc); break; case SPARC_O0_REGNUM: case SPARC_O1_REGNUM: case SPARC_O2_REGNUM: case SPARC_O3_REGNUM: case SPARC_O4_REGNUM: case SPARC_O5_REGNUM: case SPARC_O7_REGNUM: ofs = offsetof(struct trapframe, tf_out) + (regnum - SPARC_O0_REGNUM) * 8; break; default: if (regnum >= SPARC_L0_REGNUM && regnum <= SPARC_I7_REGNUM) { ofs = (regnum - SPARC_L0_REGNUM) * 8; *addrp = cache->sp + BIAS + ofs; *lvalp = lval_memory; target_read_memory(*addrp, valuep, regsz); } return; } *addrp = cache->fp + ofs; *lvalp = lval_memory; target_read_memory(*addrp, valuep, regsz); } static const struct frame_unwind kgdb_trgt_trapframe_unwind = { UNKNOWN_FRAME, &kgdb_trgt_trapframe_this_id, &kgdb_trgt_trapframe_prev_register }; const struct frame_unwind * kgdb_trgt_trapframe_sniffer(struct frame_info *next_frame) { char *pname; CORE_ADDR pc; pc = frame_func_unwind(next_frame); pname = NULL; find_pc_partial_function(pc, &pname, NULL, NULL); if (pname == NULL) return (NULL); if (strcmp(pname, "tl0_intr") == 0 || strcmp(pname, "tl0_trap") == 0 || strcmp(pname, "tl1_intr") == 0 || strcmp(pname, "tl1_trap") == 0) return (&kgdb_trgt_trapframe_unwind); /* printf("%s: %lx =%s\n", __func__, pc, pname); */ return (NULL); } #endif static void sparc64fbsd_kernel_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch) { sparc64_init_abi(info, gdbarch); frame_unwind_prepend_unwinder(gdbarch, &sparc64fbsd_trapframe_unwind); set_solib_ops(gdbarch, &kld_so_ops); #ifdef __sparc64__ fbsd_vmcore_set_supply_pcb(gdbarch, sparc64fbsd_supply_pcb); fbsd_vmcore_set_cpu_pcb_addr(gdbarch, kgdb_trgt_stop_pcb); #endif } - -void _initialize_sparc64_kgdb_tdep(void); void _initialize_sparc64_kgdb_tdep(void) { gdbarch_register_osabi_sniffer(bfd_arch_sparc, bfd_target_elf_flavour, fbsd_kernel_osabi_sniffer); gdbarch_register_osabi (bfd_arch_sparc, bfd_mach_sparc_v9, GDB_OSABI_FREEBSD_KERNEL, sparc64fbsd_kernel_init_abi); } Index: head/devel/gdb/files/patch-gdb_configure =================================================================== --- head/devel/gdb/files/patch-gdb_configure (revision 464492) +++ head/devel/gdb/files/patch-gdb_configure (revision 464493) @@ -1,18 +1,19 @@ --- gdb/configure.orig 2017-09-14 09:28:17 UTC +++ gdb/configure -@@ -15103,12 +15103,10 @@ if test "${ERROR_ON_WARNING}" = yes ; then +@@ -15292,13 +15292,10 @@ if test "${ERROR_ON_WARNING}" = yes ; then WERROR_CFLAGS="-Werror" fi -# The options we'll try to enable. +# These options work in either C or C++ modes. build_warnings="-Wall -Wpointer-arith \ --Wno-unused -Wunused-value -Wunused-function \ --Wno-switch -Wno-char-subscripts \ --Wempty-body -Wunused-but-set-parameter -Wunused-but-set-variable \ ---Wno-sign-compare -Wno-narrowing" +--Wno-sign-compare -Wno-narrowing -Wno-error=maybe-uninitialized \ +--Wno-mismatched-tags" +-Wno-unused -Wno-switch -Wno-char-subscripts \ +-Wempty-body -Wno-sign-compare -Wno-narrowing -Wno-mismatched-tags" - # Enable -Wno-format by default when using gcc on mingw since many - # GCC versions complain about %I64. + case "${host}" in + *-*-mingw32*)