From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20459 invoked by alias); 22 May 2012 18:17:25 -0000 Received: (qmail 20348 invoked by uid 22791); 22 May 2012 18:17:22 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,TW_CP X-Spam-Check-By: sourceware.org Received: from mail-yx0-f169.google.com (HELO mail-yx0-f169.google.com) (209.85.213.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 22 May 2012 18:17:09 +0000 Received: by yenm7 with SMTP id m7so6912018yen.0 for ; Tue, 22 May 2012 11:17:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:subject:from:to:date:organization:content-type:x-mailer :content-transfer-encoding:mime-version:x-gm-message-state; bh=nFtTXsQig9sHEhGvUsO+EUUUYjCqkknMUxw23x8OMCM=; b=gc7zmmhvzh7YDP1TbKdhz5C9+TvLT7HbdNbsWeoa/8ZLtBvCX7vGWx5BlEaaXgLDc9 VtS34/KjDdSSsmvlilxg+HcU1b9Q9jHNT9I2bWwKTzBKrAbU3T7FMHxTVh4c9vqgmvyP 3+lItb391+XMg4AoEEzuy4SQTPn8S7GuRIu0xbxesYcspqgmAOasePxdd/qKkwmJNDdt VsbsKTrrZu6oluRGkcBF54llOSsn90AqvoOaakx1NFQjatkRPnC1z/PE8/9jObmiVWkO z8zLYHc6OgLvpluv53X/1PDNzHVugh2wvqz0OFw8XB3kfFfeDrrvD2GVZ0tC81pIDOWR 9Rqg== Received: by 10.236.103.106 with SMTP id e70mr14874316yhg.62.1337710628462; Tue, 22 May 2012 11:17:08 -0700 (PDT) Received: from [192.168.1.50] (200.175.195.192.dynamic.dialup.gvt.net.br. [200.175.195.192]) by mx.google.com with ESMTPS id b58sm86111117yhh.16.2012.05.22.11.17.06 (version=SSLv3 cipher=OTHER); Tue, 22 May 2012 11:17:07 -0700 (PDT) Message-ID: <1337710624.19373.9.camel@hactar> Subject: [patch] Expand tildes in solib-search-path entries. From: Thiago Jung Bauermann To: gdb-patches ml Date: Tue, 22 May 2012 18:17:00 -0000 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit Mime-Version: 1.0 X-Gm-Message-State: ALoCoQk5re0gOwn54KqS5irJPjqIIbiH9tajPMdmAdbVZPhrrAhErFLX8ot7QcWIXxG6cWro68Qh 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: 2012-05/txt/msg00842.txt.bz2 Hello, GDB will expand the tilde when using the "set directories", "set sysroot", "source" and "file" commands, possibly others. But it doesn't expand the tilde on "set solib-search-path". This made me lose some time wondering what was going on when I was debugging another issue. This patch fixes it. "set directories" expands the tilde in a much more elaborate way by calling mod_path which calls add_path. "set sysroot", "source" and "file" just call tilde_expand like I do here. There are no regressions in i386-linux. Ok? -- []'s Thiago Jung Bauermann Linaro Toolchain Working Group 2012-05-22 Thiago Jung Bauermann * source.c (openp): Expand tilde in path entries. diff --git a/gdb/source.c b/gdb/source.c index 27c5b0e..af68ebd 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -771,8 +771,28 @@ openp (const char *path, int opts, const char *string, } else { - /* Normal file name in path -- just use it. */ - strcpy (filename, dir); + /* See whether we need to expand the tilde. */ + if (strchr(dir, '~')) + { + int newlen; + char *tilde_expanded; + + tilde_expanded = tilde_expand (dir); + + /* First, realloc the filename buffer if too short. */ + len = strlen (tilde_expanded); + newlen = len + strlen (string) + 2; + if (newlen > alloclen) + { + alloclen = newlen; + filename = alloca (alloclen); + } + strcpy (filename, tilde_expanded); + xfree (tilde_expanded); + } + else + /* Normal file name in path -- just use it. */ + strcpy (filename, dir); /* Don't search $cdir. It's also a magic path like $cwd, but we don't have enough information to expand it. The user *could*