This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [patch] PID cmdline argument should be whole from digits [+testcase]
On Sunday 14 February 2010 18:56:04, Jan Kratochvil wrote:
> On Sun, 14 Feb 2010 15:54:10 +0100, Pedro Alves wrote:
> > On windows-nat.c, the PID can either be a Windows or Cygwin PID.
>
> On non-cygwin (mingw?) HAVE_GETPID should be false and in Cygwin it should be
> compatible.
mingw does have getpid/_getpid. What I meant was for you to notice
that windows-nat.c when built for Cygwin tries PID as a Windows PID,
and if that fails, tries PID as a Cygwin PID. Probably doesn't matter
in this case; but this further demonstrates on top of the remote
example, that there's target side tweakable behaviour here.
> But I understand relying on HAVE_* being false is not good.
Yes.
>
> (moved getpid checking out of parse_pid* + kept "process-id to attach" message
> intact)
>
> parse_pid_to_attach does not use pid_t return type as while it is
> defined-as-needed by config.h it would not be compatible with windows-nat.c
> expected DWORD type.
(pid_t would only make sense for native targets anyway. At some
point, we may have to come up with a target_pid_t, or some such,
but we've dodged it so far.)
I'd prefer to make it return int, because it's what we in
use common code to store a pid. E.g., ptid_t.pid,
inferior->pid. Note that DWORD is always 32-bit, even
on 64-bit Windows.
Can you extend the describing comment of parse_pid_to_attach,
with something like:
Either returns a valid PID, or throws an error.
Otherwise, looks OK to me.
--
Pedro Alves