From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 34000 invoked by alias); 17 Apr 2015 13:28:44 -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 33959 invoked by uid 89); 17 Apr 2015 13:28:42 -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; Fri, 17 Apr 2015 13:28:41 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id F3115AC7B6 for ; Fri, 17 Apr 2015 13:28:39 +0000 (UTC) Received: from blade.nx (ovpn-116-95.ams2.redhat.com [10.36.116.95]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t3HDSdhS017857 for ; Fri, 17 Apr 2015 09:28:39 -0400 Received: from blade.nx (localhost [127.0.0.1]) by blade.nx (Postfix) with ESMTP id 6AAA2263FBA for ; Fri, 17 Apr 2015 14:28:38 +0100 (BST) From: Gary Benson To: gdb-patches@sourceware.org Subject: [PATCH] Use exec_file_find to prepend gdb_sysroot in follow_exec Date: Fri, 17 Apr 2015 13:28:00 -0000 Message-Id: <1429277318-26646-1-git-send-email-gbenson@redhat.com> X-IsSubscribed: yes X-SW-Source: 2015-04/txt/msg00674.txt.bz2 Hi all, 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? Cheers, Gary gdb/ChangeLog: * infrun.c (solist.h): New include. (follow_exec): Use exec_file_find to prefix execd_pathname with gdb_sysroot. --- gdb/ChangeLog | 6 ++++++ gdb/infrun.c | 18 +++++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/gdb/infrun.c b/gdb/infrun.c index 7870f70..f09e2da 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -60,6 +60,7 @@ #include "target-descriptions.h" #include "target-dcache.h" #include "terminal.h" +#include "solist.h" /* Prototypes for local functions */ @@ -1133,15 +1134,18 @@ follow_exec (ptid_t ptid, char *execd_pathname) breakpoint_init_inferior (inf_execd); - 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); + + execd_pathname = alloca (strlen (name) + 1); + strcpy (execd_pathname, name); + xfree (name); } /* Reset the shared library package. This ensures that we get a -- 1.7.1