Index: head/devel/gdb/Makefile =================================================================== --- head/devel/gdb/Makefile (revision 428875) +++ head/devel/gdb/Makefile (revision 428876) @@ -1,149 +1,132 @@ # Created by: Steven Kreuzer # $FreeBSD$ PORTNAME= gdb -PORTVERSION= 7.11.1 -PORTREVISION= 3 +PORTVERSION= 7.12 CATEGORIES= devel MASTER_SITES= GNU MAINTAINER= luca.pizzamiglio@gmail.com COMMENT= GNU GDB of newer version than comes with the system LICENSE= GPLv3 TEST_DEPENDS= runtest:misc/dejagnu TEST_TARGET= check USES= 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}/lib \ --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-21002a6 \ - ${FILESDIR}/commit-b00f86d \ - ${FILESDIR}/commit-aa1ed4a \ - ${FILESDIR}/commit-7697fc9 \ - ${FILESDIR}/commit-3350c5f \ - ${FILESDIR}/commit-2faa344 \ - ${FILESDIR}/commit-82372b2 \ - ${FILESDIR}/commit-e6cdd38 \ - ${FILESDIR}/commit-a3405d1 \ - ${FILESDIR}/commit-5077bff \ - ${FILESDIR}/commit-bb2a62e \ - ${FILESDIR}/commit-8607ea6 \ - ${FILESDIR}/commit-2c5c2a3 \ - ${FILESDIR}/commit-ee95032 \ - ${FILESDIR}/commit-bc7b765 \ - ${FILESDIR}/commit-0064d22 \ - ${FILESDIR}/commit-da95a26 \ - ${FILESDIR}/commit-5fa14c6 \ - ${FILESDIR}/commit-dbaed38 +LIB_DEPENDS+= libexpat.so:textproc/expat2 VER= ${PORTVERSION:S/.//g} PLIST_SUB= VER=${VER} ONLY_FOR_ARCHS= i386 amd64 powerpc powerpc64 armv6 # untested elsewhere, might work -OPTIONS_DEFINE= DEBUG EXPAT GDB_LINK GUILE KGDB PYTHON TUI +OPTIONS_DEFINE= DEBUG GDB_LINK GUILE KGDB PYTHON TUI -OPTIONS_DEFAULT= EXPAT GDB_LINK KGDB PYTHON TUI PORT_READLINE +OPTIONS_DEFAULT= GDB_LINK KGDB PYTHON TUI PORT_READLINE OPTIONS_SINGLE= READLINE OPTIONS_SINGLE_READLINE= BASE_READLINE BUNDLED_READLINE PORT_READLINE GDB_LINK_DESC= Create ${PREFIX}/bin/gdb symlink KGDB_DESC= Kernel Debugging Support BASE_READLINE_DESC= from base system BUNDLED_READLINE_DESC= from gdb distfile PORT_READLINE_DESC= from devel/readline port TUI_DESC= Text User Interface enabled OPTIONS_SUB= yes BASE_READLINE_USES= readline BASE_READLINE_CFLAGS= -D_rl_echoing_p=readline_echoing_p BASE_READLINE_EXTRA_PATCHES= ${FILESDIR}/extrapatch-base-readline BUNDLED_READLINE_CONFIGURE_OFF= --with-system-readline DEBUG_CFLAGS= -g -EXPAT_CONFIGURE_WITH= expat -EXPAT_LIB_DEPENDS= libexpat.so:textproc/expat2 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:2 TUI_CONFIGURE_ENABLE= tui .include .if ${OSVERSION} < 1000010 # FreeBSD 9.x and earlier do not define SIGLIBRT in CFLAGS+= -DSIGLIBRT=33 .endif +.if ${OSVERSION} > 1000010 +# The option -Wno-extended-offsetof is supported by clang only +CFLAGS+= -Wno-extended-offsetof +.endif + .if ! ${PORT_OPTIONS:MBUNDLED_READLINE} EXCLUDE+= readline .endif .if ${ARCH} == "amd64" CONFIGURE_TARGET= x86_64-portbld-freebsd${OSREL} .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} ${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} do-install-TUI-on: ${LN} -sf gdb${VER} ${STAGEDIR}${PREFIX}/bin/gdbtui${VER} - -do-install-EXPAT-on: - (cd ${WRKSRC}/gdb/data-directory ; \ - ${SETENV} ${MAKE_ENV} ${MAKE_CMD} ${MAKE_ARGS} install-syscalls ) 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 428875) +++ head/devel/gdb/distinfo (revision 428876) @@ -1,3 +1,3 @@ -TIMESTAMP = 1464770611 -SHA256 (gdb-7.11.1.tar.xz) = e9216da4e3755e9f414c1aa0026b626251dfc57ffe572a266e98da4f6988fc70 -SIZE (gdb-7.11.1.tar.xz) = 18947760 +TIMESTAMP = 1480413713 +SHA256 (gdb-7.12.tar.xz) = 834ff3c5948b30718343ea57b11cbc3235d7995c6a4f3a5cecec8c8114164f94 +SIZE (gdb-7.12.tar.xz) = 19219556 Index: head/devel/gdb/files/commit-aa1ed4a =================================================================== --- head/devel/gdb/files/commit-aa1ed4a (revision 428875) +++ head/devel/gdb/files/commit-aa1ed4a (nonexistent) @@ -1,191 +0,0 @@ -commit aa1ed4a93a2eb0fb90d274c15288f3aad1791f60 -Author: John Baldwin -Date: Sun Jun 12 08:56:31 2016 -0700 - - Add elfcore_grok_freebsd_note to parse FreeBSD ELF core notes. - - Move parsing of FreeBSD-specific ELF core notes out of elfcore_grok_note - into a new elfcore_grok_freebsd_note function. Add core note grok routines - for FreeBSD's psinfo and prstatus notes while here rather than depending - on the native handling in elfcore_grok_note. - - bfd/ChangeLog: - - * elf.c (elfcore_grok_note): Remove handling of NT_X86_XSTATE for - FreeBSD. Remove case for NT_FREEBSD_THRMISC. - (elfcore_grok_freebsd_psinfo): New function. - (elfcore_grok_freebsd_prstatus): New function. - (elfcore_grok_freebsd_note): New function. - (elf_parse_notes): Use "elfcore_grok_freebsd_note" for "FreeBSD" - notes. - -diff --git bfd/elf.c bfd/elf.c -index aaf2b53..cfcafaa 100644 ---- bfd/elf.c -+++ bfd/elf.c -@@ -9327,9 +9327,6 @@ elfcore_grok_note (bfd *abfd, Elf_Internal_Note *note) - if (note->namesz == 6 - && strcmp (note->namedata, "LINUX") == 0) - return elfcore_grok_xstatereg (abfd, note); -- else if (note->namesz == 8 -- && strcmp (note->namedata, "FreeBSD") == 0) -- return elfcore_grok_xstatereg (abfd, note); - else - return TRUE; - -@@ -9485,12 +9482,6 @@ elfcore_grok_note (bfd *abfd, Elf_Internal_Note *note) - return elfcore_make_note_pseudosection (abfd, ".note.linuxcore.siginfo", - note); - -- case NT_FREEBSD_THRMISC: -- if (note->namesz == 8 -- && strcmp (note->namedata, "FreeBSD") == 0) -- return elfcore_make_note_pseudosection (abfd, ".thrmisc", note); -- else -- return TRUE; - } - } - -@@ -9556,6 +9547,134 @@ elfobj_grok_stapsdt_note (bfd *abfd, Elf_Internal_Note *note) - } - - static bfd_boolean -+elfcore_grok_freebsd_psinfo (bfd *abfd, Elf_Internal_Note *note) -+{ -+ size_t offset; -+ -+ /* Check for version 1 in pr_version. */ -+ if (bfd_h_get_32 (abfd, (bfd_byte *) note->descdata) != 1) -+ return FALSE; -+ offset = 4; -+ -+ /* Skip over pr_psinfosz. */ -+ switch (abfd->arch_info->bits_per_word) -+ { -+ case 32: -+ offset += 4; -+ break; -+ -+ case 64: -+ offset += 4; /* Padding before pr_psinfosz. */ -+ offset += 8; -+ break; -+ -+ default: -+ return FALSE; -+ } -+ -+ /* pr_fname is PRFNAMESZ (16) + 1 bytes in size. */ -+ elf_tdata (abfd)->core->program -+ = _bfd_elfcore_strndup (abfd, note->descdata + offset, 17); -+ offset += 17; -+ -+ /* pr_psargs is PRARGSZ (80) + 1 bytes in size. */ -+ elf_tdata (abfd)->core->command -+ = _bfd_elfcore_strndup (abfd, note->descdata + offset, 81); -+ -+ return TRUE; -+} -+ -+static bfd_boolean -+elfcore_grok_freebsd_prstatus (bfd *abfd, Elf_Internal_Note *note) -+{ -+ size_t offset; -+ size_t size; -+ -+ /* Check for version 1 in pr_version. */ -+ if (bfd_h_get_32 (abfd, (bfd_byte *) note->descdata) != 1) -+ return FALSE; -+ offset = 4; -+ -+ /* Skip over pr_statussz. */ -+ switch (abfd->arch_info->bits_per_word) -+ { -+ case 32: -+ offset += 4; -+ break; -+ -+ case 64: -+ offset += 4; /* Padding before pr_statussz. */ -+ offset += 8; -+ break; -+ -+ default: -+ return FALSE; -+ } -+ -+ /* Extract size of pr_reg from pr_gregsetsz. */ -+ if (abfd->arch_info->bits_per_word == 32) -+ 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; -+ -+ /* 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. */ -+ if (abfd->arch_info->bits_per_word == 64) -+ offset += 4; -+ -+ /* Make a ".reg/999" section and a ".reg" section. */ -+ return _bfd_elfcore_make_pseudosection (abfd, ".reg", -+ size, note->descpos + offset); -+} -+ -+static bfd_boolean -+elfcore_grok_freebsd_note (bfd *abfd, Elf_Internal_Note *note) -+{ -+ switch (note->type) -+ { -+ case NT_PRSTATUS: -+ return elfcore_grok_freebsd_prstatus (abfd, note); -+ -+ case NT_FPREGSET: -+ return elfcore_grok_prfpreg (abfd, note); -+ -+ case NT_PRPSINFO: -+ return elfcore_grok_freebsd_psinfo (abfd, note); -+ -+ case NT_FREEBSD_THRMISC: -+ if (note->namesz == 8) -+ return elfcore_make_note_pseudosection (abfd, ".thrmisc", note); -+ else -+ return TRUE; -+ -+ case NT_X86_XSTATE: -+ if (note->namesz == 8) -+ return elfcore_grok_xstatereg (abfd, note); -+ else -+ return TRUE; -+ -+ default: -+ return TRUE; -+ } -+} -+ -+static bfd_boolean - elfcore_netbsd_get_lwpid (Elf_Internal_Note *note, int *lwpidp) - { - char *cp; -@@ -10467,6 +10586,7 @@ elf_parse_notes (bfd *abfd, char *buf, size_t size, file_ptr offset) - grokers[] = - { - GROKER_ELEMENT ("", elfcore_grok_note), -+ GROKER_ELEMENT ("FreeBSD", elfcore_grok_freebsd_note), - GROKER_ELEMENT ("NetBSD-CORE", elfcore_grok_netbsd_note), - GROKER_ELEMENT ( "OpenBSD", elfcore_grok_openbsd_note), - GROKER_ELEMENT ("QNX", elfcore_grok_nto_note), Property changes on: head/devel/gdb/files/commit-aa1ed4a ___________________________________________________________________ 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-bb2a62e =================================================================== --- head/devel/gdb/files/commit-bb2a62e (revision 428875) +++ head/devel/gdb/files/commit-bb2a62e (nonexistent) @@ -1,27 +0,0 @@ -commit bb2a62e694953c099c41d49f59947d3d91cc7c27 -Author: John Baldwin -Date: Fri Jun 24 18:24:21 2016 -0700 - - Honor detach-on-fork on FreeBSD. - - Only detach from the new child process in the follow fork callback - if detach_fork is true. - - gdb/ChangeLog: - - * fbsd-nat.c (fbsd_follow_fork): Only detach child if - "detach_fork" is true. - -diff --git gdb/fbsd-nat.c gdb/fbsd-nat.c -index c9548e9..0999712 100644 ---- gdb/fbsd-nat.c -+++ gdb/fbsd-nat.c -@@ -826,7 +826,7 @@ static int - fbsd_follow_fork (struct target_ops *ops, int follow_child, - int detach_fork) - { -- if (!follow_child) -+ if (!follow_child && detach_fork) - { - struct thread_info *tp = inferior_thread (); - pid_t child_pid = ptid_get_pid (tp->pending_follow.value.related_pid); Property changes on: head/devel/gdb/files/commit-bb2a62e ___________________________________________________________________ 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-0064d22 =================================================================== --- head/devel/gdb/files/commit-0064d22 (revision 428875) +++ head/devel/gdb/files/commit-0064d22 (nonexistent) @@ -1,83 +0,0 @@ -commit 0064d22386b99c047bbff3bcc73b6bfce9c29b4c -Author: John Baldwin -Date: Mon Jul 4 19:19:48 2016 -0700 - - Handle version 1a of FreeBSD's NT_PRSINFO. - - Version 1a adds a pr_pid member containing the process ID of the - terminating process. The presence of pr_pid is inferred from the - note's size. - - bfd/ChangeLog: - - * elf.c (elfcore_grok_freebsd_psinfo): Check for minimum note size - and handle pr_pid if present. - -diff --git bfd/elf.c bfd/elf.c -index 2cc64e8..ba1774e 100644 ---- bfd/elf.c -+++ bfd/elf.c -@@ -9590,27 +9590,36 @@ elfcore_grok_freebsd_psinfo (bfd *abfd, Elf_Internal_Note *note) - { - size_t offset; - -- /* Check for version 1 in pr_version. */ -- if (bfd_h_get_32 (abfd, (bfd_byte *) note->descdata) != 1) -- return FALSE; -- offset = 4; -- -- /* Skip over pr_psinfosz. */ - switch (abfd->arch_info->bits_per_word) - { - case 32: -- offset += 4; -+ if (note->descsz < 108) -+ return FALSE; - break; - - case 64: -- offset += 4; /* Padding before pr_psinfosz. */ -- offset += 8; -+ if (note->descsz < 120) -+ return FALSE; - break; - - default: - return FALSE; - } - -+ /* Check for version 1 in pr_version. */ -+ if (bfd_h_get_32 (abfd, (bfd_byte *) note->descdata) != 1) -+ return FALSE; -+ offset = 4; -+ -+ /* Skip over pr_psinfosz. */ -+ if (abfd->arch_info->bits_per_word == 32) -+ offset += 4; -+ else -+ { -+ offset += 4; /* Padding before pr_psinfosz. */ -+ offset += 8; -+ } -+ - /* pr_fname is PRFNAMESZ (16) + 1 bytes in size. */ - elf_tdata (abfd)->core->program - = _bfd_elfcore_strndup (abfd, note->descdata + offset, 17); -@@ -9619,6 +9628,17 @@ elfcore_grok_freebsd_psinfo (bfd *abfd, Elf_Internal_Note *note) - /* pr_psargs is PRARGSZ (80) + 1 bytes in size. */ - elf_tdata (abfd)->core->command - = _bfd_elfcore_strndup (abfd, note->descdata + offset, 81); -+ offset += 81; -+ -+ /* Padding before pr_pid. */ -+ offset += 2; -+ -+ /* The pr_pid field was added in version "1a". */ -+ if (note->descsz < offset + 4) -+ return TRUE; -+ -+ elf_tdata (abfd)->core->pid -+ = bfd_h_get_32 (abfd, (bfd_byte *) note->descdata + offset); - - return TRUE; - } Property changes on: head/devel/gdb/files/commit-0064d22 ___________________________________________________________________ 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-e6cdd38 =================================================================== --- head/devel/gdb/files/commit-e6cdd38 (revision 428875) +++ head/devel/gdb/files/commit-e6cdd38 (nonexistent) @@ -1,644 +0,0 @@ -commit e6cdd38e8f0fead14cd3c528e9a4b666e1871752 -Author: John Baldwin -Date: Sun Jun 12 21:24:42 2016 -0700 - - Add support for catching system calls to native FreeBSD targets. - - All platforms on FreeBSD use a shared system call table, so use a - single XML file to describe the system calls available on each FreeBSD - platform. - - Recent versions of FreeBSD include the identifier of the current - system call when reporting a system call entry or exit event in the - ptrace_lwpinfo structure obtained via PT_LWPINFO in fbsd_wait. As - such, FreeBSD native targets do not use the gdbarch method to fetch - the system call code. In addition, FreeBSD register sets fetched via - ptrace do not include an equivalent of 'orig_rax' (on amd64 for - example), so the system call code cannot be extracted from the - available registers during a system call exit. However, GDB assumes - that system call catch points are not supported if the gdbarch method - is not present. As a workaround, FreeBSD ABIs install a dummy gdbarch - method that throws an internal_error if it is ever invoked. - - gdb/ChangeLog: - - * configure.ac: Check for support for system call LWP fields on - FreeBSD. - * config.in, configure: Rebuild. - * data-directory/Makefile.in (SYSCALLS_FILES): Add freebsd.xml. - * fbsd-nat.c (fbsd_wait) [HAVE_STRUCT_PTRACE_LWPINFO_PL_SYSCALL_CODE]: - Report system call events. - [HAVE_STRUCT_PTRACE_LWPINFO_PL_SYSCALL_CODE] - (fbsd_set_syscall_catchpoint): New function. - (fbsd_nat_add_target) [HAVE_STRUCT_PTRACE_LWPINFO_PL_SYSCALL_CODE]: - Set "to_set_syscall_catchpoint" to "fbsd_set_syscall_catchpoint". - * fbsd-tdep.c: Include xml-syscall.h - (fbsd_get_syscall_number): New function. - (fbsd_init_abi): Set XML system call file name. - Add "get_syscall_number" gdbarch method. - * syscalls/freebsd.xml: New file. - -diff --git gdb/config.in gdb/config.in -index 905caf0..c82a5b4 100644 ---- gdb/config.in -+++ gdb/config.in -@@ -456,6 +456,9 @@ - /* Define to 1 if `struct ptrace_lwpinfo' is a member of `pl_tdname'. */ - #undef HAVE_STRUCT_PTRACE_LWPINFO_PL_TDNAME - -+/* Define to 1 if `struct ptrace_lwpinfo' is a member of `pl_syscall_code'. */ -+#undef HAVE_STRUCT_PTRACE_LWPINFO_PL_SYSCALL_CODE -+ - /* Define to 1 if your system has struct reg in . */ - #undef HAVE_STRUCT_REG - -diff --git gdb/configure gdb/configure -index 60ea884..ea11b50 100755 ---- gdb/configure -+++ gdb/configure -@@ -12927,6 +12927,20 @@ _ACEOF - fi - - -+# See if supports syscall fields on FreeBSD. The -+# pl_syscall_code member of `struct ptrace_lwpinfo' was added in -+# FreeBSD 10.3. -+ac_fn_c_check_member "$LINENO" "struct ptrace_lwpinfo" "pl_syscall_code" "ac_cv_member_struct_ptrace_lwpinfo_pl_syscall_code" "#include -+" -+if test "x$ac_cv_member_struct_ptrace_lwpinfo_pl_syscall_code" = x""yes; then : -+ -+cat >>confdefs.h <<_ACEOF -+#define HAVE_STRUCT_PTRACE_LWPINFO_PL_SYSCALL_CODE 1 -+_ACEOF -+ -+ -+fi -+ - - # Detect which type of /proc is in use, such as for Solaris. - -diff --git gdb/configure.ac gdb/configure.ac -index 6a72f72..920c228 100644 ---- gdb/configure.ac -+++ gdb/configure.ac -@@ -1526,6 +1526,11 @@ fi - AC_CHECK_MEMBERS([struct ptrace_lwpinfo.pl_tdname], [], [], - [#include ]) - -+# See if supports syscall fields on FreeBSD. The -+# pl_syscall_code member of `struct ptrace_lwpinfo' was added in -+# FreeBSD 10.3. -+AC_CHECK_MEMBERS([struct ptrace_lwpinfo.pl_syscall_code], [], [], -+ [#include ]) - - # Detect which type of /proc is in use, such as for Solaris. - -diff --git gdb/data-directory/Makefile.in gdb/data-directory/Makefile.in -index c05f379..0beca55 100644 ---- gdb/data-directory/Makefile.in -+++ gdb/data-directory/Makefile.in -@@ -51,7 +51,8 @@ SYSCALLS_FILES = \ - i386-linux.xml amd64-linux.xml \ - sparc-linux.xml sparc64-linux.xml \ - mips-o32-linux.xml mips-n32-linux.xml mips-n64-linux.xml \ -- s390-linux.xml s390x-linux.xml -+ s390-linux.xml s390x-linux.xml \ -+ freebsd.xml - - PYTHON_DIR = python - PYTHON_INSTALL_DIR = $(DESTDIR)$(GDB_DATADIR)/$(PYTHON_DIR) -diff --git gdb/fbsd-nat.c gdb/fbsd-nat.c -index dc65e29..c9548e9 100644 ---- gdb/fbsd-nat.c -+++ gdb/fbsd-nat.c -@@ -779,6 +779,40 @@ fbsd_wait (struct target_ops *ops, - 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 -+ call will report this flag as part of their event. Stops -+ explicitly for system call entry and exit always use -+ SIGTRAP, so only treat SIGTRAP events as system call -+ entry/exit events. */ -+ if (pl.pl_flags & (PL_FLAG_SCE | PL_FLAG_SCX) -+ && ourstatus->value.sig == SIGTRAP) -+ { -+#ifdef HAVE_STRUCT_PTRACE_LWPINFO_PL_SYSCALL_CODE -+ if (catch_syscall_enabled ()) -+ { -+ if (catching_syscall_number (pl.pl_syscall_code)) -+ { -+ if (pl.pl_flags & PL_FLAG_SCE) -+ ourstatus->kind = TARGET_WAITKIND_SYSCALL_ENTRY; -+ else -+ ourstatus->kind = TARGET_WAITKIND_SYSCALL_RETURN; -+ ourstatus->value.syscall_number = pl.pl_syscall_code; -+ return wptid; -+ } -+ } -+#endif -+ /* If the core isn't interested in this event, just -+ continue the process explicitly and wait for another -+ event. Note that PT_SYSCALL is "sticky" on FreeBSD -+ and once system call stops are enabled on a process -+ it stops for all system call entries and exits. */ -+ if (ptrace (PT_CONTINUE, pid, (caddr_t) 1, 0) == -1) -+ perror_with_name (("ptrace")); -+ continue; -+ } - } - return wptid; - } -@@ -889,6 +923,19 @@ fbsd_remove_exec_catchpoint (struct target_ops *self, int pid) - return 0; - } - #endif -+ -+#ifdef HAVE_STRUCT_PTRACE_LWPINFO_PL_SYSCALL_CODE -+static int -+fbsd_set_syscall_catchpoint (struct target_ops *self, int pid, int needed, -+ int any_count, int table_size, int *table) -+{ -+ -+ /* Ignore the arguments. inf-ptrace.c will use PT_SYSCALL which -+ will catch all system call entries and exits. The system calls -+ are filtered by GDB rather than the kernel. */ -+ return 0; -+} -+#endif - #endif - - void -@@ -925,6 +972,9 @@ fbsd_nat_add_target (struct target_ops *t) - t->to_insert_exec_catchpoint = fbsd_insert_exec_catchpoint; - t->to_remove_exec_catchpoint = fbsd_remove_exec_catchpoint; - #endif -+#ifdef HAVE_STRUCT_PTRACE_LWPINFO_PL_SYSCALL_CODE -+ t->to_set_syscall_catchpoint = fbsd_set_syscall_catchpoint; -+#endif - #endif - add_target (t); - } -diff --git gdb/fbsd-tdep.c gdb/fbsd-tdep.c -index e8f8605..4329f97 100644 ---- gdb/fbsd-tdep.c -+++ gdb/fbsd-tdep.c -@@ -24,6 +24,7 @@ - #include "regcache.h" - #include "regset.h" - #include "gdbthread.h" -+#include "xml-syscall.h" - - #include "elf-bfd.h" - #include "fbsd-tdep.h" -@@ -317,6 +318,22 @@ fbsd_print_auxv_entry (struct gdbarch *gdbarch, struct ui_file *file, - fprint_auxv_entry (file, name, description, format, type, val); - } - -+/* Implement the "get_syscall_number" gdbarch method. */ -+ -+static LONGEST -+fbsd_get_syscall_number (struct gdbarch *gdbarch, -+ ptid_t ptid) -+{ -+ -+ /* FreeBSD doesn't use gdbarch_get_syscall_number since FreeBSD -+ native targets fetch the system call number from the -+ 'pl_syscall_code' member of struct ptrace_lwpinfo in fbsd_wait. -+ However, system call catching requires this function to be -+ set. */ -+ -+ internal_error (__FILE__, __LINE__, _("fbsd_get_sycall_number called")); -+} -+ - /* To be called from GDB_OSABI_FREEBSD_ELF handlers. */ - - void -@@ -326,4 +343,8 @@ 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); -+ -+ /* `catch syscall' */ -+ set_xml_syscall_file_name (gdbarch, "syscalls/freebsd.xml"); -+ set_gdbarch_get_syscall_number (gdbarch, fbsd_get_syscall_number); - } -diff --git gdb/syscalls/freebsd.xml gdb/syscalls/freebsd.xml -new file mode 100644 -index 0000000..fb7c38b ---- /dev/null -+++ gdb/syscalls/freebsd.xml -@@ -0,0 +1,410 @@ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ Property changes on: head/devel/gdb/files/commit-e6cdd38 ___________________________________________________________________ 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-5fa14c6 =================================================================== --- head/devel/gdb/files/commit-5fa14c6 (revision 428875) +++ head/devel/gdb/files/commit-5fa14c6 (nonexistent) @@ -1,30 +0,0 @@ -commit 5fa14c6b9789bad6f91dd21889f7b1a0eb75c6d0 -Author: John Baldwin -Date: Fri Jul 15 17:01:21 2016 -0700 - - Enable ptrace events on new child processes. - - New child processes on FreeBSD do not inherit optional ptrace events - such as fork and LWP events from the parent process. Instead, - explicitly enable events on new children when reporting a fork - event. - - gdb/ChangeLog: - - * fbsd-nat.c (fbsd_wait): Use "fbsd_enable_proc_events" on - new child processes. - -diff --git gdb/fbsd-nat.c gdb/fbsd-nat.c -index 508ab19..5e4304e 100644 ---- gdb/fbsd-nat.c -+++ gdb/fbsd-nat.c -@@ -836,6 +836,9 @@ fbsd_wait (struct target_ops *ops, - child_ptid = ptid_build (child, pl.pl_lwpid, 0); - } - -+ /* Enable additional events on the child process. */ -+ fbsd_enable_proc_events (ptid_get_pid (child_ptid)); -+ - /* For vfork, the child process will have the P_PPWAIT - flag set. */ - fbsd_fetch_kinfo_proc (child, &kp); Property changes on: head/devel/gdb/files/commit-5fa14c6 ___________________________________________________________________ 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-b00f86d =================================================================== --- head/devel/gdb/files/commit-b00f86d (revision 428875) +++ head/devel/gdb/files/commit-b00f86d (nonexistent) @@ -1,34 +0,0 @@ -commit b00f86d0720d2cf44f3edb6101682074da1abe5d -Author: John Baldwin -Date: Wed Jun 15 22:44:11 2016 -0700 - - Add constants for FreeBSD-specific auxiliary vector entry types. - - include/ChangeLog: - - * elf/common.h (AT_FREEBSD_EXECPATH, AT_FREEBSD_CANARY) - (AT_FREEBSD_CANARYLEN, AT_FREEBSD_OSRELDATE, AT_FREEBSD_NCPUS) - (AT_FREEBSD_PAGESIZES, AT_FREEBSD_PAGESIZESLEN) - (AT_FREEBSD_TIMEKEEP, AT_FREEBSD_STACKPROT): Define. - -diff --git include/elf/common.h include/elf/common.h -index 087d876..d2da009d 100644 ---- include/elf/common.h -+++ include/elf/common.h -@@ -1012,6 +1012,16 @@ - #define AT_L2_CACHESHAPE 36 - #define AT_L3_CACHESHAPE 37 - -+#define AT_FREEBSD_EXECPATH 15 /* Path to the executable. */ -+#define AT_FREEBSD_CANARY 16 /* Canary for SSP. */ -+#define AT_FREEBSD_CANARYLEN 17 /* Length of the canary. */ -+#define AT_FREEBSD_OSRELDATE 18 /* OSRELDATE. */ -+#define AT_FREEBSD_NCPUS 19 /* Number of CPUs. */ -+#define AT_FREEBSD_PAGESIZES 20 /* Pagesizes. */ -+#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_SUN_UID 2000 /* Effective user ID. */ - #define AT_SUN_RUID 2001 /* Real user ID. */ - #define AT_SUN_GID 2002 /* Effective group ID. */ Property changes on: head/devel/gdb/files/commit-b00f86d ___________________________________________________________________ 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-2faa344 =================================================================== --- head/devel/gdb/files/commit-2faa344 (revision 428875) +++ head/devel/gdb/files/commit-2faa344 (nonexistent) @@ -1,397 +0,0 @@ -commit 2faa34476d9e6120eaf389b7f91b7227183fa2ce -Author: John Baldwin -Date: Sat Jun 11 15:51:38 2016 -0700 - - Add a new gdbarch method to print a single AUXV entry. - - Different platforms have different meanings for auxiliary vector - entries. The 'print_auxv_entry' gdbarch method allows an architecture - to output a suitable description for platform-specific entries. - - A fprint_auxv_entry function is split out of fprint_target_auxv. - This function outputs the description of a single auxiliary vector - entry to the specified file using caller-supplied formatting and - strings to describe the vector type. - - The existing switch on auxiliary vector types is moved out of - fprint_target_auxv into a new default_print_auxv_entry function. - default_print_auxv_entry chooses an appropriate format and description - and calls fprint_single_auxv to describe a single vector entry. - This function is used as the default 'print_auxv_entry' gdbarch method. - - fprint_target_auxv now invokes the gdbarch 'print_auxv_entry' method - on each vector entry. - - gdb/ChangeLog: - - * auxv.c (fprint_auxv_entry): New function. - (default_print_auxv_entry): New function. - (fprint_target_auxv): Use gdbarch_print_auxv_entry. - * auxv.h (enum auxv_format): New enum. - (fprint_auxv_entry): Declare. - (default_print_auxv_entry): Declare. - * gdbarch.sh (print_auxv_entry): New. - * gdbarch.c, gdbarch.h: Re-generated. - -diff --git gdb/auxv.c gdb/auxv.c -index 396862e..de9205d 100644 ---- gdb/auxv.c -+++ gdb/auxv.c -@@ -407,10 +407,126 @@ target_auxv_search (struct target_ops *ops, CORE_ADDR match, CORE_ADDR *valp) - } - - -+/* Print the description of a single AUXV entry on the specified file. */ -+ -+void -+fprint_auxv_entry (struct ui_file *file, const char *name, -+ const char *description, enum auxv_format format, -+ CORE_ADDR type, CORE_ADDR val) -+{ -+ fprintf_filtered (file, ("%-4s %-20s %-30s "), -+ plongest (type), name, description); -+ switch (format) -+ { -+ case AUXV_FORMAT_DEC: -+ fprintf_filtered (file, ("%s\n"), plongest (val)); -+ break; -+ case AUXV_FORMAT_HEX: -+ fprintf_filtered (file, ("%s\n"), paddress (target_gdbarch (), val)); -+ break; -+ case AUXV_FORMAT_STR: -+ { -+ struct value_print_options opts; -+ -+ get_user_print_options (&opts); -+ if (opts.addressprint) -+ fprintf_filtered (file, ("%s "), paddress (target_gdbarch (), val)); -+ val_print_string (builtin_type (target_gdbarch ())->builtin_char, -+ NULL, val, -1, file, &opts); -+ fprintf_filtered (file, ("\n")); -+ } -+ break; -+ } -+} -+ -+/* The default implementation of gdbarch_print_auxv_entry. */ -+ -+void -+default_print_auxv_entry (struct gdbarch *gdbarch, struct ui_file *file, -+ CORE_ADDR type, CORE_ADDR val) -+{ -+ const char *name = "???"; -+ const char *description = ""; -+ enum auxv_format format = AUXV_FORMAT_HEX; -+ -+ switch (type) -+ { -+#define TAG(tag, text, kind) \ -+ case tag: name = #tag; description = text; format = kind; break -+ TAG (AT_NULL, _("End of vector"), AUXV_FORMAT_HEX); -+ TAG (AT_IGNORE, _("Entry should be ignored"), AUXV_FORMAT_HEX); -+ TAG (AT_EXECFD, _("File descriptor of program"), AUXV_FORMAT_DEC); -+ TAG (AT_PHDR, _("Program headers for program"), AUXV_FORMAT_HEX); -+ TAG (AT_PHENT, _("Size of program header entry"), AUXV_FORMAT_DEC); -+ TAG (AT_PHNUM, _("Number of program headers"), AUXV_FORMAT_DEC); -+ TAG (AT_PAGESZ, _("System page size"), AUXV_FORMAT_DEC); -+ TAG (AT_BASE, _("Base address of interpreter"), AUXV_FORMAT_HEX); -+ TAG (AT_FLAGS, _("Flags"), AUXV_FORMAT_HEX); -+ TAG (AT_ENTRY, _("Entry point of program"), AUXV_FORMAT_HEX); -+ TAG (AT_NOTELF, _("Program is not ELF"), AUXV_FORMAT_DEC); -+ TAG (AT_UID, _("Real user ID"), AUXV_FORMAT_DEC); -+ TAG (AT_EUID, _("Effective user ID"), AUXV_FORMAT_DEC); -+ TAG (AT_GID, _("Real group ID"), AUXV_FORMAT_DEC); -+ TAG (AT_EGID, _("Effective group ID"), AUXV_FORMAT_DEC); -+ TAG (AT_CLKTCK, _("Frequency of times()"), AUXV_FORMAT_DEC); -+ TAG (AT_PLATFORM, _("String identifying platform"), AUXV_FORMAT_STR); -+ TAG (AT_HWCAP, _("Machine-dependent CPU capability hints"), -+ AUXV_FORMAT_HEX); -+ TAG (AT_FPUCW, _("Used FPU control word"), AUXV_FORMAT_DEC); -+ TAG (AT_DCACHEBSIZE, _("Data cache block size"), AUXV_FORMAT_DEC); -+ TAG (AT_ICACHEBSIZE, _("Instruction cache block size"), AUXV_FORMAT_DEC); -+ TAG (AT_UCACHEBSIZE, _("Unified cache block size"), AUXV_FORMAT_DEC); -+ TAG (AT_IGNOREPPC, _("Entry should be ignored"), AUXV_FORMAT_DEC); -+ TAG (AT_BASE_PLATFORM, _("String identifying base platform"), -+ AUXV_FORMAT_STR); -+ TAG (AT_RANDOM, _("Address of 16 random bytes"), AUXV_FORMAT_HEX); -+ TAG (AT_HWCAP2, _("Extension of AT_HWCAP"), AUXV_FORMAT_HEX); -+ TAG (AT_EXECFN, _("File name of executable"), AUXV_FORMAT_STR); -+ TAG (AT_SECURE, _("Boolean, was exec setuid-like?"), AUXV_FORMAT_DEC); -+ TAG (AT_SYSINFO, _("Special system info/entry points"), AUXV_FORMAT_HEX); -+ TAG (AT_SYSINFO_EHDR, _("System-supplied DSO's ELF header"), -+ AUXV_FORMAT_HEX); -+ TAG (AT_L1I_CACHESHAPE, _("L1 Instruction cache information"), -+ AUXV_FORMAT_HEX); -+ TAG (AT_L1D_CACHESHAPE, _("L1 Data cache information"), AUXV_FORMAT_HEX); -+ TAG (AT_L2_CACHESHAPE, _("L2 cache information"), AUXV_FORMAT_HEX); -+ TAG (AT_L3_CACHESHAPE, _("L3 cache information"), AUXV_FORMAT_HEX); -+ TAG (AT_SUN_UID, _("Effective user ID"), AUXV_FORMAT_DEC); -+ TAG (AT_SUN_RUID, _("Real user ID"), AUXV_FORMAT_DEC); -+ TAG (AT_SUN_GID, _("Effective group ID"), AUXV_FORMAT_DEC); -+ TAG (AT_SUN_RGID, _("Real group ID"), AUXV_FORMAT_DEC); -+ TAG (AT_SUN_LDELF, _("Dynamic linker's ELF header"), AUXV_FORMAT_HEX); -+ TAG (AT_SUN_LDSHDR, _("Dynamic linker's section headers"), -+ AUXV_FORMAT_HEX); -+ TAG (AT_SUN_LDNAME, _("String giving name of dynamic linker"), -+ AUXV_FORMAT_STR); -+ TAG (AT_SUN_LPAGESZ, _("Large pagesize"), AUXV_FORMAT_DEC); -+ TAG (AT_SUN_PLATFORM, _("Platform name string"), AUXV_FORMAT_STR); -+ TAG (AT_SUN_HWCAP, _("Machine-dependent CPU capability hints"), -+ AUXV_FORMAT_HEX); -+ TAG (AT_SUN_IFLUSH, _("Should flush icache?"), AUXV_FORMAT_DEC); -+ TAG (AT_SUN_CPU, _("CPU name string"), AUXV_FORMAT_STR); -+ TAG (AT_SUN_EMUL_ENTRY, _("COFF entry point address"), AUXV_FORMAT_HEX); -+ TAG (AT_SUN_EMUL_EXECFD, _("COFF executable file descriptor"), -+ AUXV_FORMAT_DEC); -+ TAG (AT_SUN_EXECNAME, -+ _("Canonicalized file name given to execve"), AUXV_FORMAT_STR); -+ TAG (AT_SUN_MMU, _("String for name of MMU module"), AUXV_FORMAT_STR); -+ TAG (AT_SUN_LDDATA, _("Dynamic linker's data segment address"), -+ AUXV_FORMAT_HEX); -+ TAG (AT_SUN_AUXFLAGS, -+ _("AF_SUN_ flags passed from the kernel"), AUXV_FORMAT_HEX); -+ } -+ -+ fprint_auxv_entry (file, name, description, format, type, val); -+} -+ - /* Print the contents of the target's AUXV on the specified file. */ -+ - int - fprint_target_auxv (struct ui_file *file, struct target_ops *ops) - { -+ struct gdbarch *gdbarch = target_gdbarch (); - CORE_ADDR type, val; - gdb_byte *data; - gdb_byte *ptr; -@@ -426,93 +542,7 @@ fprint_target_auxv (struct ui_file *file, struct target_ops *ops) - - while (target_auxv_parse (ops, &ptr, data + info->length, &type, &val) > 0) - { -- const char *name = "???"; -- const char *description = ""; -- enum { dec, hex, str } flavor = hex; -- -- switch (type) -- { --#define TAG(tag, text, kind) \ -- case tag: name = #tag; description = text; flavor = kind; break -- TAG (AT_NULL, _("End of vector"), hex); -- TAG (AT_IGNORE, _("Entry should be ignored"), hex); -- TAG (AT_EXECFD, _("File descriptor of program"), dec); -- TAG (AT_PHDR, _("Program headers for program"), hex); -- TAG (AT_PHENT, _("Size of program header entry"), dec); -- TAG (AT_PHNUM, _("Number of program headers"), dec); -- TAG (AT_PAGESZ, _("System page size"), dec); -- TAG (AT_BASE, _("Base address of interpreter"), hex); -- TAG (AT_FLAGS, _("Flags"), hex); -- TAG (AT_ENTRY, _("Entry point of program"), hex); -- TAG (AT_NOTELF, _("Program is not ELF"), dec); -- TAG (AT_UID, _("Real user ID"), dec); -- TAG (AT_EUID, _("Effective user ID"), dec); -- TAG (AT_GID, _("Real group ID"), dec); -- TAG (AT_EGID, _("Effective group ID"), dec); -- TAG (AT_CLKTCK, _("Frequency of times()"), dec); -- TAG (AT_PLATFORM, _("String identifying platform"), str); -- TAG (AT_HWCAP, _("Machine-dependent CPU capability hints"), hex); -- TAG (AT_FPUCW, _("Used FPU control word"), dec); -- TAG (AT_DCACHEBSIZE, _("Data cache block size"), dec); -- TAG (AT_ICACHEBSIZE, _("Instruction cache block size"), dec); -- TAG (AT_UCACHEBSIZE, _("Unified cache block size"), dec); -- TAG (AT_IGNOREPPC, _("Entry should be ignored"), dec); -- TAG (AT_BASE_PLATFORM, _("String identifying base platform"), str); -- TAG (AT_RANDOM, _("Address of 16 random bytes"), hex); -- TAG (AT_HWCAP2, _("Extension of AT_HWCAP"), hex); -- TAG (AT_EXECFN, _("File name of executable"), str); -- TAG (AT_SECURE, _("Boolean, was exec setuid-like?"), dec); -- TAG (AT_SYSINFO, _("Special system info/entry points"), hex); -- TAG (AT_SYSINFO_EHDR, _("System-supplied DSO's ELF header"), hex); -- TAG (AT_L1I_CACHESHAPE, _("L1 Instruction cache information"), hex); -- TAG (AT_L1D_CACHESHAPE, _("L1 Data cache information"), hex); -- TAG (AT_L2_CACHESHAPE, _("L2 cache information"), hex); -- TAG (AT_L3_CACHESHAPE, _("L3 cache information"), hex); -- TAG (AT_SUN_UID, _("Effective user ID"), dec); -- TAG (AT_SUN_RUID, _("Real user ID"), dec); -- TAG (AT_SUN_GID, _("Effective group ID"), dec); -- TAG (AT_SUN_RGID, _("Real group ID"), dec); -- TAG (AT_SUN_LDELF, _("Dynamic linker's ELF header"), hex); -- TAG (AT_SUN_LDSHDR, _("Dynamic linker's section headers"), hex); -- TAG (AT_SUN_LDNAME, _("String giving name of dynamic linker"), str); -- TAG (AT_SUN_LPAGESZ, _("Large pagesize"), dec); -- TAG (AT_SUN_PLATFORM, _("Platform name string"), str); -- TAG (AT_SUN_HWCAP, _("Machine-dependent CPU capability hints"), hex); -- TAG (AT_SUN_IFLUSH, _("Should flush icache?"), dec); -- TAG (AT_SUN_CPU, _("CPU name string"), str); -- TAG (AT_SUN_EMUL_ENTRY, _("COFF entry point address"), hex); -- TAG (AT_SUN_EMUL_EXECFD, _("COFF executable file descriptor"), dec); -- TAG (AT_SUN_EXECNAME, -- _("Canonicalized file name given to execve"), str); -- TAG (AT_SUN_MMU, _("String for name of MMU module"), str); -- TAG (AT_SUN_LDDATA, _("Dynamic linker's data segment address"), hex); -- TAG (AT_SUN_AUXFLAGS, -- _("AF_SUN_ flags passed from the kernel"), hex); -- } -- -- fprintf_filtered (file, "%-4s %-20s %-30s ", -- plongest (type), name, description); -- switch (flavor) -- { -- case dec: -- fprintf_filtered (file, "%s\n", plongest (val)); -- break; -- case hex: -- fprintf_filtered (file, "%s\n", paddress (target_gdbarch (), val)); -- break; -- case str: -- { -- struct value_print_options opts; -- -- get_user_print_options (&opts); -- if (opts.addressprint) -- fprintf_filtered (file, "%s ", paddress (target_gdbarch (), val)); -- val_print_string (builtin_type (target_gdbarch ())->builtin_char, -- NULL, val, -1, file, &opts); -- fprintf_filtered (file, "\n"); -- } -- break; -- } -+ gdbarch_print_auxv_entry (gdbarch, file, type, val); - ++ents; - if (type == AT_NULL) - break; -diff --git gdb/auxv.h gdb/auxv.h -index 9efe604..916f674 100644 ---- gdb/auxv.h -+++ gdb/auxv.h -@@ -46,6 +46,20 @@ extern int target_auxv_parse (struct target_ops *ops, - extern int target_auxv_search (struct target_ops *ops, - CORE_ADDR match, CORE_ADDR *valp); - -+/* Print a description of a single AUXV entry on the specified file. */ -+enum auxv_format { AUXV_FORMAT_DEC, AUXV_FORMAT_HEX, AUXV_FORMAT_STR }; -+ -+extern void fprint_auxv_entry (struct ui_file *file, const char *name, -+ const char *description, -+ enum auxv_format format, CORE_ADDR type, -+ CORE_ADDR val); -+ -+/* The default implementation of gdbarch_print_auxv_entry. */ -+ -+extern void default_print_auxv_entry (struct gdbarch *gdbarch, -+ struct ui_file *file, CORE_ADDR type, -+ CORE_ADDR val); -+ - /* Print the contents of the target's AUXV on the specified file. */ - extern int fprint_target_auxv (struct ui_file *file, struct target_ops *ops); - -diff --git gdb/gdbarch.c gdb/gdbarch.c -index 313502b..af7359e 100644 ---- gdb/gdbarch.c -+++ gdb/gdbarch.c -@@ -47,6 +47,7 @@ - #include "observer.h" - #include "regcache.h" - #include "objfiles.h" -+#include "auxv.h" - - /* Static function declarations */ - -@@ -328,6 +329,7 @@ struct gdbarch - gdbarch_insn_is_ret_ftype *insn_is_ret; - gdbarch_insn_is_jump_ftype *insn_is_jump; - gdbarch_auxv_parse_ftype *auxv_parse; -+ gdbarch_print_auxv_entry_ftype *print_auxv_entry; - gdbarch_vsyscall_range_ftype *vsyscall_range; - gdbarch_infcall_mmap_ftype *infcall_mmap; - gdbarch_infcall_munmap_ftype *infcall_munmap; -@@ -432,6 +434,7 @@ gdbarch_alloc (const struct gdbarch_info *info, - gdbarch->insn_is_call = default_insn_is_call; - gdbarch->insn_is_ret = default_insn_is_ret; - gdbarch->insn_is_jump = default_insn_is_jump; -+ gdbarch->print_auxv_entry = default_print_auxv_entry; - gdbarch->vsyscall_range = default_vsyscall_range; - gdbarch->infcall_mmap = default_infcall_mmap; - gdbarch->infcall_munmap = default_infcall_munmap; -@@ -678,6 +681,7 @@ verify_gdbarch (struct gdbarch *gdbarch) - /* Skip verify of insn_is_ret, invalid_p == 0 */ - /* Skip verify of insn_is_jump, invalid_p == 0 */ - /* Skip verify of auxv_parse, has predicate. */ -+ /* Skip verify of print_auxv_entry, invalid_p == 0 */ - /* Skip verify of vsyscall_range, invalid_p == 0 */ - /* Skip verify of infcall_mmap, invalid_p == 0 */ - /* Skip verify of infcall_munmap, invalid_p == 0 */ -@@ -1167,6 +1171,9 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file) - "gdbarch_dump: pointer_to_address = <%s>\n", - host_address_to_string (gdbarch->pointer_to_address)); - fprintf_unfiltered (file, -+ "gdbarch_dump: print_auxv_entry = <%s>\n", -+ host_address_to_string (gdbarch->print_auxv_entry)); -+ fprintf_unfiltered (file, - "gdbarch_dump: print_float_info = <%s>\n", - host_address_to_string (gdbarch->print_float_info)); - fprintf_unfiltered (file, -@@ -4769,6 +4776,23 @@ set_gdbarch_auxv_parse (struct gdbarch *gdbarch, - gdbarch->auxv_parse = auxv_parse; - } - -+void -+gdbarch_print_auxv_entry (struct gdbarch *gdbarch, struct ui_file *file, CORE_ADDR type, CORE_ADDR val) -+{ -+ gdb_assert (gdbarch != NULL); -+ gdb_assert (gdbarch->print_auxv_entry != NULL); -+ if (gdbarch_debug >= 2) -+ fprintf_unfiltered (gdb_stdlog, "gdbarch_print_auxv_entry called\n"); -+ gdbarch->print_auxv_entry (gdbarch, file, type, val); -+} -+ -+void -+set_gdbarch_print_auxv_entry (struct gdbarch *gdbarch, -+ gdbarch_print_auxv_entry_ftype print_auxv_entry) -+{ -+ gdbarch->print_auxv_entry = print_auxv_entry; -+} -+ - int - gdbarch_vsyscall_range (struct gdbarch *gdbarch, struct mem_range *range) - { -diff --git gdb/gdbarch.h gdb/gdbarch.h -index a6366fc..bc0f692 100644 ---- gdb/gdbarch.h -+++ gdb/gdbarch.h -@@ -1464,6 +1464,13 @@ typedef int (gdbarch_auxv_parse_ftype) (struct gdbarch *gdbarch, gdb_byte **read - extern int gdbarch_auxv_parse (struct gdbarch *gdbarch, gdb_byte **readptr, gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp); - extern void set_gdbarch_auxv_parse (struct gdbarch *gdbarch, gdbarch_auxv_parse_ftype *auxv_parse); - -+/* Print the description of a single auxv entry described by TYPE and VAL -+ to FILE. */ -+ -+typedef void (gdbarch_print_auxv_entry_ftype) (struct gdbarch *gdbarch, struct ui_file *file, CORE_ADDR type, CORE_ADDR val); -+extern void gdbarch_print_auxv_entry (struct gdbarch *gdbarch, struct ui_file *file, CORE_ADDR type, CORE_ADDR val); -+extern void set_gdbarch_print_auxv_entry (struct gdbarch *gdbarch, gdbarch_print_auxv_entry_ftype *print_auxv_entry); -+ - /* Find the address range of the current inferior's vsyscall/vDSO, and - write it to *RANGE. If the vsyscall's length can't be determined, a - range with zero length is returned. Returns true if the vsyscall is -diff --git gdb/gdbarch.sh gdb/gdbarch.sh -index f170c10..d8e0eeb 100755 ---- gdb/gdbarch.sh -+++ gdb/gdbarch.sh -@@ -1110,6 +1110,10 @@ m:int:insn_is_jump:CORE_ADDR addr:addr::default_insn_is_jump::0 - # Return 1 if an entry was read into *TYPEP and *VALP. - M:int:auxv_parse:gdb_byte **readptr, gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp:readptr, endptr, typep, valp - -+# Print the description of a single auxv entry described by TYPE and VAL -+# to FILE. -+m:void:print_auxv_entry:struct ui_file *file, CORE_ADDR type, CORE_ADDR val:file, type, val::default_print_auxv_entry::0 -+ - # Find the address range of the current inferior's vsyscall/vDSO, and - # write it to *RANGE. If the vsyscall's length can't be determined, a - # range with zero length is returned. Returns true if the vsyscall is -@@ -1616,6 +1620,7 @@ cat < -Date: Sun Jul 3 11:56:21 2016 -0700 - - Pass SIGLIBRT directly to child processes. - - FreeBSD's librt uses SIGLIBRT as an internal signal to implement - SIGEV_THREAD sigevent notifications. Similar to SIGLWP or SIGCANCEL - this signal should be passed through to child processes by default. - - include/ChangeLog: - - * signals.def: Add GDB_SIGNAL_LIBRT. - - gdb/ChangeLog: - - * common/signals.c (gdb_signal_from_host): Handle SIGLIBRT. - (do_gdb_signal_to_host): Likewise. - * infrun.c (_initialize_infrun): Pass GDB_SIGNAL_LIBRT through to - programs. - * proc-events.c (signal_table): Add entry for SIGLIBRT. - -diff --git gdb/common/signals.c gdb/common/signals.c -index 45c0c73..f84935d 100644 ---- gdb/common/signals.c -+++ gdb/common/signals.c -@@ -331,6 +331,10 @@ gdb_signal_from_host (int hostsig) - if (hostsig == SIGINFO) - return GDB_SIGNAL_INFO; - #endif -+#if defined (SIGLIBRT) -+ if (hostsig == SIGLIBRT) -+ return GDB_SIGNAL_LIBRT; -+#endif - - #if defined (REALTIME_LO) - if (hostsig >= REALTIME_LO && hostsig < REALTIME_HI) -@@ -584,6 +588,10 @@ do_gdb_signal_to_host (enum gdb_signal oursig, - case GDB_SIGNAL_INFO: - return SIGINFO; - #endif -+#if defined (SIGLIBRT) -+ case GDB_SIGNAL_LIBRT: -+ return SIGLIBRT; -+#endif - - default: - #if defined (REALTIME_LO) -diff --git gdb/infrun.c gdb/infrun.c -index 70a0790..257ac8a 100644 ---- gdb/infrun.c -+++ gdb/infrun.c -@@ -9409,6 +9409,8 @@ leave it stopped or free to run as needed."), - signal_print[GDB_SIGNAL_WAITING] = 0; - signal_stop[GDB_SIGNAL_CANCEL] = 0; - signal_print[GDB_SIGNAL_CANCEL] = 0; -+ signal_stop[GDB_SIGNAL_LIBRT] = 0; -+ signal_print[GDB_SIGNAL_LIBRT] = 0; - - /* Update cached state. */ - signal_cache_update (-1); -diff --git gdb/proc-events.c gdb/proc-events.c -index b291d31..daa6f58 100644 ---- gdb/proc-events.c -+++ gdb/proc-events.c -@@ -1536,6 +1536,9 @@ static struct trans signal_table[] = - #ifdef SIGAIO - { SIGAIO, "SIGAIO", "Asynchronous I/O signal" }, - #endif -+#ifdef SIGLIBRT -+ { SIGLIBRT, "SIGLIBRT", "Used by librt" }, -+#endif - - /* FIXME: add real-time signals. */ - }; -diff --git include/gdb/ChangeLog include/gdb/ChangeLog -index f05ba4b..05f127e 100644 ---- include/gdb/ChangeLog -+++ include/gdb/ChangeLog -@@ -1,3 +1,7 @@ -+2016-07-15 John Baldwin -+ -+ * signals.def: Add GDB_SIGNAL_LIBRT. -+ - 2016-01-06 Mike Frysinger - - * remote-sim.h (sim_open): Mark argv const. -diff --git include/gdb/signals.def include/gdb/signals.def -index 61cc88c..2b30e71 100644 ---- include/gdb/signals.def -+++ include/gdb/signals.def -@@ -194,7 +194,9 @@ SET (GDB_EXC_EMULATION, 148, "EXC_EMULATION", "Emulation instruction") - SET (GDB_EXC_SOFTWARE, 149, "EXC_SOFTWARE", "Software generated exception") - SET (GDB_EXC_BREAKPOINT, 150, "EXC_BREAKPOINT", "Breakpoint") - -+SET (GDB_SIGNAL_LIBRT, 151, "SIGLIBRT", "librt internal signal") -+ - /* If you are adding a new signal, add it just above this comment. */ - - /* Last and unused enum value, for sizing arrays, etc. */ --SET (GDB_SIGNAL_LAST, 151, NULL, "GDB_SIGNAL_LAST") -+SET (GDB_SIGNAL_LAST, 152, NULL, "GDB_SIGNAL_LAST") Property changes on: head/devel/gdb/files/commit-bc7b765 ___________________________________________________________________ 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-21002a6 =================================================================== --- head/devel/gdb/files/commit-21002a6 (revision 428875) +++ head/devel/gdb/files/commit-21002a6 (nonexistent) @@ -1,102 +0,0 @@ -commit 21002a635bf3da33367592e3a3ab3cce24fe5299 -Author: John Baldwin -Date: Tue Jan 19 11:02:09 2016 -0800 - - Handle void * conversions in FreeBSD/x86 native code to fix C++ build. - - gdb/ChangeLog: - - * amd64bsd-nat.c (amd64bsd_fetch_inferior_registers): Change xstateregs - to void *. - (amd64bsd_store_inferior_registers): Likewise. - * fbsd-nat.c (resume_one_thread_cb): Explicitly cast data to ptid_t *. - (resume_all_threads_cb): Likewise. - * i386bsd-nat.c (i386bsd_supply_gregset): Cast gregs to char *. - (i386bsd_collect_gregset): Likewise. - (i386bsd_fetch_inferior_registers): Change xstateregs to void *. - (i386bsd_store_inferior_registers): Likewise. - -diff --git gdb/amd64bsd-nat.c gdb/amd64bsd-nat.c -index fb7e4fa..e278a91 100644 ---- gdb/amd64bsd-nat.c -+++ gdb/amd64bsd-nat.c -@@ -65,7 +65,7 @@ amd64bsd_fetch_inferior_registers (struct target_ops *ops, - { - struct fpreg fpregs; - #ifdef PT_GETXSTATE_INFO -- char *xstateregs; -+ void *xstateregs; - - if (amd64bsd_xsave_len != 0) - { -@@ -118,7 +118,7 @@ amd64bsd_store_inferior_registers (struct target_ops *ops, - { - struct fpreg fpregs; - #ifdef PT_GETXSTATE_INFO -- char *xstateregs; -+ void *xstateregs; - - if (amd64bsd_xsave_len != 0) - { -diff --git gdb/fbsd-nat.c gdb/fbsd-nat.c -index bdf078e..b582abe 100644 ---- gdb/fbsd-nat.c -+++ gdb/fbsd-nat.c -@@ -428,7 +428,7 @@ static void (*super_resume) (struct target_ops *, - static int - resume_one_thread_cb (struct thread_info *tp, void *data) - { -- ptid_t *ptid = data; -+ ptid_t *ptid = (ptid_t *) data; - int request; - - if (ptid_get_pid (tp->ptid) != ptid_get_pid (*ptid)) -@@ -447,7 +447,7 @@ resume_one_thread_cb (struct thread_info *tp, void *data) - static int - resume_all_threads_cb (struct thread_info *tp, void *data) - { -- ptid_t *filter = data; -+ ptid_t *filter = (ptid_t *) data; - - if (!ptid_match (tp->ptid, *filter)) - return 0; -diff --git gdb/i386bsd-nat.c gdb/i386bsd-nat.c -index 5d45c33..f5f4a0f 100644 ---- gdb/i386bsd-nat.c -+++ gdb/i386bsd-nat.c -@@ -92,7 +92,7 @@ size_t i386bsd_xsave_len; - static void - i386bsd_supply_gregset (struct regcache *regcache, const void *gregs) - { -- const char *regs = gregs; -+ const char *regs = (const char *) gregs; - int regnum; - - for (regnum = 0; regnum < ARRAY_SIZE (i386bsd_r_reg_offset); regnum++) -@@ -112,7 +112,7 @@ static void - i386bsd_collect_gregset (const struct regcache *regcache, - void *gregs, int regnum) - { -- char *regs = gregs; -+ char *regs = (char *) gregs; - int i; - - for (i = 0; i < ARRAY_SIZE (i386bsd_r_reg_offset); i++) -@@ -157,7 +157,7 @@ i386bsd_fetch_inferior_registers (struct target_ops *ops, - #ifdef PT_GETXSTATE_INFO - if (i386bsd_xsave_len != 0) - { -- char *xstateregs; -+ void *xstateregs; - - xstateregs = alloca (i386bsd_xsave_len); - if (ptrace (PT_GETXSTATE, get_ptrace_pid (inferior_ptid), -@@ -227,7 +227,7 @@ i386bsd_store_inferior_registers (struct target_ops *ops, - #ifdef PT_GETXSTATE_INFO - if (i386bsd_xsave_len != 0) - { -- char *xstateregs; -+ void *xstateregs; - - xstateregs = alloca (i386bsd_xsave_len); - if (ptrace (PT_GETXSTATE, get_ptrace_pid (inferior_ptid), Property changes on: head/devel/gdb/files/commit-21002a6 ___________________________________________________________________ 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-ee95032 =================================================================== --- head/devel/gdb/files/commit-ee95032 (revision 428875) +++ head/devel/gdb/files/commit-ee95032 (nonexistent) @@ -1,24 +0,0 @@ -commit ee950322ca2c77494b1742f304632f667ed6ce79 -Author: John Baldwin -Date: Fri Jul 1 10:18:50 2016 -0700 - - Use 'ptid_t' instead of 'ptid' for fbsd_next_vfork_done's return type. - - 'ptid' compiles in C++, but not C. - - gdb/ChangeLog: - * fbsd-nat.c (fbsd_is_vfork_done_pending): Fix return type. - -diff --git gdb/fbsd-nat.c gdb/fbsd-nat.c -index fcb7ff5..fa9516e 100644 ---- gdb/fbsd-nat.c -+++ gdb/fbsd-nat.c -@@ -609,7 +609,7 @@ fbsd_is_vfork_done_pending (pid_t pid) - /* Check for a pending vfork done event. If one is found, remove it - from the list and return the PTID. */ - --static ptid -+static ptid_t - fbsd_next_vfork_done (void) - { - struct fbsd_fork_info *info; Property changes on: head/devel/gdb/files/commit-ee95032 ___________________________________________________________________ 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-3350c5f =================================================================== --- head/devel/gdb/files/commit-3350c5f (revision 428875) +++ head/devel/gdb/files/commit-3350c5f (nonexistent) @@ -1,39 +0,0 @@ -commit 3350c5f5de3d2e62dd9de2a76cf2d5d8728d2600 -Author: John Baldwin -Date: Sun Jun 12 12:34:51 2016 -0700 - - Create a pseudo section for the ELF AUXV core dump note on FreeBSD. - - The procstat AUXV core dump note in FreeBSD consists of 32-bit integer - followed by an array of auxiliary vector entries. - - bfd/ChangeLog: - - * elf.c (elfcore_grok_freebsd_note): Handle NT_FREEBSD_PROCSTAT_AUXV - notes. - -diff --git bfd/elf.c bfd/elf.c -index cfcafaa..cb4de50 100644 ---- bfd/elf.c -+++ bfd/elf.c -@@ -9663,6 +9663,20 @@ elfcore_grok_freebsd_note (bfd *abfd, Elf_Internal_Note *note) - else - return TRUE; - -+ case NT_FREEBSD_PROCSTAT_AUXV: -+ { -+ asection *sect = bfd_make_section_anyway_with_flags (abfd, ".auxv", -+ SEC_HAS_CONTENTS); -+ -+ if (sect == NULL) -+ return FALSE; -+ sect->size = note->descsz - 4; -+ sect->filepos = note->descpos + 4; -+ sect->alignment_power = 1 + bfd_get_arch_size (abfd) / 32; -+ -+ return TRUE; -+ } -+ - case NT_X86_XSTATE: - if (note->namesz == 8) - return elfcore_grok_xstatereg (abfd, note); Property changes on: head/devel/gdb/files/commit-3350c5f ___________________________________________________________________ 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-2c5c2a3 =================================================================== --- head/devel/gdb/files/commit-2c5c2a3 (revision 428875) +++ head/devel/gdb/files/commit-2c5c2a3 (nonexistent) @@ -1,214 +0,0 @@ -commit 2c5c2a3321706c28cbf1b85a970a2e32912eb0c8 -Author: John Baldwin -Date: Fri Jun 24 21:00:04 2016 -0700 - - Fake VFORK_DONE events when following only the parent after a vfork. - - FreeBSD does not currently report a ptrace event for a parent process - after it resumes due to the child exiting the shared memory region after - a vfork. Take the same approach used in linux-nat.c in this case of - sleeping for a while and then reporting a fake VFORK_DONE event. - - gdb/ChangeLog: - - * fbsd-nat.c (struct fbsd_fork_child_info): Rename to ... - (struct fbsd_fork_info): ... this. - (struct fbsd_fork_info) : Rename to ... - (struct fbsd_fork_info) : ... this. - (fbsd_pending_children): Update type. - (fbsd_remember_child): Update type and field name. - (fbsd_is_child_pending): Likewise. - (fbsd_pending_vfork_done): New variable. - (fbsd_is_vfork_done_pending): New function. - (fbsd_next_vfork_done): New function. - (fbsd_resume): Don't resume processes with a pending vfork done - event. - (fbsd_wait): Report pending vfork done events. - (fbsd_follow_fork): Delay and record a pending vfork done event - for a vfork parent when detaching the child. - -diff --git gdb/fbsd-nat.c gdb/fbsd-nat.c -index daf4580..fcb7ff5 100644 ---- gdb/fbsd-nat.c -+++ gdb/fbsd-nat.c -@@ -530,13 +530,13 @@ fbsd_update_thread_list (struct target_ops *ops) - sake. FreeBSD versions newer than 9.1 contain both fixes. - */ - --struct fbsd_fork_child_info -+struct fbsd_fork_info - { -- struct fbsd_fork_child_info *next; -- ptid_t child; /* Pid of new child. */ -+ struct fbsd_fork_info *next; -+ ptid_t ptid; - }; - --static struct fbsd_fork_child_info *fbsd_pending_children; -+static struct fbsd_fork_info *fbsd_pending_children; - - /* Record a new child process event that is reported before the - corresponding fork event in the parent. */ -@@ -544,9 +544,9 @@ static struct fbsd_fork_child_info *fbsd_pending_children; - static void - fbsd_remember_child (ptid_t pid) - { -- struct fbsd_fork_child_info *info = XCNEW (struct fbsd_fork_child_info); -+ struct fbsd_fork_info *info = XCNEW (struct fbsd_fork_info); - -- info->child = pid; -+ info->ptid = pid; - info->next = fbsd_pending_children; - fbsd_pending_children = info; - } -@@ -557,25 +557,74 @@ fbsd_remember_child (ptid_t pid) - static ptid_t - fbsd_is_child_pending (pid_t pid) - { -- struct fbsd_fork_child_info *info, *prev; -+ struct fbsd_fork_info *info, *prev; - ptid_t ptid; - - prev = NULL; - for (info = fbsd_pending_children; info; prev = info, info = info->next) - { -- if (ptid_get_pid (info->child) == pid) -+ if (ptid_get_pid (info->ptid) == pid) - { - if (prev == NULL) - fbsd_pending_children = info->next; - else - prev->next = info->next; -- ptid = info->child; -+ ptid = info->ptid; - xfree (info); - return ptid; - } - } - return null_ptid; - } -+ -+static struct fbsd_fork_info *fbsd_pending_vfork_done; -+ -+/* Record a pending vfork done event. */ -+ -+static void -+fbsd_add_vfork_done (ptid_t pid) -+{ -+ struct fbsd_fork_info *info = XCNEW (struct fbsd_fork_info); -+ -+ info->ptid = pid; -+ info->next = fbsd_pending_vfork_done; -+ fbsd_pending_vfork_done = info; -+} -+ -+/* Check for a pending vfork done event for a specific PID. */ -+ -+static int -+fbsd_is_vfork_done_pending (pid_t pid) -+{ -+ struct fbsd_fork_info *info; -+ -+ for (info = fbsd_pending_vfork_done; info != NULL; info = info->next) -+ { -+ if (ptid_get_pid (info->ptid) == pid) -+ return 1; -+ } -+ return 0; -+} -+ -+/* Check for a pending vfork done event. If one is found, remove it -+ from the list and return the PTID. */ -+ -+static ptid -+fbsd_next_vfork_done (void) -+{ -+ struct fbsd_fork_info *info; -+ ptid_t ptid; -+ -+ if (fbsd_pending_vfork_done != NULL) -+ { -+ info = fbsd_pending_vfork_done; -+ fbsd_pending_vfork_done = info->next; -+ ptid = info->ptid; -+ xfree (info); -+ return ptid; -+ } -+ return null_ptid; -+} - #endif - - static int -@@ -616,6 +665,17 @@ static void - fbsd_resume (struct target_ops *ops, - ptid_t ptid, int step, enum gdb_signal signo) - { -+#ifdef TDP_RFPPWAIT -+ pid_t pid; -+ -+ /* Don't PT_CONTINUE a process which has a pending vfork done event. */ -+ if (ptid_equal (minus_one_ptid, ptid)) -+ pid = ptid_get_pid (inferior_ptid); -+ else -+ pid = ptid_get_pid (ptid); -+ if (fbsd_is_vfork_done_pending (pid)) -+ return; -+#endif - - if (debug_fbsd_lwp) - fprintf_unfiltered (gdb_stdlog, -@@ -650,6 +710,12 @@ fbsd_wait (struct target_ops *ops, - - while (1) - { -+ wptid = fbsd_next_vfork_done (); -+ if (!ptid_equal (wptid, null_ptid)) -+ { -+ ourstatus->kind = TARGET_WAITKIND_VFORK_DONE; -+ return wptid; -+ } - wptid = super_wait (ops, ptid, ourstatus, target_options); - if (ourstatus->kind == TARGET_WAITKIND_STOPPED) - { -@@ -828,6 +894,7 @@ fbsd_follow_fork (struct target_ops *ops, int follow_child, - if (!follow_child && detach_fork) - { - struct thread_info *tp = inferior_thread (); -+ int has_vforked = tp->pending_follow.kind == TARGET_WAITKIND_VFORKED; - pid_t child_pid = ptid_get_pid (tp->pending_follow.value.related_pid); - - /* Breakpoints have already been detached from the child by -@@ -835,6 +902,33 @@ fbsd_follow_fork (struct target_ops *ops, int follow_child, - - if (ptrace (PT_DETACH, child_pid, (PTRACE_TYPE_ARG3)1, 0) == -1) - perror_with_name (("ptrace")); -+ -+ if (has_vforked) -+ { -+ /* We can't insert breakpoints until the child process has -+ finished with the shared memory region. The parent -+ process doesn't wait for the child process to exit or -+ exec until after it has been resumed from the ptrace stop -+ to report the fork. Once it has been resumed it doesn't -+ stop again before returning to userland, so there is no -+ reliable way to wait on the parent. -+ -+ We can't stay attached to the child to wait for an exec -+ or exit because it may invoke ptrace(PT_TRACE_ME) -+ (e.g. if the parent process is a debugger forking a new -+ child process). -+ -+ In the end, the best we can do is to make sure it runs -+ for a little while. Hopefully it will be out of range of -+ any breakpoints we reinsert. Usually this is only the -+ single-step breakpoint at vfork's return point. */ -+ -+ usleep (10000); -+ -+ /* Schedule a fake VFORK_DONE event to report on the next -+ wait. */ -+ fbsd_add_vfork_done (inferior_ptid); -+ } - } - - return 0; Property changes on: head/devel/gdb/files/commit-2c5c2a3 ___________________________________________________________________ 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-8607ea6 =================================================================== --- head/devel/gdb/files/commit-8607ea6 (revision 428875) +++ head/devel/gdb/files/commit-8607ea6 (nonexistent) @@ -1,165 +0,0 @@ -commit 8607ea632c806235554aa2336cf01bf3758c1264 -Author: John Baldwin -Date: Fri Jun 24 21:06:36 2016 -0700 - - Move fbsd_resume and related functions below fork following helper code. - - gdb/ChangeLog: - - * fbsd-nat.c (super_resume): Move earlier next to "super_wait". - (resume_one_thread_cb): Move below fork following helper code. - (resume_all_threads_cb): Likewise. - (fbsd_resume): Likewise. - -diff --git gdb/fbsd-nat.c gdb/fbsd-nat.c -index 0999712..daf4580 100644 ---- gdb/fbsd-nat.c -+++ gdb/fbsd-nat.c -@@ -281,6 +281,10 @@ fbsd_xfer_partial (struct target_ops *ops, enum target_object object, - #ifdef PT_LWPINFO - static int debug_fbsd_lwp; - -+static void (*super_resume) (struct target_ops *, -+ ptid_t, -+ int, -+ enum gdb_signal); - static ptid_t (*super_wait) (struct target_ops *, - ptid_t, - struct target_waitstatus *, -@@ -492,70 +496,6 @@ fbsd_update_thread_list (struct target_ops *ops) - #endif - } - --static void (*super_resume) (struct target_ops *, -- ptid_t, -- int, -- enum gdb_signal); -- --static int --resume_one_thread_cb (struct thread_info *tp, void *data) --{ -- ptid_t *ptid = (ptid_t *) data; -- int request; -- -- if (ptid_get_pid (tp->ptid) != ptid_get_pid (*ptid)) -- return 0; -- -- if (ptid_get_lwp (tp->ptid) == ptid_get_lwp (*ptid)) -- request = PT_RESUME; -- else -- request = PT_SUSPEND; -- -- if (ptrace (request, ptid_get_lwp (tp->ptid), NULL, 0) == -1) -- perror_with_name (("ptrace")); -- return 0; --} -- --static int --resume_all_threads_cb (struct thread_info *tp, void *data) --{ -- ptid_t *filter = (ptid_t *) data; -- -- if (!ptid_match (tp->ptid, *filter)) -- return 0; -- -- if (ptrace (PT_RESUME, ptid_get_lwp (tp->ptid), NULL, 0) == -1) -- perror_with_name (("ptrace")); -- return 0; --} -- --/* Implement the "to_resume" target_ops method. */ -- --static void --fbsd_resume (struct target_ops *ops, -- ptid_t ptid, int step, enum gdb_signal signo) --{ -- -- if (debug_fbsd_lwp) -- fprintf_unfiltered (gdb_stdlog, -- "FLWP: fbsd_resume for ptid (%d, %ld, %ld)\n", -- ptid_get_pid (ptid), ptid_get_lwp (ptid), -- ptid_get_tid (ptid)); -- if (ptid_lwp_p (ptid)) -- { -- /* If ptid is a specific LWP, suspend all other LWPs in the process. */ -- iterate_over_threads (resume_one_thread_cb, &ptid); -- } -- else -- { -- /* If ptid is a wildcard, resume all matching threads (they won't run -- until the process is continued however). */ -- iterate_over_threads (resume_all_threads_cb, &ptid); -- ptid = inferior_ptid; -- } -- super_resume (ops, ptid, step, signo); --} -- - #ifdef TDP_RFPPWAIT - /* - To catch fork events, PT_FOLLOW_FORK is set on every traced process -@@ -638,6 +578,65 @@ fbsd_is_child_pending (pid_t pid) - } - #endif - -+static int -+resume_one_thread_cb (struct thread_info *tp, void *data) -+{ -+ ptid_t *ptid = (ptid_t *) data; -+ int request; -+ -+ if (ptid_get_pid (tp->ptid) != ptid_get_pid (*ptid)) -+ return 0; -+ -+ if (ptid_get_lwp (tp->ptid) == ptid_get_lwp (*ptid)) -+ request = PT_RESUME; -+ else -+ request = PT_SUSPEND; -+ -+ if (ptrace (request, ptid_get_lwp (tp->ptid), NULL, 0) == -1) -+ perror_with_name (("ptrace")); -+ return 0; -+} -+ -+static int -+resume_all_threads_cb (struct thread_info *tp, void *data) -+{ -+ ptid_t *filter = (ptid_t *) data; -+ -+ if (!ptid_match (tp->ptid, *filter)) -+ return 0; -+ -+ if (ptrace (PT_RESUME, ptid_get_lwp (tp->ptid), NULL, 0) == -1) -+ perror_with_name (("ptrace")); -+ return 0; -+} -+ -+/* Implement the "to_resume" target_ops method. */ -+ -+static void -+fbsd_resume (struct target_ops *ops, -+ ptid_t ptid, int step, enum gdb_signal signo) -+{ -+ -+ if (debug_fbsd_lwp) -+ fprintf_unfiltered (gdb_stdlog, -+ "FLWP: fbsd_resume for ptid (%d, %ld, %ld)\n", -+ ptid_get_pid (ptid), ptid_get_lwp (ptid), -+ ptid_get_tid (ptid)); -+ if (ptid_lwp_p (ptid)) -+ { -+ /* If ptid is a specific LWP, suspend all other LWPs in the process. */ -+ iterate_over_threads (resume_one_thread_cb, &ptid); -+ } -+ else -+ { -+ /* If ptid is a wildcard, resume all matching threads (they won't run -+ until the process is continued however). */ -+ iterate_over_threads (resume_all_threads_cb, &ptid); -+ ptid = inferior_ptid; -+ } -+ super_resume (ops, ptid, step, signo); -+} -+ - /* 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. */ Property changes on: head/devel/gdb/files/commit-8607ea6 ___________________________________________________________________ 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-7697fc9 =================================================================== --- head/devel/gdb/files/commit-7697fc9 (revision 428875) +++ head/devel/gdb/files/commit-7697fc9 (nonexistent) @@ -1,110 +0,0 @@ -commit 7697fc9ec3a970f05abb836107653c46ada466ad -Author: John Baldwin -Date: Sat Jun 11 15:07:38 2016 -0700 - - Fetch the ELF auxiliary vector from live processes on FreeBSD. - - Use the kern.proc.auxv. sysctl to fetch the ELF auxiliary vector for - a live process. - - gdb/ChangeLog: - - * fbsd-nat.c [KERN_PROC_AUXV] New variable super_xfer_partial. - (fbsd_xfer_partial): New function. - (fbsd_nat_add_target) [KERN_PROC_AUXV] Set "to_xfer_partial" to - "fbsd_xfer_partial". - -diff --git gdb/fbsd-nat.c gdb/fbsd-nat.c -index b582abe..dc65e29 100644 ---- gdb/fbsd-nat.c -+++ gdb/fbsd-nat.c -@@ -206,6 +206,78 @@ fbsd_find_memory_regions (struct target_ops *self, - } - #endif - -+#ifdef KERN_PROC_AUXV -+static enum target_xfer_status (*super_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); -+ -+/* Implement the "to_xfer_partial target_ops" method. */ -+ -+static enum target_xfer_status -+fbsd_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) -+{ -+ pid_t pid = ptid_get_pid (inferior_ptid); -+ -+ switch (object) -+ { -+ case TARGET_OBJECT_AUXV: -+ { -+ struct cleanup *cleanup = make_cleanup (null_cleanup, NULL); -+ unsigned char *buf; -+ size_t buflen; -+ int mib[4]; -+ -+ if (writebuf != NULL) -+ return TARGET_XFER_E_IO; -+ mib[0] = CTL_KERN; -+ mib[1] = KERN_PROC; -+ mib[2] = KERN_PROC_AUXV; -+ mib[3] = pid; -+ if (offset == 0) -+ { -+ buf = readbuf; -+ buflen = len; -+ } -+ else -+ { -+ buflen = offset + len; -+ buf = XCNEWVEC (unsigned char, buflen); -+ cleanup = make_cleanup (xfree, buf); -+ } -+ if (sysctl (mib, 4, buf, &buflen, NULL, 0) == 0) -+ { -+ if (offset != 0) -+ { -+ if (buflen > offset) -+ { -+ buflen -= offset; -+ memcpy (readbuf, buf + offset, buflen); -+ } -+ else -+ buflen = 0; -+ } -+ do_cleanups (cleanup); -+ *xfered_len = buflen; -+ return (buflen == 0) ? TARGET_XFER_EOF : TARGET_XFER_OK; -+ } -+ do_cleanups (cleanup); -+ return TARGET_XFER_E_IO; -+ } -+ default: -+ return super_xfer_partial (ops, object, annex, readbuf, writebuf, offset, -+ len, xfered_len); -+ } -+} -+#endif -+ - #ifdef PT_LWPINFO - static int debug_fbsd_lwp; - -@@ -824,6 +896,10 @@ 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; -+#ifdef KERN_PROC_AUXV -+ super_xfer_partial = t->to_xfer_partial; -+ t->to_xfer_partial = fbsd_xfer_partial; -+#endif - #ifdef PT_LWPINFO - t->to_thread_alive = fbsd_thread_alive; - t->to_pid_to_str = fbsd_pid_to_str; Property changes on: head/devel/gdb/files/commit-7697fc9 ___________________________________________________________________ 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-5077bff =================================================================== --- head/devel/gdb/files/commit-5077bff (revision 428875) +++ head/devel/gdb/files/commit-5077bff (nonexistent) @@ -1,49 +0,0 @@ -commit 5077bfff905136e9d9a8fdf0886f6217887622ad -Author: John Baldwin -Date: Mon Jun 27 17:44:58 2016 -0700 - - Set debug registers on all threads belonging to the current inferior. - - gdb/ChangeLog: - - * x86bsd-nat.c: Include 'gdbthread.h'. - (x86bsd_dr_set): Set debug registers on all threads belonging to - the current inferior. - -diff --git gdb/x86bsd-nat.c gdb/x86bsd-nat.c -index 0c56848..bde25ab 100644 ---- gdb/x86bsd-nat.c -+++ gdb/x86bsd-nat.c -@@ -19,6 +19,7 @@ - - #include "defs.h" - #include "inferior.h" -+#include "gdbthread.h" - - /* We include to make sure `struct fxsave64' is defined on - NetBSD, since NetBSD's needs it. */ -@@ -71,6 +72,7 @@ x86bsd_dr_get (ptid_t ptid, int regnum) - static void - x86bsd_dr_set (int regnum, unsigned long value) - { -+ struct thread_info *thread; - struct dbreg dbregs; - - if (ptrace (PT_GETDBREGS, get_ptrace_pid (inferior_ptid), -@@ -84,9 +86,13 @@ x86bsd_dr_set (int regnum, unsigned long value) - - DBREG_DRX ((&dbregs), regnum) = value; - -- if (ptrace (PT_SETDBREGS, get_ptrace_pid (inferior_ptid), -- (PTRACE_TYPE_ARG3) &dbregs, 0) == -1) -- perror_with_name (_("Couldn't write debug registers")); -+ ALL_NON_EXITED_THREADS (thread) -+ if (thread->inf == current_inferior ()) -+ { -+ if (ptrace (PT_SETDBREGS, get_ptrace_pid (thread->ptid), -+ (PTRACE_TYPE_ARG3) &dbregs, 0) == -1) -+ perror_with_name (_("Couldn't write debug registers")); -+ } - } - - static void Property changes on: head/devel/gdb/files/commit-5077bff ___________________________________________________________________ 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-dbaed38 =================================================================== --- head/devel/gdb/files/commit-dbaed38 (revision 428875) +++ head/devel/gdb/files/commit-dbaed38 (nonexistent) @@ -1,157 +0,0 @@ -commit dbaed3853474e7bd824a25bc454a8f2fdd71d2b3 -Author: John Baldwin -Date: Sat Jul 16 10:14:08 2016 -0700 - - Use a real vfork done event on FreeBSD when available. - - FreeBSD 12 recently added a new ptrace event to indicate when the vfork - parent resumes after the child process stops sharing the address space. - Use this event to report a proper TARGET_WAITKIND_VFORK_DONE rather than - faking a vfork done event after a delay. - - gdb/ChangeLog: - - * fbsd-nat.c (fbsd_enable_proc_events): Enable "PTRACE_VFORK" - events. - (fbsd_pending_vfork_done): Only define if "PTRACE_VFORK" is not - defined. - (fbsd_add_vfork_done): Likewise. - (fbsd_is_vfork_done_pending): Likewise. - (fbsd_next_vfork_done): Likewise. - (fbsd_resume): Only ignore pending vfork done events if - "PTRACE_VFORK" is not defined. - (fbsd_wait): Only look for pending vfork done events if - "PTRACE_VFORK" is not defined. - [PTRACE_VFORK]: Handle "PL_FLAG_VFORKED" and "PL_FLAG_VFORK_DONE" - events. - (fbsd_follow_fork): Only fake a vfork done event if "PTRACE_VFORK" - is not defined. - -diff --git gdb/fbsd-nat.c gdb/fbsd-nat.c -index 5e4304e..ade62f1 100644 ---- gdb/fbsd-nat.c -+++ gdb/fbsd-nat.c -@@ -435,6 +435,9 @@ fbsd_enable_proc_events (pid_t pid) - sizeof (events)) == -1) - perror_with_name (("ptrace")); - events |= PTRACE_FORK | PTRACE_LWP; -+#ifdef PTRACE_VFORK -+ events |= PTRACE_VFORK; -+#endif - if (ptrace (PT_SET_EVENT_MASK, pid, (PTRACE_TYPE_ARG3)&events, - sizeof (events)) == -1) - perror_with_name (("ptrace")); -@@ -598,6 +601,7 @@ fbsd_is_child_pending (pid_t pid) - return null_ptid; - } - -+#ifndef PTRACE_VFORK - static struct fbsd_fork_info *fbsd_pending_vfork_done; - - /* Record a pending vfork done event. */ -@@ -647,6 +651,7 @@ fbsd_next_vfork_done (void) - return null_ptid; - } - #endif -+#endif - - static int - resume_one_thread_cb (struct thread_info *tp, void *data) -@@ -686,7 +691,7 @@ static void - fbsd_resume (struct target_ops *ops, - ptid_t ptid, int step, enum gdb_signal signo) - { --#ifdef TDP_RFPPWAIT -+#if defined(TDP_RFPPWAIT) && !defined(PTRACE_VFORK) - pid_t pid; - - /* Don't PT_CONTINUE a process which has a pending vfork done event. */ -@@ -731,12 +736,14 @@ fbsd_wait (struct target_ops *ops, - - while (1) - { -+#ifndef PTRACE_VFORK - wptid = fbsd_next_vfork_done (); - if (!ptid_equal (wptid, null_ptid)) - { - ourstatus->kind = TARGET_WAITKIND_VFORK_DONE; - return wptid; - } -+#endif - wptid = super_wait (ops, ptid, ourstatus, target_options); - if (ourstatus->kind == TARGET_WAITKIND_STOPPED) - { -@@ -812,12 +819,18 @@ fbsd_wait (struct target_ops *ops, - #ifdef TDP_RFPPWAIT - if (pl.pl_flags & PL_FLAG_FORKED) - { -+#ifndef PTRACE_VFORK - struct kinfo_proc kp; -+#endif - ptid_t child_ptid; - pid_t child; - - child = pl.pl_child_pid; - ourstatus->kind = TARGET_WAITKIND_FORKED; -+#ifdef PTRACE_VFORK -+ if (pl.pl_flags & PL_FLAG_VFORKED) -+ ourstatus->kind = TARGET_WAITKIND_VFORKED; -+#endif - - /* Make sure the other end of the fork is stopped too. */ - child_ptid = fbsd_is_child_pending (child); -@@ -839,11 +852,13 @@ fbsd_wait (struct target_ops *ops, - /* Enable additional events on the child process. */ - fbsd_enable_proc_events (ptid_get_pid (child_ptid)); - -+#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; -+#endif - ourstatus->value.related_pid = child_ptid; - - return wptid; -@@ -857,6 +872,14 @@ fbsd_wait (struct target_ops *ops, - fbsd_remember_child (wptid); - continue; - } -+ -+#ifdef PTRACE_VFORK -+ if (pl.pl_flags & PL_FLAG_VFORK_DONE) -+ { -+ ourstatus->kind = TARGET_WAITKIND_VFORK_DONE; -+ return wptid; -+ } -+#endif - #endif - - #ifdef PL_FLAG_EXEC -@@ -918,7 +941,6 @@ fbsd_follow_fork (struct target_ops *ops, int follow_child, - if (!follow_child && detach_fork) - { - struct thread_info *tp = inferior_thread (); -- int has_vforked = tp->pending_follow.kind == TARGET_WAITKIND_VFORKED; - pid_t child_pid = ptid_get_pid (tp->pending_follow.value.related_pid); - - /* Breakpoints have already been detached from the child by -@@ -927,7 +949,8 @@ fbsd_follow_fork (struct target_ops *ops, int follow_child, - if (ptrace (PT_DETACH, child_pid, (PTRACE_TYPE_ARG3)1, 0) == -1) - perror_with_name (("ptrace")); - -- if (has_vforked) -+#ifndef PTRACE_VFORK -+ if (tp->pending_follow.kind == TARGET_WAITKIND_VFORKED) - { - /* We can't insert breakpoints until the child process has - finished with the shared memory region. The parent -@@ -953,6 +976,7 @@ fbsd_follow_fork (struct target_ops *ops, int follow_child, - wait. */ - fbsd_add_vfork_done (inferior_ptid); - } -+#endif - } - - return 0; Property changes on: head/devel/gdb/files/commit-dbaed38 ___________________________________________________________________ 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-a3405d1 =================================================================== --- head/devel/gdb/files/commit-a3405d1 (revision 428875) +++ head/devel/gdb/files/commit-a3405d1 (nonexistent) @@ -1,827 +0,0 @@ -commit a3405d124e1388b613a35af49f19f0cc1b8d959d -Author: John Baldwin -Date: Mon Jun 27 13:19:09 2016 -0700 - - Consolidate x86 debug register code for BSD native targets. - - Move the debug register support code from amd64bsd-nat.c and - i386bsd-nat.c into a shared x86bsd-nat.c. - - Instead of setting up x86_dr_low in amd64fbsd-nat.c and - i386fbsd-nat.c, add a x86bsd_target function that creates a new target - that inherits from inf_ptrace and sets up x86 debug registers if - supported. In addition to initializing x86_dr_low, the x86bsd target - installs a custom mourn_inferior target operation to clean up the - x86 debug register state. Previously this was only done on amd64. - Now it will be done for both i386 and amd64. The i386bsd_target and - amd64bsd_target functions create targets that inherit from x86bsd - rather than inf_ptrace. - - gdb/ChangeLog: - - * Makefile.in [HFILES_NO_SRCDIR]: Replace 'amd64bsd-nat.h' with - 'x86bsd-nat.h'. - * amd64bsd-nat.c: Include 'x86bsd-nat.h' instead of - 'amd64bsd-nat.h'. - (amd64bsd_xsave_len): Rename and move to x86bsd-nat.c. - (amd64bsd_fetch_inferior_registers): Replace 'amd64bsd_xsave_len' - with 'x86bsd_xsave_len'. - (amd64bsd_store_inferior_registers): Likewise. - (amd64bsd_target): Inherit from x86bsd_target. - (amd64bsd_dr_get): Rename and move to x86bsd-nat.c. - (amd64bsd_dr_set): Likewise. - (amd64bsd_dr_set_control): Likewise. - (amd64bsd_dr_set_addr): Likewise. - (amd64bsd_dr_get_addr): Likewise. - (amd64bsd_dr_get_status): Likewise. - (amd64bsd_dr_get_control): Likewise. - * amd64fbsd-nat.c: Include 'x86bsd-nat.h' instead of - 'amd64bsd-nat.h'. - (super_mourn_inferior): Move to x86bsd-nat.c. - (amd64fbsd_mourn_inferior): Rename and move to x86bsd-nat.c. - (amd64fbsd_read_description): Replace 'amd64bsd_xsave_len' with - 'x86bsd_xsave_len'. - (_initialize_amd64fbsd_nat): Remove x86 watchpoint setup and - mourn_inferior' target op. - * config/i386/fbsd.mh (NATDEPFILES): Add x86bsd-nat.o. - * config/i386/fbsd64.mh: Likewise. - * config/i386/nbsd64.mh: Likewise. - * config/i386/nbsdelf.mh: Likewise. - * config/i386/obsd.mh: Likewise. - * config/i386/obsd64.mh: Likewise. - * i386bsd-nat.c: Include 'x86bsd-nat.h'. - (i386bsd_xsave_len): Rename and move to x86bsd-nat.c. - (i386bsd_fetch_inferior_registers): Replace 'i386bsd_xsave_len' - with 'x86bsd_xsave_len'. - (i386bsd_store_inferior_registers): Likewise. - (i386bsd_target): Inherit from x86bsd_target. - (i386bsd_dr_get): Rename and move to x86bsd-nat.c. - (i386bsd_dr_set): Likewise. - (i386bsd_dr_set_control): Likewise. - (i386bsd_dr_set_addr): Likewise. - (i386bsd_dr_get_addr): Likewise. - (i386bsd_dr_get_status): Likewise. - (i386bsd_dr_get_control): Likewise. - * i386bsd-nat.h (i386bsd_xsave_len): Remove. - (i386bsd_dr_set_control): Remove. - (i386bsd_dr_set_addr): Remove. - (i386bsd_dr_get_addr): Remove. - (i386bsd_dr_get_status): Remove. - (i386bsd_dr_get_control): Remove. - * i386fbsd-nat.c: Include 'x86bsd-nat.h'. - (i386fbsd_read_description): Replace 'i386bsd_xsave_len' with - 'x86bsd_xsave_len'. - (_initialize_i386fbsd_nat): Remove x86 watchpoint setup and - mourn_inferior' target op. - * x86bsd-nat.c: New file. - * x86bsd-nat.h: New file. - -diff --git gdb/Makefile.in gdb/Makefile.in -index 16d5f27..5af6103 100644 ---- gdb/Makefile.in -+++ gdb/Makefile.in -@@ -912,7 +912,7 @@ common/gdb_signals.h nat/gdb_thread_db.h common/gdb_vecs.h \ - common/x86-xstate.h nat/linux-ptrace.h nat/mips-linux-watch.h \ - proc-utils.h aarch64-tdep.h arm-tdep.h ax-gdb.h ppcfbsd-tdep.h \ - ppcnbsd-tdep.h cli-out.h gdb_expat.h breakpoint.h infcall.h obsd-tdep.h \ --exec.h m32r-tdep.h osabi.h gdbcore.h amd64bsd-nat.h \ -+exec.h m32r-tdep.h osabi.h gdbcore.h x86bsd-nat.h \ - i386bsd-nat.h xml-support.h xml-tdesc.h alphabsd-tdep.h gdb_obstack.h \ - ia64-tdep.h ada-lang.h varobj.h varobj-iter.h frv-tdep.h \ - nto-tdep.h serial.h \ -diff --git gdb/amd64bsd-nat.c gdb/amd64bsd-nat.c -index e278a91..b87672a 100644 ---- gdb/amd64bsd-nat.c -+++ gdb/amd64bsd-nat.c -@@ -31,14 +31,10 @@ - - #include "amd64-tdep.h" - #include "amd64-nat.h" --#include "amd64bsd-nat.h" -+#include "x86bsd-nat.h" - #include "inf-ptrace.h" - - --#ifdef PT_GETXSTATE_INFO --size_t amd64bsd_xsave_len; --#endif -- - /* Fetch register REGNUM from the inferior. If REGNUM is -1, do this - for all registers (including the floating-point registers). */ - -@@ -67,9 +63,9 @@ amd64bsd_fetch_inferior_registers (struct target_ops *ops, - #ifdef PT_GETXSTATE_INFO - void *xstateregs; - -- if (amd64bsd_xsave_len != 0) -+ if (x86bsd_xsave_len != 0) - { -- xstateregs = alloca (amd64bsd_xsave_len); -+ xstateregs = alloca (x86bsd_xsave_len); - if (ptrace (PT_GETXSTATE, get_ptrace_pid (inferior_ptid), - (PTRACE_TYPE_ARG3) xstateregs, 0) == -1) - perror_with_name (_("Couldn't get extended state status")); -@@ -120,9 +116,9 @@ amd64bsd_store_inferior_registers (struct target_ops *ops, - #ifdef PT_GETXSTATE_INFO - void *xstateregs; - -- if (amd64bsd_xsave_len != 0) -+ if (x86bsd_xsave_len != 0) - { -- xstateregs = alloca (amd64bsd_xsave_len); -+ xstateregs = alloca (x86bsd_xsave_len); - if (ptrace (PT_GETXSTATE, get_ptrace_pid (inferior_ptid), - (PTRACE_TYPE_ARG3) xstateregs, 0) == -1) - perror_with_name (_("Couldn't get extended state status")); -@@ -130,7 +126,7 @@ amd64bsd_store_inferior_registers (struct target_ops *ops, - amd64_collect_xsave (regcache, regnum, xstateregs, 0); - - if (ptrace (PT_SETXSTATE, get_ptrace_pid (inferior_ptid), -- (PTRACE_TYPE_ARG3) xstateregs, amd64bsd_xsave_len) == -1) -+ (PTRACE_TYPE_ARG3) xstateregs, x86bsd_xsave_len) == -1) - perror_with_name (_("Couldn't write extended state status")); - return; - } -@@ -156,80 +152,8 @@ amd64bsd_target (void) - { - struct target_ops *t; - -- t = inf_ptrace_target (); -+ t = x86bsd_target (); - t->to_fetch_registers = amd64bsd_fetch_inferior_registers; - t->to_store_registers = amd64bsd_store_inferior_registers; - return t; - } -- -- --/* Support for debug registers. */ -- --#ifdef HAVE_PT_GETDBREGS -- --static unsigned long --amd64bsd_dr_get (ptid_t ptid, int regnum) --{ -- struct dbreg dbregs; -- -- if (ptrace (PT_GETDBREGS, get_ptrace_pid (inferior_ptid), -- (PTRACE_TYPE_ARG3) &dbregs, 0) == -1) -- perror_with_name (_("Couldn't read debug registers")); -- -- return DBREG_DRX ((&dbregs), regnum); --} -- --static void --amd64bsd_dr_set (int regnum, unsigned long value) --{ -- struct dbreg dbregs; -- -- if (ptrace (PT_GETDBREGS, get_ptrace_pid (inferior_ptid), -- (PTRACE_TYPE_ARG3) &dbregs, 0) == -1) -- perror_with_name (_("Couldn't get debug registers")); -- -- /* For some mysterious reason, some of the reserved bits in the -- debug control register get set. Mask these off, otherwise the -- ptrace call below will fail. */ -- DBREG_DRX ((&dbregs), 7) &= ~(0xffffffff0000fc00); -- -- DBREG_DRX ((&dbregs), regnum) = value; -- -- if (ptrace (PT_SETDBREGS, get_ptrace_pid (inferior_ptid), -- (PTRACE_TYPE_ARG3) &dbregs, 0) == -1) -- perror_with_name (_("Couldn't write debug registers")); --} -- --void --amd64bsd_dr_set_control (unsigned long control) --{ -- amd64bsd_dr_set (7, control); --} -- --void --amd64bsd_dr_set_addr (int regnum, CORE_ADDR addr) --{ -- gdb_assert (regnum >= 0 && regnum <= 4); -- -- amd64bsd_dr_set (regnum, addr); --} -- --CORE_ADDR --amd64bsd_dr_get_addr (int regnum) --{ -- return amd64bsd_dr_get (inferior_ptid, regnum); --} -- --unsigned long --amd64bsd_dr_get_status (void) --{ -- return amd64bsd_dr_get (inferior_ptid, 6); --} -- --unsigned long --amd64bsd_dr_get_control (void) --{ -- return amd64bsd_dr_get (inferior_ptid, 7); --} -- --#endif /* PT_GETDBREGS */ -diff --git gdb/amd64bsd-nat.h gdb/amd64bsd-nat.h -deleted file mode 100644 -index f6a4022..0000000 ---- gdb/amd64bsd-nat.h -+++ /dev/null -@@ -1,38 +0,0 @@ --/* Native-dependent code for AMD64 BSD's. -- -- Copyright (C) 2011-2016 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 . */ -- --#ifndef AMD64BSD_NAT_H --#define AMD64BSD_NAT_H -- --/* Low level amd64 XSAVE info. */ --extern size_t amd64bsd_xsave_len; -- --/* Low level amd64 debug register functions. */ -- --extern void amd64bsd_dr_set_control (unsigned long control); -- --extern void amd64bsd_dr_set_addr (int regnum, CORE_ADDR addr); -- --extern CORE_ADDR amd64bsd_dr_get_addr (int regnum); -- --extern unsigned long amd64bsd_dr_get_status (void); -- --extern unsigned long amd64bsd_dr_get_control (void); -- --#endif /* amd64bsd-nat.h */ -diff --git gdb/amd64fbsd-nat.c gdb/amd64fbsd-nat.c -index 63a7197..66c374c 100644 ---- gdb/amd64fbsd-nat.c -+++ gdb/amd64fbsd-nat.c -@@ -32,7 +32,7 @@ - #include "fbsd-nat.h" - #include "amd64-tdep.h" - #include "amd64-nat.h" --#include "amd64bsd-nat.h" -+#include "x86bsd-nat.h" - #include "x86-nat.h" - - -@@ -140,17 +140,6 @@ amd64fbsd_supply_pcb (struct regcache *regcache, struct pcb *pcb) - } - - --static void (*super_mourn_inferior) (struct target_ops *ops); -- --static void --amd64fbsd_mourn_inferior (struct target_ops *ops) --{ --#ifdef HAVE_PT_GETDBREGS -- x86_cleanup_dregs (); --#endif -- super_mourn_inferior (ops); --} -- - /* Implement the to_read_description method. */ - - static const struct target_desc * -@@ -175,13 +164,13 @@ amd64fbsd_read_description (struct target_ops *ops) - if (ptrace (PT_GETXSTATE_INFO, ptid_get_pid (inferior_ptid), - (PTRACE_TYPE_ARG3) &info, sizeof (info)) == 0) - { -- amd64bsd_xsave_len = info.xsave_len; -+ x86bsd_xsave_len = info.xsave_len; - xcr0 = info.xsave_mask; - } - xsave_probed = 1; - } - -- if (amd64bsd_xsave_len != 0) -+ if (x86bsd_xsave_len != 0) - { - if (is64) - return amd64_target_description (xcr0); -@@ -209,22 +198,6 @@ _initialize_amd64fbsd_nat (void) - - /* Add some extra features to the common *BSD/i386 target. */ - t = amd64bsd_target (); -- --#ifdef HAVE_PT_GETDBREGS -- -- x86_use_watchpoints (t); -- -- x86_dr_low.set_control = amd64bsd_dr_set_control; -- x86_dr_low.set_addr = amd64bsd_dr_set_addr; -- x86_dr_low.get_addr = amd64bsd_dr_get_addr; -- x86_dr_low.get_status = amd64bsd_dr_get_status; -- x86_dr_low.get_control = amd64bsd_dr_get_control; -- x86_set_debug_register_length (8); -- --#endif /* HAVE_PT_GETDBREGS */ -- -- super_mourn_inferior = t->to_mourn_inferior; -- t->to_mourn_inferior = amd64fbsd_mourn_inferior; - t->to_read_description = amd64fbsd_read_description; - - fbsd_nat_add_target (t); -diff --git gdb/config/i386/fbsd.mh gdb/config/i386/fbsd.mh -index e5bff3a..1db6660 100644 ---- gdb/config/i386/fbsd.mh -+++ gdb/config/i386/fbsd.mh -@@ -1,7 +1,7 @@ - # Host: FreeBSD/i386 - NATDEPFILES= fork-child.o inf-ptrace.o \ -- fbsd-nat.o x86-nat.o x86-dregs.o i386bsd-nat.o i386fbsd-nat.o \ -- bsd-kvm.o -+ fbsd-nat.o x86-nat.o x86-dregs.o x86bsd-nat.o i386bsd-nat.o \ -+ i386fbsd-nat.o bsd-kvm.o - NAT_FILE= nm-fbsd.h - HAVE_NATIVE_GCORE_HOST = 1 - -diff --git gdb/config/i386/fbsd64.mh gdb/config/i386/fbsd64.mh -index 329c526..e196c00 100644 ---- gdb/config/i386/fbsd64.mh -+++ gdb/config/i386/fbsd64.mh -@@ -1,7 +1,7 @@ - # Host: FreeBSD/amd64 - NATDEPFILES= fork-child.o inf-ptrace.o \ - fbsd-nat.o amd64-nat.o amd64bsd-nat.o amd64fbsd-nat.o \ -- bsd-kvm.o x86-nat.o x86-dregs.o -+ bsd-kvm.o x86-nat.o x86-dregs.o x86bsd-nat.o - HAVE_NATIVE_GCORE_HOST = 1 - - LOADLIBES= -lkvm -diff --git gdb/config/i386/nbsd64.mh gdb/config/i386/nbsd64.mh -index 5de8cf5..5fa369f 100644 ---- gdb/config/i386/nbsd64.mh -+++ gdb/config/i386/nbsd64.mh -@@ -1,3 +1,3 @@ - # Host: NetBSD/amd64 - NATDEPFILES= fork-child.o inf-ptrace.o \ -- nbsd-nat.o amd64-nat.o amd64bsd-nat.o amd64nbsd-nat.o -+ nbsd-nat.o amd64-nat.o x86bsd-nat.o amd64bsd-nat.o amd64nbsd-nat.o -diff --git gdb/config/i386/nbsdelf.mh gdb/config/i386/nbsdelf.mh -index d27c842..f8b9d6c 100644 ---- gdb/config/i386/nbsdelf.mh -+++ gdb/config/i386/nbsdelf.mh -@@ -1,5 +1,5 @@ - # Host: NetBSD/i386 ELF - NATDEPFILES= fork-child.o inf-ptrace.o \ -- nbsd-nat.o i386bsd-nat.o i386nbsd-nat.o bsd-kvm.o -+ nbsd-nat.o x86bsd-nat.o i386bsd-nat.o i386nbsd-nat.o bsd-kvm.o - - LOADLIBES= -lkvm -diff --git gdb/config/i386/obsd.mh gdb/config/i386/obsd.mh -index a9041f4..3845d26 100644 ---- gdb/config/i386/obsd.mh -+++ gdb/config/i386/obsd.mh -@@ -1,5 +1,5 @@ - # Host: OpenBSD/i386 ELF - NATDEPFILES= fork-child.o inf-ptrace.o obsd-nat.o \ -- i386bsd-nat.o i386obsd-nat.o bsd-kvm.o -+ x86bsd-nat.o i386bsd-nat.o i386obsd-nat.o bsd-kvm.o - - LOADLIBES= -lkvm -diff --git gdb/config/i386/obsd64.mh gdb/config/i386/obsd64.mh -index 386a582..2a8c42c 100644 ---- gdb/config/i386/obsd64.mh -+++ gdb/config/i386/obsd64.mh -@@ -1,5 +1,5 @@ - # Host: OpenBSD/amd64 - NATDEPFILES= fork-child.o inf-ptrace.o obsd-nat.o \ -- amd64-nat.o amd64bsd-nat.o amd64obsd-nat.o bsd-kvm.o -+ amd64-nat.o x86bsd-nat.o amd64bsd-nat.o amd64obsd-nat.o bsd-kvm.o - - LOADLIBES= -lkvm -diff --git gdb/i386bsd-nat.c gdb/i386bsd-nat.c -index f5f4a0f..b6b143b 100644 ---- gdb/i386bsd-nat.c -+++ gdb/i386bsd-nat.c -@@ -29,6 +29,7 @@ - - #include "i386-tdep.h" - #include "i387-tdep.h" -+#include "x86bsd-nat.h" - #include "i386bsd-nat.h" - #include "inf-ptrace.h" - -@@ -81,10 +82,6 @@ static int i386bsd_r_reg_offset[] = - so that we try PT_GETXMMREGS the first time around. */ - static int have_ptrace_xmmregs = -1; - #endif -- --#ifdef PT_GETXSTATE_INFO --size_t i386bsd_xsave_len; --#endif - - - /* Supply the general-purpose registers in GREGS, to REGCACHE. */ -@@ -155,11 +152,11 @@ i386bsd_fetch_inferior_registers (struct target_ops *ops, - #endif - - #ifdef PT_GETXSTATE_INFO -- if (i386bsd_xsave_len != 0) -+ if (x86bsd_xsave_len != 0) - { - void *xstateregs; - -- xstateregs = alloca (i386bsd_xsave_len); -+ xstateregs = alloca (x86bsd_xsave_len); - if (ptrace (PT_GETXSTATE, get_ptrace_pid (inferior_ptid), - (PTRACE_TYPE_ARG3) xstateregs, 0) == -1) - perror_with_name (_("Couldn't get extended state status")); -@@ -225,11 +222,11 @@ i386bsd_store_inferior_registers (struct target_ops *ops, - #endif - - #ifdef PT_GETXSTATE_INFO -- if (i386bsd_xsave_len != 0) -+ if (x86bsd_xsave_len != 0) - { - void *xstateregs; - -- xstateregs = alloca (i386bsd_xsave_len); -+ xstateregs = alloca (x86bsd_xsave_len); - if (ptrace (PT_GETXSTATE, get_ptrace_pid (inferior_ptid), - (PTRACE_TYPE_ARG3) xstateregs, 0) == -1) - perror_with_name (_("Couldn't get extended state status")); -@@ -237,7 +234,7 @@ i386bsd_store_inferior_registers (struct target_ops *ops, - i387_collect_xsave (regcache, -1, xstateregs, 0); - - if (ptrace (PT_SETXSTATE, get_ptrace_pid (inferior_ptid), -- (PTRACE_TYPE_ARG3) xstateregs, i386bsd_xsave_len) == -1) -+ (PTRACE_TYPE_ARG3) xstateregs, x86bsd_xsave_len) == -1) - perror_with_name (_("Couldn't write extended state status")); - return; - } -@@ -283,91 +280,13 @@ i386bsd_target (void) - { - struct target_ops *t; - -- t = inf_ptrace_target (); -+ t = x86bsd_target (); - t->to_fetch_registers = i386bsd_fetch_inferior_registers; - t->to_store_registers = i386bsd_store_inferior_registers; - return t; - } - - --/* Support for debug registers. */ -- --#ifdef HAVE_PT_GETDBREGS -- --/* Not all versions of FreeBSD/i386 that support the debug registers -- have this macro. */ --#ifndef DBREG_DRX --#define DBREG_DRX(d, x) ((&d->dr0)[x]) --#endif -- --static unsigned long --i386bsd_dr_get (ptid_t ptid, int regnum) --{ -- struct dbreg dbregs; -- -- if (ptrace (PT_GETDBREGS, get_ptrace_pid (inferior_ptid), -- (PTRACE_TYPE_ARG3) &dbregs, 0) == -1) -- perror_with_name (_("Couldn't read debug registers")); -- -- return DBREG_DRX ((&dbregs), regnum); --} -- --static void --i386bsd_dr_set (int regnum, unsigned int value) --{ -- struct dbreg dbregs; -- -- if (ptrace (PT_GETDBREGS, get_ptrace_pid (inferior_ptid), -- (PTRACE_TYPE_ARG3) &dbregs, 0) == -1) -- perror_with_name (_("Couldn't get debug registers")); -- -- /* For some mysterious reason, some of the reserved bits in the -- debug control register get set. Mask these off, otherwise the -- ptrace call below will fail. */ -- DBREG_DRX ((&dbregs), 7) &= ~(0x0000fc00); -- -- DBREG_DRX ((&dbregs), regnum) = value; -- -- if (ptrace (PT_SETDBREGS, get_ptrace_pid (inferior_ptid), -- (PTRACE_TYPE_ARG3) &dbregs, 0) == -1) -- perror_with_name (_("Couldn't write debug registers")); --} -- --void --i386bsd_dr_set_control (unsigned long control) --{ -- i386bsd_dr_set (7, control); --} -- --void --i386bsd_dr_set_addr (int regnum, CORE_ADDR addr) --{ -- gdb_assert (regnum >= 0 && regnum <= 4); -- -- i386bsd_dr_set (regnum, addr); --} -- --CORE_ADDR --i386bsd_dr_get_addr (int regnum) --{ -- return i386bsd_dr_get (inferior_ptid, regnum); --} -- --unsigned long --i386bsd_dr_get_status (void) --{ -- return i386bsd_dr_get (inferior_ptid, 6); --} -- --unsigned long --i386bsd_dr_get_control (void) --{ -- return i386bsd_dr_get (inferior_ptid, 7); --} -- --#endif /* PT_GETDBREGS */ -- -- - /* Provide a prototype to silence -Wmissing-prototypes. */ - void _initialize_i386bsd_nat (void); - -diff --git gdb/i386bsd-nat.h gdb/i386bsd-nat.h -index 78ea551..1b51d19 100644 ---- gdb/i386bsd-nat.h -+++ gdb/i386bsd-nat.h -@@ -25,19 +25,4 @@ - - extern struct target_ops *i386bsd_target (void); - --/* Low level i386 XSAVE info. */ --extern size_t i386bsd_xsave_len; -- --/* low level i386 debug register functions used in i386fbsd-nat.c. */ -- --extern void i386bsd_dr_set_control (unsigned long control); -- --extern void i386bsd_dr_set_addr (int regnum, CORE_ADDR addr); -- --extern CORE_ADDR i386bsd_dr_get_addr (int regnum); -- --extern unsigned long i386bsd_dr_get_status (void); -- --extern unsigned long i386bsd_dr_get_control (void); -- - #endif /* i386bsd-nat.h */ -diff --git gdb/i386fbsd-nat.c gdb/i386fbsd-nat.c -index 7d371a6..716b513 100644 ---- gdb/i386fbsd-nat.c -+++ gdb/i386fbsd-nat.c -@@ -30,6 +30,7 @@ - #include "fbsd-nat.h" - #include "i386-tdep.h" - #include "x86-nat.h" -+#include "x86bsd-nat.h" - #include "i386bsd-nat.h" - - /* Resume execution of the inferior process. If STEP is nonzero, -@@ -132,13 +133,13 @@ i386fbsd_read_description (struct target_ops *ops) - if (ptrace (PT_GETXSTATE_INFO, ptid_get_pid (inferior_ptid), - (PTRACE_TYPE_ARG3) &info, sizeof (info)) == 0) - { -- i386bsd_xsave_len = info.xsave_len; -+ x86bsd_xsave_len = info.xsave_len; - xcr0 = info.xsave_mask; - } - xsave_probed = 1; - } - -- if (i386bsd_xsave_len != 0) -+ if (x86bsd_xsave_len != 0) - { - return i386_target_description (xcr0); - } -@@ -158,19 +159,6 @@ _initialize_i386fbsd_nat (void) - /* Add some extra features to the common *BSD/i386 target. */ - t = i386bsd_target (); - --#ifdef HAVE_PT_GETDBREGS -- -- x86_use_watchpoints (t); -- -- x86_dr_low.set_control = i386bsd_dr_set_control; -- x86_dr_low.set_addr = i386bsd_dr_set_addr; -- x86_dr_low.get_addr = i386bsd_dr_get_addr; -- x86_dr_low.get_status = i386bsd_dr_get_status; -- x86_dr_low.get_control = i386bsd_dr_get_control; -- x86_set_debug_register_length (4); -- --#endif /* HAVE_PT_GETDBREGS */ -- - #ifdef PT_GETXSTATE_INFO - t->to_read_description = i386fbsd_read_description; - #endif -diff --git gdb/x86bsd-nat.c gdb/x86bsd-nat.c -new file mode 100644 -index 0000000..0c56848 ---- /dev/null -+++ gdb/x86bsd-nat.c -@@ -0,0 +1,150 @@ -+/* Native-dependent code for X86 BSD's. -+ -+ Copyright (C) 2003-2016 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 "inferior.h" -+ -+/* We include to make sure `struct fxsave64' is defined on -+ NetBSD, since NetBSD's needs it. */ -+#include -+#include -+#include -+#include -+ -+#include "x86-nat.h" -+#include "x86bsd-nat.h" -+#include "inf-ptrace.h" -+ -+ -+#ifdef PT_GETXSTATE_INFO -+size_t x86bsd_xsave_len; -+#endif -+ -+/* Support for debug registers. */ -+ -+#ifdef HAVE_PT_GETDBREGS -+static void (*super_mourn_inferior) (struct target_ops *ops); -+ -+/* Implement the "to_mourn_inferior" target_ops method. */ -+ -+static void -+x86bsd_mourn_inferior (struct target_ops *ops) -+{ -+ x86_cleanup_dregs (); -+ super_mourn_inferior (ops); -+} -+ -+/* Not all versions of FreeBSD/i386 that support the debug registers -+ have this macro. */ -+#ifndef DBREG_DRX -+#define DBREG_DRX(d, x) ((&d->dr0)[x]) -+#endif -+ -+static unsigned long -+x86bsd_dr_get (ptid_t ptid, int regnum) -+{ -+ struct dbreg dbregs; -+ -+ if (ptrace (PT_GETDBREGS, get_ptrace_pid (inferior_ptid), -+ (PTRACE_TYPE_ARG3) &dbregs, 0) == -1) -+ perror_with_name (_("Couldn't read debug registers")); -+ -+ return DBREG_DRX ((&dbregs), regnum); -+} -+ -+static void -+x86bsd_dr_set (int regnum, unsigned long value) -+{ -+ struct dbreg dbregs; -+ -+ if (ptrace (PT_GETDBREGS, get_ptrace_pid (inferior_ptid), -+ (PTRACE_TYPE_ARG3) &dbregs, 0) == -1) -+ perror_with_name (_("Couldn't get debug registers")); -+ -+ /* For some mysterious reason, some of the reserved bits in the -+ debug control register get set. Mask these off, otherwise the -+ ptrace call below will fail. */ -+ DBREG_DRX ((&dbregs), 7) &= ~(0xffffffff0000fc00); -+ -+ DBREG_DRX ((&dbregs), regnum) = value; -+ -+ if (ptrace (PT_SETDBREGS, get_ptrace_pid (inferior_ptid), -+ (PTRACE_TYPE_ARG3) &dbregs, 0) == -1) -+ perror_with_name (_("Couldn't write debug registers")); -+} -+ -+static void -+x86bsd_dr_set_control (unsigned long control) -+{ -+ x86bsd_dr_set (7, control); -+} -+ -+static void -+x86bsd_dr_set_addr (int regnum, CORE_ADDR addr) -+{ -+ gdb_assert (regnum >= 0 && regnum <= 4); -+ -+ x86bsd_dr_set (regnum, addr); -+} -+ -+static CORE_ADDR -+x86bsd_dr_get_addr (int regnum) -+{ -+ return x86bsd_dr_get (inferior_ptid, regnum); -+} -+ -+static unsigned long -+x86bsd_dr_get_status (void) -+{ -+ return x86bsd_dr_get (inferior_ptid, 6); -+} -+ -+static unsigned long -+x86bsd_dr_get_control (void) -+{ -+ return x86bsd_dr_get (inferior_ptid, 7); -+} -+ -+#endif /* PT_GETDBREGS */ -+ -+/* Create a prototype *BSD/x86 target. The client can override it -+ with local methods. */ -+ -+struct target_ops * -+x86bsd_target (void) -+{ -+ struct target_ops *t; -+ -+ t = inf_ptrace_target (); -+ -+#ifdef HAVE_PT_GETDBREGS -+ x86_use_watchpoints (t); -+ -+ x86_dr_low.set_control = x86bsd_dr_set_control; -+ x86_dr_low.set_addr = x86bsd_dr_set_addr; -+ x86_dr_low.get_addr = x86bsd_dr_get_addr; -+ x86_dr_low.get_status = x86bsd_dr_get_status; -+ x86_dr_low.get_control = x86bsd_dr_get_control; -+ x86_set_debug_register_length (sizeof (void *)); -+ super_mourn_inferior = t->to_mourn_inferior; -+ t->to_mourn_inferior = x86bsd_mourn_inferior; -+#endif /* HAVE_PT_GETDBREGS */ -+ -+ return t; -+} -diff --git gdb/x86bsd-nat.h gdb/x86bsd-nat.h -new file mode 100644 -index 0000000..6d39697 ---- /dev/null -+++ gdb/x86bsd-nat.h -@@ -0,0 +1,31 @@ -+/* Native-dependent code for x86 BSD's. -+ -+ Copyright (C) 2011-2016 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 . */ -+ -+#ifndef X86BSD_NAT_H -+#define X86BSD_NAT_H -+ -+/* Low level x86 XSAVE info. */ -+extern size_t x86bsd_xsave_len; -+ -+/* Create a prototype *BSD/x86 target. The client can override it -+ with local methods. */ -+ -+extern struct target_ops *x86bsd_target (void); -+ -+#endif /* x86bsd-nat.h */ Property changes on: head/devel/gdb/files/commit-a3405d1 ___________________________________________________________________ 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-82372b2 =================================================================== --- head/devel/gdb/files/commit-82372b2 (revision 428875) +++ head/devel/gdb/files/commit-82372b2 (nonexistent) @@ -1,74 +0,0 @@ -commit 82372b2f2747d347e24bb10ddc7bc7e828222a42 -Author: John Baldwin -Date: Wed Jun 15 21:33:42 2016 -0700 - - Add a gdbarch 'print_auxv_entry' method for FreeBSD ABIs. - - Add a 'print_auxv_entry' method for FreeBSD ABIs that parses - FreeBSD-specific auxiliary vector entries and outputs a suitable - description using fprint_auxv_entry. - - gdb/ChangeLog: - - * fbsd-tdep.c: Include "auxv.h". - (fbsd_print_auxv_entry): New function. - (fbsd_init_abi): Install gdbarch "print_auxv_entry" method. - -diff --git gdb/fbsd-tdep.c gdb/fbsd-tdep.c -index 7310ea0..e8f8605 100644 ---- gdb/fbsd-tdep.c -+++ gdb/fbsd-tdep.c -@@ -18,6 +18,7 @@ - along with this program. If not, see . */ - - #include "defs.h" -+#include "auxv.h" - #include "gdbcore.h" - #include "inferior.h" - #include "regcache.h" -@@ -283,6 +284,39 @@ fbsd_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size) - return note_data; - } - -+/* Print descriptions of FreeBSD-specific AUXV entries to FILE. */ -+ -+static void -+fbsd_print_auxv_entry (struct gdbarch *gdbarch, struct ui_file *file, -+ CORE_ADDR type, CORE_ADDR val) -+{ -+ const char *name; -+ const char *description; -+ enum auxv_format format; -+ -+ switch (type) -+ { -+#define _TAGNAME(tag) #tag -+#define TAGNAME(tag) _TAGNAME(AT_##tag) -+#define TAG(tag, text, kind) \ -+ case AT_FREEBSD_##tag: name = TAGNAME(tag); description = text; format = kind; break -+ TAG (EXECPATH, _("Executable path"), AUXV_FORMAT_STR); -+ TAG (CANARY, _("Canary for SSP"), AUXV_FORMAT_HEX); -+ TAG (CANARYLEN, ("Length of the SSP canary"), AUXV_FORMAT_DEC); -+ TAG (OSRELDATE, _("OSRELDATE"), AUXV_FORMAT_DEC); -+ TAG (NCPUS, _("Number of CPUs"), AUXV_FORMAT_DEC); -+ TAG (PAGESIZES, _("Pagesizes"), AUXV_FORMAT_HEX); -+ TAG (PAGESIZESLEN, _("Number of pagesizes"), AUXV_FORMAT_DEC); -+ TAG (TIMEKEEP, _("Pointer to timehands"), AUXV_FORMAT_HEX); -+ TAG (STACKPROT, _("Initial stack protection"), AUXV_FORMAT_HEX); -+ default: -+ default_print_auxv_entry (gdbarch, file, type, val); -+ return; -+ } -+ -+ fprint_auxv_entry (file, name, description, format, type, val); -+} -+ - /* To be called from GDB_OSABI_FREEBSD_ELF handlers. */ - - void -@@ -291,4 +325,5 @@ 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_make_corefile_notes (gdbarch, fbsd_make_corefile_notes); -+ set_gdbarch_print_auxv_entry (gdbarch, fbsd_print_auxv_entry); - } Property changes on: head/devel/gdb/files/commit-82372b2 ___________________________________________________________________ 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-da95a26 =================================================================== --- head/devel/gdb/files/commit-da95a26 (revision 428875) +++ head/devel/gdb/files/commit-da95a26 (nonexistent) @@ -1,123 +0,0 @@ -commit da95a26cc381c0f092f515ffe108075985c16d7f -Author: John Baldwin -Date: Fri Jul 15 14:03:10 2016 -0700 - - Consolidate code to enable optional FreeBSD native target event reporting. - - Add a new function to enable optional event reporting for FreeBSD native - targets. Specifically, use this to enable fork and LWP events. - The bodies of fbsd_enable_follow_fork and fbsd_enable_lwp_events have been - subsumed into the new function. In addition, use the PT_GET_EVENT_MASK - and PT_EVENT_SET_MASK requests added in FreeBSD 12 when present to enable - these events. - - gdb/ChangeLog: - - * fbsd-nat.c (fbsd_enable_lwp_events): Remove function. - (fbsd_enable_proc_events): New function. - (fbsd_enable_follow_fork): Remove function. - (fbsd_post_startup_inferior): Use "fbsd_enable_proc_events". - (fbsd_post_attach): Likewise. - -diff --git gdb/fbsd-nat.c gdb/fbsd-nat.c -index fa9516e..508ab19 100644 ---- gdb/fbsd-nat.c -+++ gdb/fbsd-nat.c -@@ -412,22 +412,43 @@ fbsd_thread_name (struct target_ops *self, struct thread_info *thr) - } - #endif - --#ifdef PT_LWP_EVENTS --/* Enable LWP events for a specific process. -+/* Enable additional event reporting on new processes. - -- To catch LWP events, PT_LWP_EVENTS is set on every traced process. -+ To catch fork events, PTRACE_FORK is set on every traced process -+ to enable stops on returns from fork or vfork. Note that both the -+ parent and child will always stop, even if system call stops are -+ not enabled. -+ -+ To catch LWP events, PTRACE_EVENTS is set on every traced process. - This enables stops on the birth for new LWPs (excluding the "main" LWP) - and the death of LWPs (excluding the last LWP in a process). Note - that unlike fork events, the LWP that creates a new LWP does not - report an event. */ - - static void --fbsd_enable_lwp_events (pid_t pid) -+fbsd_enable_proc_events (pid_t pid) - { -+#ifdef PT_GET_EVENT_MASK -+ int events; -+ -+ if (ptrace (PT_GET_EVENT_MASK, pid, (PTRACE_TYPE_ARG3)&events, -+ sizeof (events)) == -1) -+ perror_with_name (("ptrace")); -+ events |= PTRACE_FORK | PTRACE_LWP; -+ if (ptrace (PT_SET_EVENT_MASK, pid, (PTRACE_TYPE_ARG3)&events, -+ sizeof (events)) == -1) -+ perror_with_name (("ptrace")); -+#else -+#ifdef TDP_RFPPWAIT -+ if (ptrace (PT_FOLLOW_FORK, pid, (PTRACE_TYPE_ARG3)0, 1) == -1) -+ perror_with_name (("ptrace")); -+#endif -+#ifdef PT_LWP_EVENTS - if (ptrace (PT_LWP_EVENTS, pid, (PTRACE_TYPE_ARG3)0, 1) == -1) - perror_with_name (("ptrace")); --} - #endif -+#endif -+} - - /* Add threads for any new LWPs in a process. - -@@ -957,20 +978,6 @@ fbsd_remove_vfork_catchpoint (struct target_ops *self, int pid) - { - return 0; - } -- --/* Enable fork tracing for a specific process. -- -- To catch fork events, PT_FOLLOW_FORK is set on every traced process -- to enable stops on returns from fork or vfork. Note that both the -- parent and child will always stop, even if system call stops are -- not enabled. */ -- --static void --fbsd_enable_follow_fork (pid_t pid) --{ -- if (ptrace (PT_FOLLOW_FORK, pid, (PTRACE_TYPE_ARG3)0, 1) == -1) -- perror_with_name (("ptrace")); --} - #endif - - /* Implement the "to_post_startup_inferior" target_ops method. */ -@@ -978,12 +985,7 @@ fbsd_enable_follow_fork (pid_t pid) - static void - fbsd_post_startup_inferior (struct target_ops *self, ptid_t pid) - { --#ifdef TDP_RFPPWAIT -- fbsd_enable_follow_fork (ptid_get_pid (pid)); --#endif --#ifdef PT_LWP_EVENTS -- fbsd_enable_lwp_events (ptid_get_pid (pid)); --#endif -+ fbsd_enable_proc_events (ptid_get_pid (pid)); - } - - /* Implement the "to_post_attach" target_ops method. */ -@@ -991,12 +993,7 @@ fbsd_post_startup_inferior (struct target_ops *self, ptid_t pid) - static void - fbsd_post_attach (struct target_ops *self, int pid) - { --#ifdef TDP_RFPPWAIT -- fbsd_enable_follow_fork (pid); --#endif --#ifdef PT_LWP_EVENTS -- fbsd_enable_lwp_events (pid); --#endif -+ fbsd_enable_proc_events (pid); - fbsd_add_threads (pid); - } - Property changes on: head/devel/gdb/files/commit-da95a26 ___________________________________________________________________ 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/extrapatch-kgdb =================================================================== --- head/devel/gdb/files/extrapatch-kgdb (revision 428875) +++ head/devel/gdb/files/extrapatch-kgdb (revision 428876) @@ -1,295 +1,295 @@ diff --git gdb/Makefile.in gdb/Makefile.in index dfaa8a3..182d875 100644 --- gdb/Makefile.in +++ gdb/Makefile.in @@ -207,7 +207,8 @@ # 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 @@ -650,7 +650,8 @@ ALL_64_TARGET_OBS = \ ia64-linux-tdep.o ia64-vms-tdep.o ia64-tdep.o \ mips64obsd-tdep.o \ sparc64fbsd-tdep.o sparc64-linux-tdep.o sparc64nbsd-tdep.o \ - sparc64obsd-tdep.o sparc64-sol2-tdep.o sparc64-tdep.o + sparc64obsd-tdep.o sparc64-sol2-tdep.o sparc64-tdep.o \ + amd64fbsd-kern.o sparc64fbsd-kern.o # All other target-dependent objects files (used with --enable-targets=all). ALL_TARGET_OBS = \ @@ -672,6 +673,7 @@ ALL_TARGET_OBS = \ i386-sol2-tdep.o i386-tdep.o i387-tdep.o \ i386-dicos-tdep.o i386-darwin-tdep.o \ iq2000-tdep.o \ + fbsd-kld.o fbsd-kthr.o fbsd-kvm.o i386fbsd-kern.o ppcfbsd-kern.o \ linux-tdep.o \ lm32-tdep.o \ m32c-tdep.o \ @@ -1123,7 +1125,7 @@ generated_files = config.h observer.h observer.inc ada-lex.c jit-reader.h \ $(COMPILE) $< $(POSTCOMPILE) -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 installcheck: @@ -1393,6 +1395,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 @@ -1437,7 +1445,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 @@ -1667,6 +1675,9 @@ ALLDEPFILES = \ core-regset.c \ dcache.c dicos-tdep.c darwin-nat.c \ exec.c \ + fbsd-kld.c fbsd-kthr.c fbsd-kvm.c \ + amd64fbsd-kern.c i386fbsd-kern.c ppcfbsd-kern.c \ + sparc64fbsd-kern.c \ fbsd-nat.c \ fbsd-tdep.c \ fork-child.c \ @@ -2740,7 +2752,7 @@ # A list of all the objects we might care about in this build, for # dependency tracking. -all_object_files = gdb.o $(LIBGDB_OBS) gdbtk-main.o \ +all_object_files = kgdb-main.o gdb.o $(LIBGDB_OBS) gdbtk-main.o \ test-cp-name-parser.o # Ensure that generated files are created early. Use order-only diff --git gdb/config.in gdb/config.in index 9ef53b3..c55c01b 100644 --- gdb/config.in +++ gdb/config.in @@ -216,6 +216,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/configure gdb/configure index 48acfe5..f0cd958 100755 --- gdb/configure +++ gdb/configure @@ -7104,6 +7104,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 + + diff --git gdb/configure.ac gdb/configure.ac index a40860a..9035d48 100644 --- gdb/configure.ac +++ gdb/configure.ac @@ -539,6 +539,11 @@ AC_SEARCH_LIBS(kinfo_getvmmap, util, [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/defs.h gdb/defs.h index ccdab18..499944f 100644 --- gdb/defs.h +++ gdb/defs.h @@ -549,6 +549,7 @@ enum gdb_osabi GDB_OSABI_LINUX, GDB_OSABI_FREEBSD_AOUT, GDB_OSABI_FREEBSD_ELF, + GDB_OSABI_FREEBSD_ELF_KERNEL, GDB_OSABI_NETBSD_AOUT, GDB_OSABI_NETBSD_ELF, GDB_OSABI_OPENBSD_ELF, diff --git gdb/osabi.c gdb/osabi.c -index 3581eb3..d12656e 100644 +index f7d4e74..130ffef 100644 --- gdb/osabi.c +++ gdb/osabi.c @@ -66,6 +66,7 @@ static const struct osabi_names gdb_osabi_names[] = { "GNU/Linux", "linux(-gnu)?" }, - { "FreeBSD a.out", NULL }, - { "FreeBSD ELF", NULL }, -+ { "FreeBSD ELF kernel", NULL }, - { "NetBSD a.out", NULL }, - { "NetBSD ELF", NULL }, - { "OpenBSD ELF", NULL }, + { "FreeBSD/a.out", NULL }, + { "FreeBSD/ELF", NULL }, ++ { "FreeBSD/kernel", NULL }, + { "NetBSD/a.out", NULL }, + { "NetBSD/ELF", NULL }, + { "OpenBSD/ELF", NULL }, diff --git gdb/regcache.c gdb/regcache.c -index 86e648a..26a0fd5 100644 +index a5c90a6..05044e5 100644 --- gdb/regcache.c +++ gdb/regcache.c -@@ -1065,6 +1065,20 @@ regcache_raw_supply (struct regcache *regcache, int regnum, const void *buf) +@@ -1083,6 +1083,20 @@ regcache_raw_supply (struct regcache *regcache, int regnum, const void *buf) } } +void +regcache_raw_supply_unsigned (struct regcache *regcache, int regnum, + ULONGEST val) +{ -+ void *buf; ++ gdb_byte *buf; + + gdb_assert (regcache != NULL); + gdb_assert (regnum >=0 && regnum < regcache->descr->nr_raw_registers); -+ buf = alloca (regcache->descr->sizeof_register[regnum]); ++ buf = (gdb_byte *)alloca (regcache->descr->sizeof_register[regnum]); + store_unsigned_integer (buf, regcache->descr->sizeof_register[regnum], + gdbarch_byte_order (regcache->descr->gdbarch), val); + regcache_raw_supply (regcache, regnum, buf); +} + /* Collect register REGNUM from REGCACHE and store its contents in BUF. */ void diff --git gdb/regcache.h gdb/regcache.h index a9fb44b..a156918 100644 --- gdb/regcache.h +++ gdb/regcache.h @@ -147,6 +147,8 @@ extern void regcache_write_pc (struct regcache *regcache, CORE_ADDR pc); extern void regcache_raw_supply (struct regcache *regcache, int regnum, const void *buf); +extern void regcache_raw_supply_unsigned (struct regcache *regcache, + int regnum, ULONGEST val); extern void regcache_raw_collect (const struct regcache *regcache, int regnum, void *buf); diff --git gdb/configure.tgt gdb/configure.tgt index 4e4d6a9..57e4b3a 100644 --- gdb/configure.tgt +++ gdb/configure.tgt @@ -185,7 +185,13 @@ i[34567]86-*-dicos*) i[34567]86-*-freebsd* | i[34567]86-*-kfreebsd*-gnu) # Target: FreeBSD/i386 gdb_target_obs="i386-tdep.o i387-tdep.o i386bsd-tdep.o i386fbsd-tdep.o \ - bsd-uthread.o fbsd-tdep.o solib-svr4.o" + bsd-uthread.o fbsd-tdep.o solib-svr4.o \ + fbsd-kld.o fbsd-kthr.o fbsd-kvm.o i386fbsd-kern.o" + if test "x$enable_64_bit_bfd" = "xyes"; then + # Target: FreeBSD amd64 + gdb_target_obs="amd64-tdep.o amd64fbsd-tdep.o amd64fbsd-kern.o \ + ${gdb_target_obs}" + fi ;; i[34567]86-*-netbsd* | i[34567]86-*-knetbsd*-gnu) # Target: NetBSD/i386 @@ -405,7 +411,8 @@ powerpc*-*-freebsd*) # Target: FreeBSD/powerpc gdb_target_obs="rs6000-tdep.o ppc-sysv-tdep.o ppc64-tdep.o \ ppcfbsd-tdep.o fbsd-tdep.o solib-svr4.o \ - ravenscar-thread.o ppc-ravenscar-thread.o" + ravenscar-thread.o ppc-ravenscar-thread.o \ + fbsd-kld.o fbsd-kthr.o fbsd-kvm.o ppcfbsd-kern.o" ;; powerpc-*-netbsd* | powerpc-*-knetbsd*-gnu) @@ -534,7 +541,8 @@ sparc*-*-freebsd* | sparc*-*-kfreebsd*-gnu) # Target: FreeBSD/sparc64 gdb_target_obs="sparc-tdep.o sparc64-tdep.o sparc64fbsd-tdep.o \ fbsd-tdep.o solib-svr4.o \ - ravenscar-thread.o sparc-ravenscar-thread.o" + ravenscar-thread.o sparc-ravenscar-thread.o \ + fbsd-kld.o fbsd-kthr.o fbsd-kvm.o sparc64fbsd-kern.o" ;; sparc-*-netbsd* | sparc-*-knetbsd*-gnu) # Target: NetBSD/sparc @@ -662,7 +670,9 @@ x86_64-*-freebsd* | x86_64-*-kfreebsd*-gnu) # Target: FreeBSD/amd64 gdb_target_obs="amd64-tdep.o amd64fbsd-tdep.o i386-tdep.o \ i387-tdep.o i386bsd-tdep.o i386fbsd-tdep.o \ - bsd-uthread.o fbsd-tdep.o solib-svr4.o" + bsd-uthread.o fbsd-tdep.o solib-svr4.o \ + fbsd-kld.o fbsd-kthr.o fbsd-kvm.o amd64fbsd-kern.o \ + i386fbsd-kern.o" ;; x86_64-*-mingw* | x86_64-*-cygwin*) # Target: MingW/amd64 Index: head/devel/gdb/files/kgdb/amd64fbsd-kern.c =================================================================== --- head/devel/gdb/files/kgdb/amd64fbsd-kern.c (revision 428875) +++ head/devel/gdb/files/kgdb/amd64fbsd-kern.c (revision 428876) @@ -1,304 +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 "gdbcore.h" #include "osabi.h" #include #include "solib.h" #include "stack.h" #include "symtab.h" #include "trad-frame.h" #include #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_unsigned(regcache, AMD64_CS_REGNUM, CODE_SEL); regcache_raw_supply_unsigned(regcache, 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 (*this_cache); + 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, "fork_trampoline") == 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); 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_ELF_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 428875) +++ head/devel/gdb/files/kgdb/fbsd-kld.c (revision 428876) @@ -1,588 +1,588 @@ /* * 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 #include #include "solib.h" #include #include "kgdb.h" struct lm_info { 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 = 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 = program_space_data (current_program_space, kld_pspace_data); + 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 (char *filename, char *path, size_t path_size) { struct kld_info *info; struct cleanup *cleanup; char *module_path; char *kernel_dir, *module_dir, *cp; int error; info = get_kld_info(); if (exec_bfd) { kernel_dir = dirname(bfd_get_filename(exec_bfd)); if (kernel_dir != NULL) { snprintf(path, path_size, "%s/%s", kernel_dir, 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) { struct kld_info *info; CORE_ADDR kld; char *kld_filename; 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 = basename(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; bfd *bfd; CORE_ADDR curr_addr; int add_flags, i; /* Open the kld. */ bfd = bfd_openr(path, gnutarget); if (bfd == NULL) error("\"%s\": can't open: %s", path, bfd_errmsg(bfd_get_error())); cleanup = make_cleanup_bfd_unref(bfd); if (!bfd_check_format(bfd, bfd_object)) error("\%s\": not an object file", path); /* Make sure we have a .text section. */ if (bfd_get_section_by_name (bfd, ".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, §ions, §ions_end)) error("\"%s\": can't find file sections", path); 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(path, add_flags, sap, OBJF_USERLOADED); do_cleanups(cleanup); } static void kgdb_add_kld_cmd (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; if (sec == so->sections) curr_addr = so->lm_info->base_address; adjust_section_address(sec, &curr_addr); } static void kld_free_so (struct so_list *so) { xfree(so->lm_info); } static void kld_clear_so (struct so_list *so) { if (so->lm_info != NULL) so->lm_info->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, 1, ¤t_target, auto_solib_add); } static void kld_special_symbol_handling (void) { } static struct so_list * kld_current_sos (void) { - struct so_list *head, **prev, *new; + 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; - new = xmalloc(sizeof(*new)); - memset(new, 0, sizeof(*new)); + newobj = XCNEW (struct so_list); - new->lm_info = xmalloc(sizeof(*new->lm_info)); - new->lm_info->base_address = 0; + newobj->lm_info = XNEW (struct lm_info); + newobj->lm_info->base_address = 0; /* Read the base filename and store it in so_original_name. */ target_read_string(read_pointer(kld + info->off_filename), - &path, sizeof(new->so_original_name), &error); + &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(new); + free_so(newobj); continue; } - strlcpy(new->so_original_name, path, - sizeof(new->so_original_name)); + 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(new->so_original_name, new->so_name, - sizeof(new->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(new->so_name), &error); + &path, sizeof(newobj->so_name), &error); if (error != 0) { warning( "kld_current_sos: Can't read pathname for \"%s\": %s\n", - new->so_original_name, + newobj->so_original_name, safe_strerror(error)); - strlcpy(new->so_name, new->so_original_name, - sizeof(new->so_name)); + strlcpy(newobj->so_name, newobj->so_original_name, + sizeof(newobj->so_name)); } else { - strlcpy(new->so_name, path, - sizeof(new->so_name)); + strlcpy(newobj->so_name, path, + sizeof(newobj->so_name)); xfree(path); } } else - strlcpy(new->so_name, new->so_original_name, - sizeof(new->so_name)); + strlcpy(newobj->so_name, newobj->so_original_name, + sizeof(newobj->so_name)); /* Read this kld's base address. */ - new->lm_info->base_address = read_pointer(kld + + newobj->lm_info->base_address = read_pointer(kld + info->off_address); - if (new->lm_info->base_address == 0) { + if (newobj->lm_info->base_address == 0) { warning( "kld_current_sos: Invalid address for kld \"%s\"", - new->so_original_name); - free_so(new); + newobj->so_original_name); + free_so(newobj); continue; } /* Append to the list. */ - *prev = new; - prev = &new->next; + *prev = newobj; + prev = &newobj->next; } return (head); } static int kld_open_symbol_file_object (void *from_ttyp) { return (0); } static int kld_in_dynsym_resolve_code (CORE_ADDR pc) { return (0); } static int kld_find_and_open_solib (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.special_symbol_handling = kld_special_symbol_handling; 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-kthr.c =================================================================== --- head/devel/gdb/files/kgdb/fbsd-kthr.c (revision 428875) +++ head/devel/gdb/files/kgdb/fbsd-kthr.c (revision 428876) @@ -1,351 +1,351 @@ /* * 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 #include #include "gdbcore.h" #include "objfiles.h" #include "value.h" #include "kgdb.h" static CORE_ADDR dumppcb; static LONGEST dumptid; static CORE_ADDR stopped_cpus; static LONGEST mp_maxid; static struct kthr *first; struct kthr *curkthr; static int proc_off_p_pid, proc_off_p_comm, proc_off_p_list, proc_off_p_threads; static int thread_off_td_tid, thread_off_td_oncpu, thread_off_td_pcb; static int thread_off_td_name, thread_off_td_plist; static int thread_oncpu_size; CORE_ADDR kgdb_lookup(const char *sym) { struct bound_minimal_symbol msym; msym = lookup_minimal_symbol(sym, NULL, NULL); if (msym.minsym == NULL) return (0); return (BMSYMBOL_VALUE_ADDRESS(msym)); } /* * Perform the equivalent of CPU_ISSET() to see if 'cpu' is set in the * kernel's stopped_cpus set. The set contains an array of longs. * This function determines the specific long to read and tests the * necessary bit in the long. */ static bool cpu_stopped(int cpu) { struct gdbarch *gdbarch = target_gdbarch (); CORE_ADDR addr; ULONGEST mask; int bit, long_bytes, word; if (cpu < 0 || cpu > mp_maxid || stopped_cpus == 0) return (false); bit = cpu % gdbarch_long_bit (gdbarch); word = cpu / gdbarch_long_bit (gdbarch); long_bytes = gdbarch_long_bit (gdbarch) / 8; addr = stopped_cpus + word * long_bytes; mask = read_memory_unsigned_integer (addr, long_bytes, gdbarch_byte_order (gdbarch)); return (mask & ((ULONGEST)1 << bit)) != 0; } struct kthr * kgdb_thr_first(void) { return (first); } static void kgdb_thr_add_procs(CORE_ADDR paddr, CORE_ADDR (*cpu_pcb_addr) (u_int)) { struct gdbarch *gdbarch = target_gdbarch (); struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr; enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); struct kthr *kt; CORE_ADDR pcb, pnext, tdaddr, tdnext; ULONGEST oncpu; LONGEST pid, tid; while (paddr != 0) { TRY { tdaddr = read_memory_typed_address (paddr + proc_off_p_threads, ptr_type); pid = read_memory_integer (paddr + proc_off_p_pid, 4, byte_order); pnext = read_memory_typed_address (paddr + proc_off_p_list, ptr_type); } CATCH(e, RETURN_MASK_ERROR) { break; } END_CATCH while (tdaddr != 0) { TRY { tid = read_memory_integer (tdaddr + thread_off_td_tid, 4, byte_order); oncpu = read_memory_unsigned_integer (tdaddr + thread_off_td_oncpu, thread_oncpu_size, byte_order); pcb = read_memory_typed_address (tdaddr + thread_off_td_pcb, ptr_type); tdnext = read_memory_typed_address (tdaddr + thread_off_td_plist, ptr_type); } CATCH(e, RETURN_MASK_ERROR) { break; } END_CATCH - kt = malloc(sizeof(*kt)); + kt = XNEW (struct kthr); kt->next = first; kt->kaddr = tdaddr; if (tid == dumptid) kt->pcb = dumppcb; else if (cpu_stopped(oncpu)) kt->pcb = cpu_pcb_addr(oncpu); else kt->pcb = pcb; kt->tid = tid; kt->pid = pid; kt->paddr = paddr; kt->cpu = oncpu; first = kt; tdaddr = tdnext; } paddr = pnext; } } struct kthr * kgdb_thr_init(CORE_ADDR (*cpu_pcb_addr) (u_int)) { struct gdbarch *gdbarch = target_gdbarch (); struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr; enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); struct kthr *kt; CORE_ADDR addr, paddr; while (first != NULL) { kt = first; first = kt->next; free(kt); } addr = kgdb_lookup("allproc"); if (addr == 0) return (NULL); TRY { paddr = read_memory_typed_address (addr, ptr_type); } CATCH(e, RETURN_MASK_ERROR) { return (NULL); } END_CATCH dumppcb = kgdb_lookup("dumppcb"); if (dumppcb == 0) return (NULL); #if 1 TRY { dumptid = parse_and_eval_long("dumptid"); } CATCH(e, RETURN_MASK_ERROR) { dumptid = -1; } END_CATCH #else addr = kgdb_lookup("dumptid"); if (addr != 0) { TRY { dumptid = read_memory_integer (addr, 4, byte_order); } CATCH(e, RETURN_MASK_ERROR) { dumptid = -1; } END_CATCH } else dumptid = -1; #endif TRY { mp_maxid = parse_and_eval_long("mp_maxid"); } CATCH(e, RETURN_MASK_ERROR) { mp_maxid = 0; } END_CATCH stopped_cpus = kgdb_lookup("stopped_cpus"); /* * Newer kernels export a set of global variables with the offsets * of certain members in struct proc and struct thread. For older * kernels, try to extract these offsets using debug symbols. If * that fails, use native values. */ TRY { proc_off_p_pid = parse_and_eval_long("proc_off_p_pid"); proc_off_p_comm = parse_and_eval_long("proc_off_p_comm"); proc_off_p_list = parse_and_eval_long("proc_off_p_list"); proc_off_p_threads = parse_and_eval_long("proc_off_p_threads"); thread_off_td_tid = parse_and_eval_long("thread_off_td_tid"); thread_off_td_name = parse_and_eval_long("thread_off_td_name"); thread_off_td_oncpu = parse_and_eval_long("thread_off_td_oncpu"); thread_off_td_pcb = parse_and_eval_long("thread_off_td_pcb"); thread_off_td_plist = parse_and_eval_long("thread_off_td_plist"); thread_oncpu_size = 4; } CATCH(e, RETURN_MASK_ERROR) { TRY { proc_off_p_pid = parse_and_eval_address( "&((struct proc *)0)->p_pid"); proc_off_p_comm = parse_and_eval_address( "&((struct proc *)0)->p_comm"); proc_off_p_list = parse_and_eval_address( "&((struct proc *)0)->p_list"); proc_off_p_threads = parse_and_eval_address( "&((struct proc *)0)->p_threads"); thread_off_td_tid = parse_and_eval_address( "&((struct thread *)0)->td_tid"); thread_off_td_name = parse_and_eval_address( "&((struct thread *)0)->td_name"); thread_off_td_oncpu = parse_and_eval_address( "&((struct thread *)0)->td_oncpu"); thread_off_td_pcb = parse_and_eval_address( "&((struct thread *)0)->td_pcb"); thread_off_td_plist = parse_and_eval_address( "&((struct thread *)0)->td_plist"); thread_oncpu_size = parse_and_eval_long( "sizeof(((struct thread *)0)->td_oncpu)"); } CATCH(e, RETURN_MASK_ERROR) { proc_off_p_pid = offsetof(struct proc, p_pid); proc_off_p_comm = offsetof(struct proc, p_comm); proc_off_p_list = offsetof(struct proc, p_list); proc_off_p_threads = offsetof(struct proc, p_threads); thread_off_td_tid = offsetof(struct thread, td_tid); thread_off_td_name = offsetof(struct thread, td_name); thread_off_td_oncpu = offsetof(struct thread, td_oncpu); thread_off_td_pcb = offsetof(struct thread, td_pcb); thread_off_td_plist = offsetof(struct thread, td_plist); thread_oncpu_size = sizeof(((struct thread *)0)->td_oncpu); } END_CATCH } END_CATCH kgdb_thr_add_procs(paddr, cpu_pcb_addr); addr = kgdb_lookup("zombproc"); if (addr != 0) { TRY { paddr = read_memory_typed_address (addr, ptr_type); kgdb_thr_add_procs(paddr, cpu_pcb_addr); } CATCH(e, RETURN_MASK_ERROR) { } END_CATCH } curkthr = kgdb_thr_lookup_tid(dumptid); if (curkthr == NULL) curkthr = first; return (first); } struct kthr * kgdb_thr_lookup_tid(int tid) { struct kthr *kt; kt = first; while (kt != NULL && kt->tid != tid) kt = kt->next; return (kt); } struct kthr * kgdb_thr_lookup_taddr(uintptr_t taddr) { struct kthr *kt; kt = first; while (kt != NULL && kt->kaddr != taddr) kt = kt->next; return (kt); } struct kthr * kgdb_thr_lookup_pid(int pid) { struct kthr *kt; kt = first; while (kt != NULL && kt->pid != pid) kt = kt->next; return (kt); } struct kthr * kgdb_thr_lookup_paddr(uintptr_t paddr) { struct kthr *kt; kt = first; while (kt != NULL && kt->paddr != paddr) kt = kt->next; return (kt); } struct kthr * kgdb_thr_next(struct kthr *kt) { return (kt->next); } char * kgdb_thr_extra_thread_info(int tid) { char comm[MAXCOMLEN + 1]; char td_name[MAXCOMLEN + 1]; struct kthr *kt; static char buf[64]; kt = kgdb_thr_lookup_tid(tid); if (kt == NULL) return (NULL); snprintf(buf, sizeof(buf), "PID=%d", kt->pid); TRY { read_memory_string (kt->paddr + proc_off_p_comm, comm, sizeof(comm)); strlcat(buf, ": ", sizeof(buf)); strlcat(buf, comm, sizeof(buf)); read_memory_string (kt->kaddr + thread_off_td_name, td_name, sizeof(td_name)); if (strcmp(comm, td_name) != 0) { strlcat(buf, "/", sizeof(buf)); strlcat(buf, td_name, sizeof(buf)); } } CATCH(e, RETURN_MASK_ERROR) { } END_CATCH return (buf); } Index: head/devel/gdb/files/kgdb/fbsd-kvm.c =================================================================== --- head/devel/gdb/files/kgdb/fbsd-kvm.c (revision 428875) +++ head/devel/gdb/files/kgdb/fbsd-kvm.c (revision 428876) @@ -1,588 +1,596 @@ /* * 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 "elf-bfd.h" #include #include "filenames.h" #include #include #include #include #include "gdb_obstack.h" #include #include #include "objfiles.h" #include #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 = gdbarch_data (gdbarch, fbsd_vmcore_data); + 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 = gdbarch_data (gdbarch, fbsd_vmcore_data); + 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; /* FreeBSD ELF kernels have a FreeBSD/ELF OS ABI. */ if (elf_elfheader(abfd)->e_ident[EI_OSABI] != ELFOSABI_FREEBSD) 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_ELF_KERNEL); return (GDB_OSABI_UNKNOWN); } -#define INKERNEL(x) ((x) >= kernstart) - #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 = gdbarch_data (target_gdbarch(), - fbsd_vmcore_data); + 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 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 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 = gdbarch_data (target_gdbarch(), - fbsd_vmcore_data); + 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_ignore_breakpoints(struct target_ops *ops, struct gdbarch *gdbarch, +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) { char buf[16]; int thread_id; 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); } static void kgdb_set_proc_cmd (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 (!INKERNEL (addr)) { + 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); } static void kgdb_set_tid_cmd (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 && INKERNEL (addr)) { + 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); } 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_ignore_breakpoints; - kgdb_trgt_ops.to_remove_breakpoint = kgdb_trgt_ignore_breakpoints; + 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 428875) +++ head/devel/gdb/files/kgdb/i386fbsd-kern.c (revision 428876) @@ -1,576 +1,577 @@ /* * 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 #ifdef __i386__ #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 = 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 = program_space_data (current_program_space, i386fbsd_pspace_data); + 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_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); } #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, (void *)&sd, sizeof(sd)) != 0) + 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 (*this_cache); + 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 (*this_cache); + 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_ELF_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 428875) +++ head/devel/gdb/files/kgdb/kgdb-main.c (revision 428876) @@ -1,407 +1,407 @@ /* * 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 #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 *arg) { args->argc++; - args->argv = reallocf(args->argv, (args->argc + 1) * sizeof(char *)); + 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] = 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] = "-q"; else if (strcmp(s, "fullname") == 0) argv[a] = "-f"; } } kgdb_quiet = 0; memset (&args, 0, sizeof args); args.interpreter_p = INTERP_CONSOLE; - args.argv = malloc(sizeof(char *)); + 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) "); /* 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/ppcfbsd-kern.c =================================================================== --- head/devel/gdb/files/kgdb/ppcfbsd-kern.c (revision 428875) +++ head/devel/gdb/files/kgdb/ppcfbsd-kern.c (revision 428876) @@ -1,254 +1,254 @@ /*- * 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 "gdbcore.h" #include "osabi.h" #include "regcache.h" #include "solib.h" #include "symtab.h" #include "trad-frame.h" #include #include "ppc64-tdep.h" #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()); if (target_read_memory(pcb_addr, &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, (char *)&pcb.pcb_context[i]); } /* r1 is saved in the sp field */ regcache_raw_supply(regcache, 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, (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); } #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 *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_ELF_KERNEL, ppcfbsd_kernel_init_abi); gdbarch_register_osabi (bfd_arch_powerpc, bfd_mach_ppc64, GDB_OSABI_FREEBSD_ELF_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_ELF_KERNEL, ppcfbsd_kernel_init_abi); } Index: head/devel/gdb/files/kgdb/sparc64fbsd-kern.c =================================================================== --- head/devel/gdb/files/kgdb/sparc64fbsd-kern.c (revision 428875) +++ head/devel/gdb/files/kgdb/sparc64fbsd-kern.c (revision 428876) @@ -1,319 +1,319 @@ /* * 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 "gdbcore.h" #include "osabi.h" #include "regcache.h" #include #include #include "solib.h" #include "trad-frame.h" #include #include #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 *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_ELF_KERNEL, sparc64fbsd_kernel_init_abi); } Index: head/devel/gdb/files/patch-fixes =================================================================== --- head/devel/gdb/files/patch-fixes (nonexistent) +++ head/devel/gdb/files/patch-fixes (revision 428876) @@ -0,0 +1,11 @@ +--- gdb/compile/compile-loc2c.c.orig 2016-07-05 12:30:44.811467295 +0200 ++++ gdb/compile/compile-loc2c.c 2016-07-05 12:38:46.432434206 +0200 +@@ -670,7 +670,7 @@ + enum dwarf_location_atom op = (enum dwarf_location_atom) *op_ptr; + uint64_t uoffset, reg; + int64_t offset; +- ++ uoffset = 0; + print_spaces (indent - 2, stream); + if (info[op_ptr - base].label) + { Property changes on: head/devel/gdb/files/patch-fixes ___________________________________________________________________ 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/patch-gdb-configure =================================================================== --- head/devel/gdb/files/patch-gdb-configure (revision 428875) +++ head/devel/gdb/files/patch-gdb-configure (revision 428876) @@ -1,12 +1,24 @@ ---- gdb/configure.orig 2016-03-07 10:33:02.757803766 +0100 -+++ gdb/configure 2016-03-07 10:32:39.480804873 +0100 -@@ -14297,8 +14297,7 @@ +--- gdb/configure.orig 2016-10-07 19:09:21.000000000 +0200 ++++ gdb/configure 2016-10-18 11:11:30.452542000 +0200 +@@ -14256,9 +14256,8 @@ + + # 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-unused -Wno-switch -Wno-char-subscripts \ ++-Wempty-body" + + # Now add in C and C++ specific options, depending on mode. + if test "$enable_build_with_cxx" = "yes"; then +@@ -14266,8 +14265,7 @@ -Wno-narrowing" else build_warnings="$build_warnings -Wpointer-sign -Wmissing-prototypes \ --Wdeclaration-after-statement -Wmissing-parameter-type \ --Wold-style-declaration -Wold-style-definition" +-Wdeclaration-after-statement -Wold-style-definition" fi # Enable -Wno-format by default when using gcc on mingw since many Index: head/devel/gdb/files/patch-gdb-gnulib-import-stddef.in.h =================================================================== --- head/devel/gdb/files/patch-gdb-gnulib-import-stddef.in.h (nonexistent) +++ head/devel/gdb/files/patch-gdb-gnulib-import-stddef.in.h (revision 428876) @@ -0,0 +1,11 @@ +--- gdb/gnulib/import/stddef.in.h.orig 2016-10-07 23:33:10.529558000 -0700 ++++ gdb/gnulib/import/stddef.in.h 2016-10-07 23:33:23.824676000 -0700 +@@ -82,7 +82,7 @@ + #endif + + /* Some platforms lack max_align_t. */ +-#if !@HAVE_MAX_ALIGN_T@ ++#if 0 + /* On the x86, the maximum storage alignment of double, long, etc. is 4, + but GCC's C11 ABI for x86 says that max_align_t has an alignment of 8, + and the C11 standard allows this. Work around this problem by Property changes on: head/devel/gdb/files/patch-gdb-gnulib-import-stddef.in.h ___________________________________________________________________ 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/patch-gdb-x86bsd-nat.c =================================================================== --- head/devel/gdb/files/patch-gdb-x86bsd-nat.c (nonexistent) +++ head/devel/gdb/files/patch-gdb-x86bsd-nat.c (revision 428876) @@ -0,0 +1,14 @@ +--- gdb/x86bsd-nat.c.orig 2016-10-18 13:27:55.820837000 +0200 ++++ gdb/x86bsd-nat.c 2016-10-18 13:29:02.518927000 +0200 +@@ -82,7 +82,11 @@ + /* For some mysterious reason, some of the reserved bits in the + debug control register get set. Mask these off, otherwise the + ptrace call below will fail. */ ++#ifdef __i386__ ++ DBREG_DRX ((&dbregs), 7) &= ~(0x0000fc00); ++#else + DBREG_DRX ((&dbregs), 7) &= ~(0xffffffff0000fc00); ++#endif + + DBREG_DRX ((&dbregs), regnum) = value; + Property changes on: head/devel/gdb/files/patch-gdb-x86bsd-nat.c ___________________________________________________________________ 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/patch-nowarning =================================================================== --- head/devel/gdb/files/patch-nowarning (nonexistent) +++ head/devel/gdb/files/patch-nowarning (revision 428876) @@ -0,0 +1,65 @@ +--- gdb/arm-tdep.c.orig 2016-07-08 15:42:17.131392993 +0200 ++++ gdb/arm-tdep.c 2016-07-08 15:44:10.506386463 +0200 +@@ -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 ___________________________________________________________________ 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/pkg-plist =================================================================== --- head/devel/gdb/pkg-plist (revision 428875) +++ head/devel/gdb/pkg-plist (revision 428876) @@ -1,57 +1,58 @@ %%GDB_LINK%%bin/gdb %%GDB_LINK%%%%KGDB%%bin/kgdb bin/gdb%%VER%% %%TUI%%bin/gdbtui%%VER%% %%KGDB%%bin/kgdb%%VER%% man/man1/gdb%%VER%%.1.gz %%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/__init__.py %%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/FrameDecorator.py %%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/FrameIterator.py %%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/frames.py %%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/printing.py %%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/prompt.py %%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/types.py %%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/unwinder.py %%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/xmethod.py %%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/command/__init__.py %%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/command/explore.py %%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/command/frame_filters.py %%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/command/pretty_printers.py %%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/command/prompt.py %%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/command/type_printers.py %%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/command/unwinders.py %%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/command/xmethods.py %%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/function/__init__.py +%%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/function/as_string.py %%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/function/caller_is.py %%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/function/strfns.py %%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/printer/__init__.py %%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/printer/bound_registers.py %%GUILE%%%%DATADIR%%%%VER%%/guile/gdb.go %%GUILE%%%%DATADIR%%%%VER%%/guile/gdb.scm %%GUILE%%%%DATADIR%%%%VER%%/guile/gdb/boot.scm %%GUILE%%%%DATADIR%%%%VER%%/guile/gdb/experimental.go %%GUILE%%%%DATADIR%%%%VER%%/guile/gdb/experimental.scm %%GUILE%%%%DATADIR%%%%VER%%/guile/gdb/init.scm %%GUILE%%%%DATADIR%%%%VER%%/guile/gdb/iterator.go %%GUILE%%%%DATADIR%%%%VER%%/guile/gdb/iterator.scm %%GUILE%%%%DATADIR%%%%VER%%/guile/gdb/printing.go %%GUILE%%%%DATADIR%%%%VER%%/guile/gdb/printing.scm %%GUILE%%%%DATADIR%%%%VER%%/guile/gdb/support.go %%GUILE%%%%DATADIR%%%%VER%%/guile/gdb/support.scm %%GUILE%%%%DATADIR%%%%VER%%/guile/gdb/types.go %%GUILE%%%%DATADIR%%%%VER%%/guile/gdb/types.scm -%%EXPAT%%%%DATADIR%%%%VER%%/syscalls/aarch64-linux.xml -%%EXPAT%%%%DATADIR%%%%VER%%/syscalls/amd64-linux.xml -%%EXPAT%%%%DATADIR%%%%VER%%/syscalls/arm-linux.xml -%%EXPAT%%%%DATADIR%%%%VER%%/syscalls/freebsd.xml -%%EXPAT%%%%DATADIR%%%%VER%%/syscalls/gdb-syscalls.dtd -%%EXPAT%%%%DATADIR%%%%VER%%/syscalls/i386-linux.xml -%%EXPAT%%%%DATADIR%%%%VER%%/syscalls/mips-n32-linux.xml -%%EXPAT%%%%DATADIR%%%%VER%%/syscalls/mips-n64-linux.xml -%%EXPAT%%%%DATADIR%%%%VER%%/syscalls/mips-o32-linux.xml -%%EXPAT%%%%DATADIR%%%%VER%%/syscalls/ppc-linux.xml -%%EXPAT%%%%DATADIR%%%%VER%%/syscalls/ppc64-linux.xml -%%EXPAT%%%%DATADIR%%%%VER%%/syscalls/s390-linux.xml -%%EXPAT%%%%DATADIR%%%%VER%%/syscalls/s390x-linux.xml -%%EXPAT%%%%DATADIR%%%%VER%%/syscalls/sparc-linux.xml -%%EXPAT%%%%DATADIR%%%%VER%%/syscalls/sparc64-linux.xml +%%DATADIR%%%%VER%%/syscalls/aarch64-linux.xml +%%DATADIR%%%%VER%%/syscalls/amd64-linux.xml +%%DATADIR%%%%VER%%/syscalls/arm-linux.xml +%%DATADIR%%%%VER%%/syscalls/freebsd.xml +%%DATADIR%%%%VER%%/syscalls/gdb-syscalls.dtd +%%DATADIR%%%%VER%%/syscalls/i386-linux.xml +%%DATADIR%%%%VER%%/syscalls/mips-n32-linux.xml +%%DATADIR%%%%VER%%/syscalls/mips-n64-linux.xml +%%DATADIR%%%%VER%%/syscalls/mips-o32-linux.xml +%%DATADIR%%%%VER%%/syscalls/ppc-linux.xml +%%DATADIR%%%%VER%%/syscalls/ppc64-linux.xml +%%DATADIR%%%%VER%%/syscalls/s390-linux.xml +%%DATADIR%%%%VER%%/syscalls/s390x-linux.xml +%%DATADIR%%%%VER%%/syscalls/sparc-linux.xml +%%DATADIR%%%%VER%%/syscalls/sparc64-linux.xml