Date: Wed, 27 Jul 2016 16:27:06 +0000 (UTC) From: John Baldwin <jhb@FreeBSD.org> To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-branches@freebsd.org Subject: svn commit: r419185 - in branches/2016Q3/devel/gdb: . files Message-ID: <201607271627.u6RGR6Z7096180@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jhb (src,doc committer) Date: Wed Jul 27 16:27:06 2016 New Revision: 419185 URL: https://svnweb.freebsd.org/changeset/ports/419185 Log: MFH: r418566 r418964 Import several patches recently merged upstream. - Fix fork following to honor 'detach-on-fork' - Fix vfork following to post a fake vfork_done event to fix breakpoints in vfork parents (a real vfork_done event is pending but requires kernel changes currently in review). - Fix x86 debug registers to work with multiple threads (PR 157755) - Add support for 'info auxv' on both live processes and cores. - Add support for 'catch syscall'. Note that catching system calls by names requires parsing an XML file mapping system call names to numbers. The port now installs the XML syscall files to the data directory. In addition, the EXPAT option is now enabled by default as expat is used to parse the XML files. - Handle version 1a of NT_PRPSINFO notes which include the pr_pid field. - Replace patch-sigev with upstream version. Note that upstream GDB doesn't define SIGLIBRT on older OS versions, so do that in the port Makefile instead. - Use PT_GET_EVENT_MASK/PT_SET_EVENT_MASK (new in 12). - Fix a bug where fork and LWP events weren't enabled in new child processes when following child processes after a fork. - Handle "real" vfork done events via PTRACE_VFORK (new in 12). - Bump PORTREVISION. PR: 157755, 210874, 211254 Approved by: ports-secteam (feld) Added: branches/2016Q3/devel/gdb/files/commit-0064d22 - copied unchanged from r418964, head/devel/gdb/files/commit-0064d22 branches/2016Q3/devel/gdb/files/commit-21002a6 - copied unchanged from r418566, head/devel/gdb/files/commit-21002a6 branches/2016Q3/devel/gdb/files/commit-2c5c2a3 - copied unchanged from r418566, head/devel/gdb/files/commit-2c5c2a3 branches/2016Q3/devel/gdb/files/commit-2faa344 - copied unchanged from r418566, head/devel/gdb/files/commit-2faa344 branches/2016Q3/devel/gdb/files/commit-3350c5f - copied unchanged from r418566, head/devel/gdb/files/commit-3350c5f branches/2016Q3/devel/gdb/files/commit-5077bff - copied unchanged from r418566, head/devel/gdb/files/commit-5077bff branches/2016Q3/devel/gdb/files/commit-5fa14c6 - copied unchanged from r418964, head/devel/gdb/files/commit-5fa14c6 branches/2016Q3/devel/gdb/files/commit-7697fc9 - copied unchanged from r418566, head/devel/gdb/files/commit-7697fc9 branches/2016Q3/devel/gdb/files/commit-82372b2 - copied unchanged from r418566, head/devel/gdb/files/commit-82372b2 branches/2016Q3/devel/gdb/files/commit-8607ea6 - copied unchanged from r418566, head/devel/gdb/files/commit-8607ea6 branches/2016Q3/devel/gdb/files/commit-a3405d1 - copied unchanged from r418566, head/devel/gdb/files/commit-a3405d1 branches/2016Q3/devel/gdb/files/commit-aa1ed4a - copied unchanged from r418566, head/devel/gdb/files/commit-aa1ed4a branches/2016Q3/devel/gdb/files/commit-b00f86d - copied unchanged from r418566, head/devel/gdb/files/commit-b00f86d branches/2016Q3/devel/gdb/files/commit-bb2a62e - copied unchanged from r418566, head/devel/gdb/files/commit-bb2a62e branches/2016Q3/devel/gdb/files/commit-bc7b765 - copied unchanged from r418964, head/devel/gdb/files/commit-bc7b765 branches/2016Q3/devel/gdb/files/commit-da95a26 - copied unchanged from r418964, head/devel/gdb/files/commit-da95a26 branches/2016Q3/devel/gdb/files/commit-dbaed38 - copied unchanged from r418964, head/devel/gdb/files/commit-dbaed38 branches/2016Q3/devel/gdb/files/commit-e6cdd38 - copied unchanged from r418566, head/devel/gdb/files/commit-e6cdd38 branches/2016Q3/devel/gdb/files/commit-ee95032 - copied unchanged from r418566, head/devel/gdb/files/commit-ee95032 Deleted: branches/2016Q3/devel/gdb/files/patch-sigev Modified: branches/2016Q3/devel/gdb/Makefile branches/2016Q3/devel/gdb/pkg-plist Directory Properties: branches/2016Q3/ (props changed) Modified: branches/2016Q3/devel/gdb/Makefile ============================================================================== --- branches/2016Q3/devel/gdb/Makefile Wed Jul 27 16:11:08 2016 (r419184) +++ branches/2016Q3/devel/gdb/Makefile Wed Jul 27 16:27:06 2016 (r419185) @@ -3,7 +3,7 @@ PORTNAME= gdb PORTVERSION= 7.11.1 -PORTREVISION= 1 +PORTREVISION= 3 CATEGORIES= devel MASTER_SITES= GNU @@ -30,6 +30,25 @@ CFLAGS:= ${CFLAGS:C/ +$//} # blanks at E 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 VER= ${PORTVERSION:S/.//g} PLIST_SUB= VER=${VER} @@ -38,7 +57,7 @@ ONLY_FOR_ARCHS= i386 amd64 powerpc power OPTIONS_DEFINE= DEBUG EXPAT GDB_LINK GUILE KGDB PYTHON TUI -OPTIONS_DEFAULT= GDB_LINK KGDB PYTHON TUI PORT_READLINE +OPTIONS_DEFAULT= EXPAT GDB_LINK KGDB PYTHON TUI PORT_READLINE OPTIONS_SINGLE= READLINE OPTIONS_SINGLE_READLINE= BASE_READLINE BUNDLED_READLINE PORT_READLINE @@ -70,6 +89,11 @@ TUI_CONFIGURE_ENABLE= tui .include <bsd.port.options.mk> +.if ${OSVERSION} < 1000010 +# FreeBSD 9.x and earlier do not define SIGLIBRT in <sys/signal.h> +CFLAGS+= -DSIGLIBRT=33 +.endif + .if ! ${PORT_OPTIONS:MBUNDLED_READLINE} EXCLUDE+= readline .endif @@ -99,6 +123,10 @@ do-install-KGDB-on: 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} Copied: branches/2016Q3/devel/gdb/files/commit-0064d22 (from r418964, head/devel/gdb/files/commit-0064d22) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ branches/2016Q3/devel/gdb/files/commit-0064d22 Wed Jul 27 16:27:06 2016 (r419185, copy of r418964, head/devel/gdb/files/commit-0064d22) @@ -0,0 +1,83 @@ +commit 0064d22386b99c047bbff3bcc73b6bfce9c29b4c +Author: John Baldwin <jhb@FreeBSD.org> +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; + } Copied: branches/2016Q3/devel/gdb/files/commit-21002a6 (from r418566, head/devel/gdb/files/commit-21002a6) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ branches/2016Q3/devel/gdb/files/commit-21002a6 Wed Jul 27 16:27:06 2016 (r419185, copy of r418566, head/devel/gdb/files/commit-21002a6) @@ -0,0 +1,102 @@ +commit 21002a635bf3da33367592e3a3ab3cce24fe5299 +Author: John Baldwin <jhb@FreeBSD.org> +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), Copied: branches/2016Q3/devel/gdb/files/commit-2c5c2a3 (from r418566, head/devel/gdb/files/commit-2c5c2a3) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ branches/2016Q3/devel/gdb/files/commit-2c5c2a3 Wed Jul 27 16:27:06 2016 (r419185, copy of r418566, head/devel/gdb/files/commit-2c5c2a3) @@ -0,0 +1,214 @@ +commit 2c5c2a3321706c28cbf1b85a970a2e32912eb0c8 +Author: John Baldwin <jhb@FreeBSD.org> +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) <child>: Rename to ... + (struct fbsd_fork_info) <ptid>: ... 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; Copied: branches/2016Q3/devel/gdb/files/commit-2faa344 (from r418566, head/devel/gdb/files/commit-2faa344) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ branches/2016Q3/devel/gdb/files/commit-2faa344 Wed Jul 27 16:27:06 2016 (r419185, copy of r418566, head/devel/gdb/files/commit-2faa344) @@ -0,0 +1,397 @@ +commit 2faa34476d9e6120eaf389b7f91b7227183fa2ce +Author: John Baldwin <jhb@FreeBSD.org> +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 <<EOF + #include "observer.h" + #include "regcache.h" + #include "objfiles.h" ++#include "auxv.h" + + /* Static function declarations */ + Copied: branches/2016Q3/devel/gdb/files/commit-3350c5f (from r418566, head/devel/gdb/files/commit-3350c5f) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ branches/2016Q3/devel/gdb/files/commit-3350c5f Wed Jul 27 16:27:06 2016 (r419185, copy of r418566, head/devel/gdb/files/commit-3350c5f) @@ -0,0 +1,39 @@ +commit 3350c5f5de3d2e62dd9de2a76cf2d5d8728d2600 +Author: John Baldwin <jhb@FreeBSD.org> +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); Copied: branches/2016Q3/devel/gdb/files/commit-5077bff (from r418566, head/devel/gdb/files/commit-5077bff) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ branches/2016Q3/devel/gdb/files/commit-5077bff Wed Jul 27 16:27:06 2016 (r419185, copy of r418566, head/devel/gdb/files/commit-5077bff) @@ -0,0 +1,49 @@ +commit 5077bfff905136e9d9a8fdf0886f6217887622ad +Author: John Baldwin <jhb@FreeBSD.org> +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 <signal.h> to make sure `struct fxsave64' is defined on + NetBSD, since NetBSD's <machine/reg.h> 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 Copied: branches/2016Q3/devel/gdb/files/commit-5fa14c6 (from r418964, head/devel/gdb/files/commit-5fa14c6) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ branches/2016Q3/devel/gdb/files/commit-5fa14c6 Wed Jul 27 16:27:06 2016 (r419185, copy of r418964, head/devel/gdb/files/commit-5fa14c6) @@ -0,0 +1,30 @@ +commit 5fa14c6b9789bad6f91dd21889f7b1a0eb75c6d0 +Author: John Baldwin <jhb@FreeBSD.org> +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)); *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201607271627.u6RGR6Z7096180>