Re: [PATCH 02/15] Remove some GDBSERVER checks from linux-ptrace

Doug Evans
2014-07-11T19:29:09Z

Gary Benson writes:
> This patch removes some GDBSERVER checks from nat/linux-ptrace.c.
> Currently the code uses a compile-time check to decide whether some
> flags should be used. This changes the code to instead let users of
> the module specify an additional set of flags; and then changes gdb's
> linux-nat.c to call this function. At some later date, when the back
> ends are fully merged, we will be able to remove this function again.
>
> gdb/
> 2014-07-09 Tom Tromey <tromey@redhat.com>
> Gary Benson <gbenson@redhat.com>
>
> * nat/linux-ptrace.c (additional_flags): New global.
> (linux_test_for_tracesysgood, linux_test_for_tracefork): Use
> additional_flags; don't check GDBSERVER.
> (linux_ptrace_set_additional_flags): New function.
> * nat/linux-ptrace.h (linux_ptrace_set_additional_flags):
> Declare.
> * linux-nat.c (_initialize_linux_nat): Call
> linux_ptrace_set_additional_flags.

Hi. Recognizing that this is a temporary hack, the patch is ok with me.
One nit below.

> @@ -433,18 +435,7 @@ linux_test_for_tracefork (int child_pid)
>
> /* We got the PID from the grandchild, which means fork
> tracing is supported. */
> -#ifdef GDBSERVER
> - /* Do not enable all the options for now since gdbserver does not
> - properly support them. This restriction will be lifted when
> - gdbserver is augmented to support them. */
> - current_ptrace_options |= PTRACE_O_TRACECLONE;
> -#else
> - current_ptrace_options |= PTRACE_O_TRACEFORK | PTRACE_O_TRACEVFORK
> - | PTRACE_O_TRACECLONE | PTRACE_O_TRACEEXEC;
> -
> - /* Do not enable PTRACE_O_TRACEEXIT until GDB is more prepared to
> - support read-only process state. */
> -#endif
> + current_ptrace_options |= PTRACE_O_TRACECLONE | additional_flags;
>
> /* Do some cleanup and kill the grandchild. */
> my_waitpid (second_pid, &second_status, 0);

I can't tell if the PTRACE_O_TRACEEXIT comment was accidentally
or intentionally dropped.
I'm not sure it's important enough to keep, but it would be
good to verify its deletion was intentional.