This is the mail archive of the gdb-testers@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Enable fork tracing for native FreeBSD targets.


*** TEST RESULTS FOR COMMIT e58e05d677d33da3646721bdd225ec6e90424000 ***

Author: John Baldwin <jhb@FreeBSD.org>
Branch: master
Commit: e58e05d677d33da3646721bdd225ec6e90424000

Enable fork tracing for native FreeBSD targets.
Enable PT_FOLLOW_FORK on all processes.  When this is enabled, both
the parent and child process stop when a fork or vfork occurs.

A target operation for wait uses PT_LWPINFO to fetch more detailed
information about the state of a stopped process.  A parent process
sets the PL_FLAG_FORKED flag in the pl_flags field of the structure
returned by PT_LWPINFO as well as the pid of the new child process.
The child process sets the PL_FLAG_CHILD flag in the pl_flags field.

When a fork is detected, the wait hook waits for both processes to
report their respective events.  It then reports the fork to GDB as
a single TARGET_WAITKIND_FORKED or TARGET_WAITKIND_VFORKED event.
The kernel does not guarantee the order the events are reported in.
If the parent process' event is reported first, then the wait hook
explicitly waits for the child process.  If the child process' event
is reported first, the event is recorded on an internal list of
pending child events and the wait hook waits for another event.
Later when the parent process' event is reported, the parent will
use the previously-recorded child process event instead of explicitly
waiting on the child process.

To distinguish vfork events from fork events, the external process
structure for the child process is extracted from the kernel.  The
P_PPWAIT flag is set in the ki_flags field of this structure if the
process was created via vfork, but it is not set for a regular fork.

gdb/ChangeLog:

	* fbsd-nat.c: [PT_LWPINFO] New variable super_wait.
	[TDP_RFPPWAIT] New variable fbsd_pending_children.
	[TDP_RFPPWAIT] (fbsd_remember_child): New function.
	[TDP_RFPPWAIT] (fbsd_is_child_pending): New function.
	[TDP_RFPPWAIT] (fbsd_fetch_kinfo_proc): New function.
	[PT_LWPINFO] (fbsd_wait): New function.
	[TDP_RFPPWAIT] (fbsd_follow_fork): New function.
	[TDP_RFPPWAIT] (fbsd_insert_fork_catchpoint): New function.
	[TDP_RFPPWAIT] (fbsd_remove_fork_catchpoint): New function.
	[TDP_RFPPWAIT] (fbsd_insert_vfork_catchpoint): New function.
	[TDP_RFPPWAIT] (fbsd_remove_vfork_catchpoint): New function.
	[TDP_RFPPWAIT] (fbsd_enable_follow_fork): New function.
	[TDP_RFPPWAIT] (fbsd_post_startup_inferior): New function.
	[TDP_RFPPWAIT] (fbsd_post_attach): New function.
	(fbsd_nat_add_target) [PT_LWPINFO] Set "to_wait" to
	"fbsd_wait".
	[TDP_RFPPWAIT] Set "to_follow_fork" to "fbsd_follow_fork".
	Set "to_insert_fork_catchpoint" to "fbsd_insert_fork_catchpoint".
	Set "to_remove_fork_catchpoint" to "fbsd_remove_fork_catchpoint".
	Set "to_insert_vfork_catchpoint" to "fbsd_insert_vfork_catchpoint".
	Set "to_remove_vfork_catchpoint" to "fbsd_remove_vfork_catchpoint".
	Set "to_post_startup_inferior" to "fbsd_post_startup_inferior".
	Set "to_post_attach" to "fbsd_post_attach".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]