From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7653 invoked by alias); 15 Apr 2015 09:37:21 -0000 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 Received: (qmail 7643 invoked by uid 89); 15 Apr 2015 09:37:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 15 Apr 2015 09:37:19 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id E85768E6FA for ; Wed, 15 Apr 2015 09:37:17 +0000 (UTC) Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t3F9bFK8002673; Wed, 15 Apr 2015 05:37:16 -0400 Message-ID: <552E314B.9020404@redhat.com> Date: Wed, 15 Apr 2015 09:37:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Gary Benson , gdb-patches@sourceware.org Subject: Re: [PATCH 4/7] Introduce linux_pid_to_exec_file References: <1427887341-31819-1-git-send-email-gbenson@redhat.com> <1427887341-31819-5-git-send-email-gbenson@redhat.com> In-Reply-To: <1427887341-31819-5-git-send-email-gbenson@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2015-04/txt/msg00550.txt.bz2 On 04/01/2015 12:22 PM, Gary Benson wrote: > This commit introduces a new function, linux_pid_to_exec_file, that > shared Linux code can use to discover the filename of the executable > that was run to create a process on the system. > > gdb/ChangeLog: > > * nat/linux-nat.h (linux_pid_to_exec_file): New declaration. > * nat/linux-nat.c: New file. > * Makefile.in (common-linux-nat.o): New rule. > * config/aarch64/linux.mh (NATDEPFILES): Add common-linux-nat.o. > * config/alpha/alpha-linux.mh (NATDEPFILES): Likewise. > * config/arm/linux.mh (NATDEPFILES): Likewise. > * config/i386/linux.mh (NATDEPFILES): Likewise. > * config/i386/linux64.mh (NATDEPFILES): Likewise. > * config/ia64/linux.mh (NATDEPFILES): Likewise. > * config/m32r/linux.mh (NATDEPFILES): Likewise. > * config/m68k/linux.mh (NATDEPFILES): Likewise. > * config/mips/linux.mh (NATDEPFILES): Likewise. > * config/pa/linux.mh (NATDEPFILES): Likewise. > * config/powerpc/linux.mh (NATDEPFILES): Likewise. > * config/powerpc/ppc64-linux.mh (NATDEPFILES): Likewise. > * config/powerpc/spu-linux.mh (NATDEPFILES): Likewise. > * config/s390/linux.mh (NATDEPFILES): Likewise. > * config/sparc/linux.mh (NATDEPFILES): Likewise. > * config/sparc/linux64.mh (NATDEPFILES): Likewise. > * config/tilegx/linux.mh (NATDEPFILES): Likewise. > * config/xtensa/linux.mh (NATDEPFILES): Likewise. > * linux-nat.c (linux_child_pid_to_exec_file): Factored out > to new function linux_pid_to_exec_file in nat/linux-nat.c. Sorry for pushing back a after you touched all these files, but, there's already a natural place for this shared function. > --- /dev/null > +++ b/gdb/nat/linux-nat.c > @@ -0,0 +1,37 @@ > +/* Native-dependent code for GNU/Linux ... > +char * > +linux_pid_to_exec_file (int pid) > +{ > + static char buf[PATH_MAX]; > + char name[PATH_MAX]; > + > + xsnprintf (name, PATH_MAX, "/proc/%d/exe", pid); > + memset (buf, 0, PATH_MAX); > + if (readlink (name, buf, PATH_MAX - 1) <= 0) > + strcpy (buf, name); > + > + return buf; > +} Instead please move this function to nat/linux-procfs.c, (and call it linux_proc_pid_to_exec_file). Thanks, Pedro Alves