From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8946 invoked by alias); 19 Sep 2012 19:56:01 -0000 Received: (qmail 8936 invoked by uid 22791); 19 Sep 2012 19:56:00 -0000 X-SWARE-Spam-Status: No, hits=-3.8 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from server-nat-6.cs.umd.edu (HELO bacon.cs.umd.edu) (128.8.127.149) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 19 Sep 2012 19:55:45 +0000 Received: from [10.109.174.174] (129-2-129-155.wireless.umd.edu [129.2.129.155]) (Authenticated sender: khooyp) by bacon.cs.umd.edu (Postfix) with ESMTPSA id 549ECB406F5; Wed, 19 Sep 2012 15:55:33 -0400 (EDT) Subject: [PATCH 2/2] Try to initialize data-directory by first searching for "data-directory" in the same directory as the gdb binary Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: multipart/mixed; boundary=Apple-Mail-31-410141544 From: Khoo Yit Phang In-Reply-To: <20120919130040.GA20442@host2.jankratochvil.net> Date: Wed, 19 Sep 2012 19:56:00 -0000 Cc: Khoo Yit Phang , GDB Patches Message-Id: References: <21ACC598-F6B4-4117-BA7B-B316414DE9E3@cs.umd.edu> <20120919130040.GA20442@host2.jankratochvil.net> To: Jan Kratochvil X-CSD-MailScanner-ID: 549ECB406F5.A0C02 X-CSD-MailScanner: Found to be clean X-CSD-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-50, required 5, autolearn=not spam, ALL_TRUSTED -50.00) X-CSD-MailScanner-From: khooyp@cs.umd.edu X-CSD-MailScanner-Watermark: 1348689333.48772@I9Hh0ux6WVPniUZsZnysKQ 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-09/txt/msg00399.txt.bz2 --Apple-Mail-31-410141544 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Content-length: 242 Hi Jan, Here's the second of the split patch that actually implements the extra sea= rch for data-directory in the same directory as the gdb binary. I've droppe= d the reverting changes to cc-with-tweaks.sh as well. Yit September 19, 2012 --Apple-Mail-31-410141544 Content-Disposition: attachment; filename=gdb-relative-data-directory.txt Content-Type: text/plain; name="gdb-relative-data-directory.txt" Content-Transfer-Encoding: 7bit Content-length: 2166 gdb/ChangeLog 2012-09-19 Khoo Yit Phang Try to initialize data-directory by first searching for "data-directory" in the same directory as the gdb binary. * main.c (relocate_gdb_data_directory): New function similar to relocate_gdb_directory, but specifically for data-directory. (captured_main): Call relocate_gdb_data_directory to initialize gdb_datadir. diff --git a/gdb/main.c b/gdb/main.c --- a/gdb/main.c +++ b/gdb/main.c @@ -152,6 +152,49 @@ return dir; } +/* Like relocate_gdb_path, but specifically for data-directory. */ + +static char * +relocate_gdb_data_directory (void) +{ + char *dir; + + /* First try to find "data-directory" in the same directory as gdb. + + Use relocate_path only to resolve the parent directory of + gdb_program_name (i.e., based on PATH if necessary); relocate_path + (gdb_program_name, BINDIR "/data-directory") cannot be used to resolve + data-directory as it returns a path relative to the _grandparent + directory_ of gdb_program_name (munging the parent directory). */ + + dir = relocate_path (gdb_program_name, BINDIR, 1, 1); + if (dir) + dir = reconcat (dir, dir, SLASH_STRING, "data-directory", NULL); + + /* Then try to find GDB_DATADIR relocated relative to gdb. */ + if (!dir) + dir = relocate_path (gdb_program_name, GDB_DATADIR, 1, + GDB_DATADIR_RELOCATABLE); + + /* Otherwise use GDB_DATADIR as is. */ + if (!dir) + dir = xstrdup (GDB_DATADIR); + + /* Canonicalize the directory. */ + if (*dir) + { + char *canon_sysroot = lrealpath (dir); + + if (canon_sysroot) + { + xfree (dir); + dir = canon_sysroot; + } + } + + return dir; +} + /* Compute the locations of init files that GDB should source and return them in SYSTEM_GDBINIT, HOME_GDBINIT, LOCAL_GDBINIT. If there is no system gdbinit (resp. home gdbinit and local gdbinit) @@ -370,8 +413,7 @@ debug_file_directory = relocate_gdb_directory (DEBUGDIR, DEBUGDIR_RELOCATABLE); - gdb_datadir = relocate_gdb_directory (GDB_DATADIR, - GDB_DATADIR_RELOCATABLE); + gdb_datadir = relocate_gdb_data_directory (); #ifdef WITH_PYTHON_PATH { --Apple-Mail-31-410141544--