binutils-gdb/gdb/common
Pedro Alves 8ae377e842 Always run the PTRACE_O_TRACESYSGOOD tests even if PTRACE_O_TRACEFORK is not supported.
If enabling PTRACE_O_TRACEFORK fails, we never test for
PTRACE_O_TRACESYSGOOD support.  Before PTRACE_O_TRACESYSGOOD is checked,
we have:

  /* First, set the PTRACE_O_TRACEFORK option.  If this fails, we
     know for sure that it is not supported.  */
  ret = ptrace (PTRACE_SETOPTIONS, child_pid, (PTRACE_TYPE_ARG3) 0,
		(PTRACE_TYPE_ARG4) PTRACE_O_TRACEFORK);

  if (ret != 0)
    {
      ret = ptrace (PTRACE_KILL, child_pid, (PTRACE_TYPE_ARG3) 0,
		    (PTRACE_TYPE_ARG4) 0);
      if (ret != 0)
	{
	  warning (_("linux_check_ptrace_features: failed to kill child"));
	  return;
	}

      ret = my_waitpid (child_pid, &status, 0);
      if (ret != child_pid)
	warning (_("linux_check_ptrace_features: failed "
		   "to wait for killed child"));
      else if (!WIFSIGNALED (status))
	warning (_("linux_check_ptrace_features: unexpected "
		   "wait status 0x%x from killed child"), status);

      return; <<<<<<<<<<<<<<<<<
    }

Note that early return.  If PTRACE_O_TRACEFORK isn't supported, we're
not checking PTRACE_O_TRACESYSGOOD.  This didn't use to be a problem
before the unification of this whole detection business in
linux-ptrace.c.  Before, the sysgood detection was completely
separate:

static void
linux_test_for_tracesysgood (int original_pid)
{
  int ret;
  sigset_t prev_mask;

  /* We don't want those ptrace calls to be interrupted.  */
  block_child_signals (&prev_mask);

  linux_supports_tracesysgood_flag = 0;

  ret = ptrace (PTRACE_SETOPTIONS, original_pid, 0, PTRACE_O_TRACESYSGOOD);
  if (ret != 0)
    goto out;

  linux_supports_tracesysgood_flag = 1;
out:
  restore_child_signals_mask (&prev_mask);
}

So we need to get back the decoupling somehow.  I think it's cleaner
to split the seperate feature detections to separate functions.  This
patch does that.  The new functions are named for their counterparts
that existed before this code was moved to linux-ptrace.c.

Note I've used forward declarations for the new functions to make the
patch clearer, as otherwise the patch would look like I'd be adding a
bunch of new code.  A reorder can be done in a follow up patch.

Tested on x86_64 Fedora 17.

gdb/
2013-10-03  Pedro Alves  <palves@redhat.com>

	* common/linux-ptrace.c (linux_check_ptrace_features): Factor out
	the PTRACE_O_TRACESYSGOOD and PTRACE_O_TRACEFORK to separate
	functions.  Always test for PTRACE_O_TRACESYSGOOD even if
	PTRACE_O_TRACEFORK is not supported.
	(linux_test_for_tracesysgood): New function.
	(linux_test_for_tracefork): New function, factored out from
	linux_check_ptrace_features, and also don't kill child_pid here.
2013-10-03 10:13:34 +00:00
..
agent.c
agent.h
ax.def
break-common.h gdb/ 2013-07-27 07:11:46 +00:00
btrace-common.h
buffer.c
buffer.h
common-utils.c
common-utils.h
create-version.sh gdb/ 2013-07-04 01:22:38 +00:00
filestuff.c * common/filestuff.c (gdb_fopen_cloexec): Do not try to use "e" 2013-09-14 06:26:35 +00:00
filestuff.h
format.c Handle '#' flag for printf of pointer types. 2013-08-13 16:05:23 +00:00
format.h
gdb_assert.h
gdb_dirent.h
gdb_locale.h
gdb_signals.h
gdb_stat.h
gdb_string.h
gdb_thread_db.h
gdb_vecs.c
gdb_vecs.h gdb/ 2013-06-26 08:01:57 +00:00
gdb_wait.h
glibc_thread_db.h
host-defs.h
i386-cpuid.h gdb: clean up x86 cpuid implementations 2013-06-19 22:29:36 +00:00
i386-gcc-cpuid.h gdb: clean up x86 cpuid implementations 2013-06-19 22:29:36 +00:00
i386-xstate.h
linux-btrace.c gdb: btrace: fix build errors on older glibc builds 2013-09-29 03:57:34 +00:00
linux-btrace.h
linux-osdata.c
linux-osdata.h
linux-procfs.c
linux-procfs.h
linux-ptrace.c Always run the PTRACE_O_TRACESYSGOOD tests even if PTRACE_O_TRACEFORK is not supported. 2013-10-03 10:13:34 +00:00
linux-ptrace.h Unify ptrace options discovery code and make both GDB and 2013-08-22 23:46:30 +00:00
mips-linux-watch.c gdb/ 2013-07-27 07:49:05 +00:00
mips-linux-watch.h gdb/ 2013-07-27 07:49:05 +00:00
ptid.c * aarch64-linux-nat.c: Replace PIDGET with ptid_get_pid. 2013-09-30 11:50:12 +00:00
ptid.h * aarch64-linux-nat.c: Replace PIDGET with ptid_get_pid. 2013-09-30 11:50:12 +00:00
queue.h
signals.c
vec.c
vec.h
version.h don't keep a gdb-specific date 2013-06-24 15:06:27 +00:00
xml-utils.c
xml-utils.h