From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23479 invoked by alias); 15 Feb 2010 14:57:40 -0000 Received: (qmail 23462 invoked by uid 22791); 15 Feb 2010 14:57:40 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 15 Feb 2010 14:57:35 +0000 Received: (qmail 25761 invoked from network); 15 Feb 2010 14:57:32 -0000 Received: from unknown (HELO orlando.localnet) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 15 Feb 2010 14:57:32 -0000 From: Pedro Alves To: Jan Kratochvil Subject: Re: [patch] PID cmdline argument should be whole from digits [+testcase] Date: Mon, 15 Feb 2010 14:57:00 -0000 User-Agent: KMail/1.12.2 (Linux/2.6.31-19-generic; KDE/4.3.2; x86_64; ; ) Cc: gdb-patches@sourceware.org, Eli Zaretskii References: <20100213152044.GA6115@host0.dyn.jankratochvil.net> <201002141454.11337.pedro@codesourcery.com> <20100214185604.GA30756@host0.dyn.jankratochvil.net> In-Reply-To: <20100214185604.GA30756@host0.dyn.jankratochvil.net> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201002151457.24814.pedro@codesourcery.com> X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-02/txt/msg00361.txt.bz2 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