From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 109668 invoked by alias); 28 Apr 2015 11:29:17 -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 109653 invoked by uid 89); 28 Apr 2015 11:29:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=no 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; Tue, 28 Apr 2015 11:29:15 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 123B4AC7CB for ; Tue, 28 Apr 2015 11:29:14 +0000 (UTC) Received: from blade.nx (ovpn-116-91.ams2.redhat.com [10.36.116.91]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t3SBTDNu024686; Tue, 28 Apr 2015 07:29:13 -0400 Received: by blade.nx (Postfix, from userid 1000) id 71227263CBC; Tue, 28 Apr 2015 12:29:12 +0100 (BST) Date: Tue, 28 Apr 2015 11:35:00 -0000 From: Gary Benson To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] Use exec_file_find to prepend gdb_sysroot in follow_exec Message-ID: <20150428112912.GA17957@blade.nx> References: <1429277318-26646-1-git-send-email-gbenson@redhat.com> <553E5CF7.7090309@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <553E5CF7.7090309@redhat.com> X-IsSubscribed: yes X-SW-Source: 2015-04/txt/msg01037.txt.bz2 Pedro Alves wrote: > On 04/17/2015 02:28 PM, Gary Benson wrote: > > This commit updates follow_exec to use exec_file_find to prefix > > the new executable's filename with gdb_sysroot rather than doing > > it longhand. > > > > Built and regtested on RHEL6.6 x86_64. > > > > Ok to commit? > > OK. Thanks, I pushed it. > > - if (gdb_sysroot && *gdb_sysroot) > > + if (gdb_sysroot != NULL && *gdb_sysroot != '\0') > > { > > - char *name = alloca (strlen (gdb_sysroot) > > - + strlen (execd_pathname) > > - + 1); > > + int fd = -1; > > + char *name; > > > > - strcpy (name, gdb_sysroot); > > - strcat (name, execd_pathname); > > - execd_pathname = name; > > + name = exec_file_find (execd_pathname, &fd); > > + if (fd >= 0) > > + close (fd); > > We now have at least two places that need to remember to call close. > IWBN if we hid that close in a exec_file_find variant, so that > callers didn't have to recall to do it. Maybe rename exec_file_find > to (e.g.) exec_file_find_fd and reuse the exec_file_find name, even. Good shout. How about I fix solib_find_1 to accept fd == NULL, and put the closing logic in there? That would work for solib_find too then (I'm not sure if there are any "solib_find; close" places in GDB but I'll look.) Cheers, Gary -- http://gbenson.net/