Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F134676547
D2927.id6511.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
16 KB
Referenced Files
None
Subscribers
None
D2927.id6511.diff
View Options
Index: devel/gdb/Makefile
===================================================================
--- devel/gdb/Makefile
+++ devel/gdb/Makefile
@@ -3,6 +3,7 @@
PORTNAME= gdb
PORTVERSION= 7.9.1
+PORTREVISION= 1
CATEGORIES= devel
MASTER_SITES= GNU
@@ -17,7 +18,7 @@
GNU_CONFIGURE= yes
CONFIGURE_ENV= CONFIGURED_M4=m4 CONFIGURED_BISON=byacc
CONFIGURE_ARGS= --program-suffix=${PORTVERSION:S/.//g} \
- --enable-targets=all \
+ --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} \
@@ -31,7 +32,11 @@
${FILESDIR}/commit-773eacf \
${FILESDIR}/commit-2526815 \
${FILESDIR}/commit-3ce5b6e \
- ${FILESDIR}/commit-97de354
+ ${FILESDIR}/commit-97de354 \
+ ${FILESDIR}/commit-8f60fe0 \
+ ${FILESDIR}/commit-e58e05d \
+ ${FILESDIR}/commit-d2b41ca \
+ ${FILESDIR}/commit-cea6e4f
VER= ${PORTVERSION:S/.//g}
PLIST_SUB= VER=${VER}
Index: devel/gdb/files/commit-8f60fe0
===================================================================
--- /dev/null
+++ devel/gdb/files/commit-8f60fe0
@@ -0,0 +1,127 @@
+diff --git gdb/amd64fbsd-nat.c gdb/amd64fbsd-nat.c
+index a721f48..4745b44 100644
+--- gdb/amd64fbsd-nat.c
++++ gdb/amd64fbsd-nat.c
+@@ -227,9 +227,7 @@ _initialize_amd64fbsd_nat (void)
+ t->to_mourn_inferior = amd64fbsd_mourn_inferior;
+ t->to_read_description = amd64fbsd_read_description;
+
+- t->to_pid_to_exec_file = fbsd_pid_to_exec_file;
+- t->to_find_memory_regions = fbsd_find_memory_regions;
+- add_target (t);
++ fbsd_nat_add_target (t);
+
+ /* Support debugging kernel virtual memory images. */
+ bsd_kvm_add_target (amd64fbsd_supply_pcb);
+diff --git gdb/fbsd-nat.c gdb/fbsd-nat.c
+index 1ce197d..68b8e65 100644
+--- gdb/fbsd-nat.c
++++ gdb/fbsd-nat.c
+@@ -37,7 +37,7 @@
+ /* Return the name of a file that can be opened to get the symbols for
+ the child process identified by PID. */
+
+-char *
++static char *
+ fbsd_pid_to_exec_file (struct target_ops *self, int pid)
+ {
+ ssize_t len = PATH_MAX;
+@@ -71,7 +71,7 @@ fbsd_pid_to_exec_file (struct target_ops *self, int pid)
+ calling FUNC for each memory region. OBFD is passed as the last
+ argument to FUNC. */
+
+-int
++static int
+ fbsd_find_memory_regions (struct target_ops *self,
+ find_memory_region_ftype func, void *obfd)
+ {
+@@ -149,7 +149,7 @@ fbsd_read_mapping (FILE *mapfile, unsigned long *start, unsigned long *end,
+ calling FUNC for each memory region. OBFD is passed as the last
+ argument to FUNC. */
+
+-int
++static int
+ fbsd_find_memory_regions (struct target_ops *self,
+ find_memory_region_ftype func, void *obfd)
+ {
+@@ -200,3 +200,11 @@ fbsd_find_memory_regions (struct target_ops *self,
+ return 0;
+ }
+ #endif
++
++void
++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;
++ add_target (t);
++}
+diff --git gdb/fbsd-nat.h gdb/fbsd-nat.h
+index e6e88ff..03f6bb1 100644
+--- gdb/fbsd-nat.h
++++ gdb/fbsd-nat.h
+@@ -20,16 +20,8 @@
+ #ifndef FBSD_NAT_H
+ #define FBSD_NAT_H
+
+-/* Return the name of a file that can be opened to get the symbols for
+- the child process identified by PID. */
+-
+-extern char *fbsd_pid_to_exec_file (struct target_ops *self, int pid);
+-
+-/* Iterate over all the memory regions in the current inferior,
+- calling FUNC for each memory region. OBFD is passed as the last
+- argument to FUNC. */
+-
+-extern int fbsd_find_memory_regions (struct target_ops *self,
+- find_memory_region_ftype func, void *obfd);
++/* Register the customized FreeBSD target. This should be used
++ instead of calling add_target directly. */
++extern void fbsd_nat_add_target (struct target_ops *);
+
+ #endif /* fbsd-nat.h */
+diff --git gdb/i386fbsd-nat.c gdb/i386fbsd-nat.c
+index 6c43f2c..f5d2ee3 100644
+--- gdb/i386fbsd-nat.c
++++ gdb/i386fbsd-nat.c
+@@ -176,9 +176,7 @@ _initialize_i386fbsd_nat (void)
+ #endif
+
+ t->to_resume = i386fbsd_resume;
+- t->to_pid_to_exec_file = fbsd_pid_to_exec_file;
+- t->to_find_memory_regions = fbsd_find_memory_regions;
+- add_target (t);
++ fbsd_nat_add_target (t);
+
+ /* Support debugging kernel virtual memory images. */
+ bsd_kvm_add_target (i386fbsd_supply_pcb);
+diff --git gdb/ppcfbsd-nat.c gdb/ppcfbsd-nat.c
+index 778b4bb..778e19a 100644
+--- gdb/ppcfbsd-nat.c
++++ gdb/ppcfbsd-nat.c
+@@ -212,9 +212,7 @@ _initialize_ppcfbsd_nat (void)
+ t = inf_ptrace_target ();
+ t->to_fetch_registers = ppcfbsd_fetch_inferior_registers;
+ t->to_store_registers = ppcfbsd_store_inferior_registers;
+- t->to_pid_to_exec_file = fbsd_pid_to_exec_file;
+- t->to_find_memory_regions = fbsd_find_memory_regions;
+- add_target (t);
++ fbsd_nat_add_target (t);
+
+ /* Support debugging kernel virtual memory images. */
+ bsd_kvm_add_target (ppcfbsd_supply_pcb);
+diff --git gdb/sparc64fbsd-nat.c gdb/sparc64fbsd-nat.c
+index 1a2397f..f197f74 100644
+--- gdb/sparc64fbsd-nat.c
++++ gdb/sparc64fbsd-nat.c
+@@ -70,9 +70,7 @@ _initialize_sparc64fbsd_nat (void)
+
+ /* Add some extra features to the generic SPARC target. */
+ t = sparc_target ();
+- t->to_pid_to_exec_file = fbsd_pid_to_exec_file;
+- t->to_find_memory_regions = fbsd_find_memory_regions;
+- add_target (t);
++ fbsd_nat_add_target (t);
+
+ sparc_gregmap = &sparc64fbsd_gregmap;
+
Index: devel/gdb/files/commit-cea6e4f
===================================================================
--- /dev/null
+++ devel/gdb/files/commit-cea6e4f
@@ -0,0 +1,17 @@
+diff --git gdb/fbsd-nat.c gdb/fbsd-nat.c
+index 066e288..9705d45 100644
+--- gdb/fbsd-nat.c
++++ gdb/fbsd-nat.c
+@@ -23,11 +23,11 @@
+ #include "regcache.h"
+ #include "regset.h"
+ #include "gdbthread.h"
++#include "gdb_wait.h"
+ #include <sys/types.h>
+ #include <sys/procfs.h>
+ #include <sys/ptrace.h>
+ #include <sys/sysctl.h>
+-#include <sys/wait.h>
+ #ifdef HAVE_KINFO_GETVMMAP
+ #include <sys/user.h>
+ #include <libutil.h>
Index: devel/gdb/files/commit-d2b41ca
===================================================================
--- /dev/null
+++ devel/gdb/files/commit-d2b41ca
@@ -0,0 +1,56 @@
+diff --git gdb/fbsd-nat.c gdb/fbsd-nat.c
+index 214f411..066e288 100644
+--- gdb/fbsd-nat.c
++++ gdb/fbsd-nat.c
+@@ -376,6 +376,16 @@ fbsd_wait (struct target_ops *ops,
+ continue;
+ }
+ #endif
++
++#ifdef PL_FLAG_EXEC
++ if (pl.pl_flags & PL_FLAG_EXEC)
++ {
++ ourstatus->kind = TARGET_WAITKIND_EXECD;
++ ourstatus->value.execd_pathname
++ = xstrdup (fbsd_pid_to_exec_file (NULL, pid));
++ return wptid;
++ }
++#endif
+ }
+ return wptid;
+ }
+@@ -458,6 +468,23 @@ fbsd_post_attach (struct target_ops *self, int pid)
+ fbsd_enable_follow_fork (pid);
+ }
+ #endif
++
++#ifdef PL_FLAG_EXEC
++/* If the FreeBSD kernel supports PL_FLAG_EXEC, then traced processes
++ will always stop after exec. */
++
++static int
++fbsd_insert_exec_catchpoint (struct target_ops *self, int pid)
++{
++ return 0;
++}
++
++static int
++fbsd_remove_exec_catchpoint (struct target_ops *self, int pid)
++{
++ return 0;
++}
++#endif
+ #endif
+
+ void
+@@ -477,6 +504,10 @@ fbsd_nat_add_target (struct target_ops *t)
+ t->to_post_startup_inferior = fbsd_post_startup_inferior;
+ t->to_post_attach = fbsd_post_attach;
+ #endif
++#ifdef PL_FLAG_EXEC
++ t->to_insert_exec_catchpoint = fbsd_insert_exec_catchpoint;
++ t->to_remove_exec_catchpoint = fbsd_remove_exec_catchpoint;
++#endif
+ #endif
+ add_target (t);
+ }
Index: devel/gdb/files/commit-e58e05d
===================================================================
--- /dev/null
+++ devel/gdb/files/commit-e58e05d
@@ -0,0 +1,295 @@
+diff --git gdb/fbsd-nat.c gdb/fbsd-nat.c
+index 68b8e65..214f411 100644
+--- gdb/fbsd-nat.c
++++ gdb/fbsd-nat.c
+@@ -25,7 +25,9 @@
+ #include "gdbthread.h"
+ #include <sys/types.h>
+ #include <sys/procfs.h>
++#include <sys/ptrace.h>
+ #include <sys/sysctl.h>
++#include <sys/wait.h>
+ #ifdef HAVE_KINFO_GETVMMAP
+ #include <sys/user.h>
+ #include <libutil.h>
+@@ -201,10 +203,280 @@ fbsd_find_memory_regions (struct target_ops *self,
+ }
+ #endif
+
++#ifdef PT_LWPINFO
++static ptid_t (*super_wait) (struct target_ops *,
++ ptid_t,
++ struct target_waitstatus *,
++ int);
++
++#ifdef TDP_RFPPWAIT
++/*
++ 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.
++
++ After a fork, both the child and parent process will stop and report
++ an event. However, there is no guarantee of order. If the parent
++ reports its stop first, then fbsd_wait explicitly waits for the new
++ child before returning. If the child reports its stop first, then
++ the event is saved on a list and ignored until the parent's stop is
++ reported. fbsd_wait could have been changed to fetch the parent PID
++ of the new child and used that to wait for the parent explicitly.
++ However, if two threads in the parent fork at the same time, then
++ the wait on the parent might return the "wrong" fork event.
++
++ The initial version of PT_FOLLOW_FORK did not set PL_FLAG_CHILD for
++ the new child process. This flag could be inferred by treating any
++ events for an unknown pid as a new child.
++
++ In addition, the initial version of PT_FOLLOW_FORK did not report a
++ stop event for the parent process of a vfork until after the child
++ process executed a new program or exited. The kernel was changed to
++ defer the wait for exit or exec of the child until after posting the
++ stop event shortly after the change to introduce PL_FLAG_CHILD.
++ This could be worked around by reporting a vfork event when the
++ child event posted and ignoring the subsequent event from the
++ parent.
++
++ This implementation requires both of these fixes for simplicity's
++ sake. FreeBSD versions newer than 9.1 contain both fixes.
++*/
++
++struct fbsd_fork_child_info
++{
++ struct fbsd_fork_child_info *next;
++ pid_t child; /* Pid of new child. */
++};
++
++static struct fbsd_fork_child_info *fbsd_pending_children;
++
++/* Record a new child process event that is reported before the
++ corresponding fork event in the parent. */
++
++static void
++fbsd_remember_child (pid_t pid)
++{
++ struct fbsd_fork_child_info *info;
++
++ info = xcalloc (1, sizeof *info);
++
++ info->child = pid;
++ info->next = fbsd_pending_children;
++ fbsd_pending_children = info;
++}
++
++/* Check for a previously-recorded new child process event for PID.
++ If one is found, remove it from the list. */
++
++static int
++fbsd_is_child_pending (pid_t pid)
++{
++ struct fbsd_fork_child_info *info, *prev;
++
++ prev = NULL;
++ for (info = fbsd_pending_children; info; prev = info, info = info->next)
++ {
++ if (info->child == pid)
++ {
++ if (prev == NULL)
++ fbsd_pending_children = info->next;
++ else
++ prev->next = info->next;
++ xfree (info);
++ return 1;
++ }
++ }
++ return 0;
++}
++
++/* Fetch the external variant of the kernel's internal process
++ structure for the process PID into KP. */
++
++static void
++fbsd_fetch_kinfo_proc (pid_t pid, struct kinfo_proc *kp)
++{
++ size_t len;
++ int mib[4];
++
++ len = sizeof *kp;
++ mib[0] = CTL_KERN;
++ mib[1] = KERN_PROC;
++ mib[2] = KERN_PROC_PID;
++ mib[3] = pid;
++ if (sysctl (mib, 4, kp, &len, NULL, 0) == -1)
++ perror_with_name (("sysctl"));
++}
++#endif
++
++/* 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. */
++
++static ptid_t
++fbsd_wait (struct target_ops *ops,
++ ptid_t ptid, struct target_waitstatus *ourstatus,
++ int target_options)
++{
++ ptid_t wptid;
++
++ while (1)
++ {
++ wptid = super_wait (ops, ptid, ourstatus, target_options);
++ if (ourstatus->kind == TARGET_WAITKIND_STOPPED)
++ {
++ struct ptrace_lwpinfo pl;
++ pid_t pid;
++ int status;
++
++ pid = ptid_get_pid (wptid);
++ if (ptrace (PT_LWPINFO, pid, (caddr_t)&pl, sizeof pl) == -1)
++ perror_with_name (("ptrace"));
++
++#ifdef TDP_RFPPWAIT
++ if (pl.pl_flags & PL_FLAG_FORKED)
++ {
++ struct kinfo_proc kp;
++ pid_t child;
++
++ child = pl.pl_child_pid;
++ ourstatus->kind = TARGET_WAITKIND_FORKED;
++ ourstatus->value.related_pid = pid_to_ptid (child);
++
++ /* Make sure the other end of the fork is stopped too. */
++ if (!fbsd_is_child_pending (child))
++ {
++ pid = waitpid (child, &status, 0);
++ if (pid == -1)
++ perror_with_name (("waitpid"));
++
++ gdb_assert (pid == child);
++
++ if (ptrace (PT_LWPINFO, child, (caddr_t)&pl, sizeof pl) == -1)
++ perror_with_name (("ptrace"));
++
++ gdb_assert (pl.pl_flags & PL_FLAG_CHILD);
++ }
++
++ /* 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;
++
++ return wptid;
++ }
++
++ if (pl.pl_flags & PL_FLAG_CHILD)
++ {
++ /* Remember that this child forked, but do not report it
++ until the parent reports its corresponding fork
++ event. */
++ fbsd_remember_child (ptid_get_pid (wptid));
++ continue;
++ }
++#endif
++ }
++ return wptid;
++ }
++}
++
++#ifdef TDP_RFPPWAIT
++/* Target hook for follow_fork. On entry and at return inferior_ptid is
++ the ptid of the followed inferior. */
++
++static int
++fbsd_follow_fork (struct target_ops *ops, int follow_child,
++ int detach_fork)
++{
++ if (!follow_child)
++ {
++ struct thread_info *tp = inferior_thread ();
++ pid_t child_pid = ptid_get_pid (tp->pending_follow.value.related_pid);
++
++ /* Breakpoints have already been detached from the child by
++ infrun.c. */
++
++ if (ptrace (PT_DETACH, child_pid, (PTRACE_TYPE_ARG3)1, 0) == -1)
++ perror_with_name (("ptrace"));
++ }
++
++ return 0;
++}
++
++static int
++fbsd_insert_fork_catchpoint (struct target_ops *self, int pid)
++{
++ return 0;
++}
++
++static int
++fbsd_remove_fork_catchpoint (struct target_ops *self, int pid)
++{
++ return 0;
++}
++
++static int
++fbsd_insert_vfork_catchpoint (struct target_ops *self, int pid)
++{
++ return 0;
++}
++
++static int
++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"));
++}
++
++/* Implement the "to_post_startup_inferior" target_ops method. */
++
++static void
++fbsd_post_startup_inferior (struct target_ops *self, ptid_t pid)
++{
++ fbsd_enable_follow_fork (ptid_get_pid (pid));
++}
++
++/* Implement the "to_post_attach" target_ops method. */
++
++static void
++fbsd_post_attach (struct target_ops *self, int pid)
++{
++ fbsd_enable_follow_fork (pid);
++}
++#endif
++#endif
++
+ void
+ 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 PT_LWPINFO
++ super_wait = t->to_wait;
++ t->to_wait = fbsd_wait;
++#ifdef TDP_RFPPWAIT
++ t->to_follow_fork = fbsd_follow_fork;
++ t->to_insert_fork_catchpoint = fbsd_insert_fork_catchpoint;
++ t->to_remove_fork_catchpoint = fbsd_remove_fork_catchpoint;
++ t->to_insert_vfork_catchpoint = fbsd_insert_vfork_catchpoint;
++ t->to_remove_vfork_catchpoint = fbsd_remove_vfork_catchpoint;
++ t->to_post_startup_inferior = fbsd_post_startup_inferior;
++ t->to_post_attach = fbsd_post_attach;
++#endif
++#endif
+ add_target (t);
+ }
Index: devel/gdb/files/patch-gdb-i386fbsd-nat.c
===================================================================
--- devel/gdb/files/patch-gdb-i386fbsd-nat.c
+++ devel/gdb/files/patch-gdb-i386fbsd-nat.c
@@ -1,5 +1,5 @@
diff --git gdb/i386fbsd-nat.c gdb/i386fbsd-nat.c
-index 6c43f2c..a205a26 100644
+index f5d2ee3..7a36302 100644
--- gdb/i386fbsd-nat.c
+++ gdb/i386fbsd-nat.c
@@ -175,7 +175,6 @@ _initialize_i386fbsd_nat (void)
@@ -7,6 +7,6 @@
#endif
- t->to_resume = i386fbsd_resume;
- t->to_pid_to_exec_file = fbsd_pid_to_exec_file;
- t->to_find_memory_regions = fbsd_find_memory_regions;
- add_target (t);
+ fbsd_nat_add_target (t);
+
+ /* Support debugging kernel virtual memory images. */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 4, 11:40 PM (3 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
24725948
Default Alt Text
D2927.id6511.diff (16 KB)
Attached To
Mode
D2927: Add fork tracing.
Attached
Detach File
Event Timeline
Log In to Comment