From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15342 invoked by alias); 28 May 2005 23:42:42 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 15331 invoked by uid 22791); 28 May 2005 23:42:36 -0000 Received: from nevyn.them.org (HELO nevyn.them.org) (66.93.172.17) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Sat, 28 May 2005 23:42:36 +0000 Received: from drow by nevyn.them.org with local (Exim 4.50) id 1DcAws-0002ti-E8; Sat, 28 May 2005 19:42:34 -0400 Date: Sat, 28 May 2005 23:59:00 -0000 From: Daniel Jacobowitz To: gdb-patches@sourceware.org Cc: Christopher Faylor Subject: RFA: Use lrealpath instead of gdb_realpath Message-ID: <20050528234233.GA3440@nevyn.them.org> Mail-Followup-To: gdb-patches@sourceware.org, Christopher Faylor Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.8i X-SW-Source: 2005-05/txt/msg00595.txt.bz2 This patch will have no effect on any system except mingw32; on that system, it will call GetFullPathName after the patch, since Danny Smith added bits for that to libiberty last June. Eli, I understand that you think this is a bad choice. However, the mingw32 maintainers disagree. My only motivation here is to get rid of the duplicated function; I thought I'd done this in the first place, but obviously I forgot to. I don't want to leave both copies around, in case they continue to diverge. Chris, since mingw32 should be the only affected target, I'll ask you for approval. OK? I verified that there is no change in behavior on i686-linux. -- Daniel Jacobowitz CodeSourcery, LLC 2005-05-28 Daniel Jacobowitz * defs.h (gdb_realpath): Remove prototype. * nto-tdep.c (nto_find_and_open_solib): Use lrealpath. * symtab.c (lookup_symtab, lookup_partial_symtab): Likewise. * utils.c (xfullpath): Likewise. (gdb_realpath): Delete. * source.c (openp): Update comment. Index: defs.h =================================================================== RCS file: /cvs/src/src/gdb/defs.h,v retrieving revision 1.186 diff -u -p -r1.186 defs.h --- defs.h 19 May 2005 17:55:53 -0000 1.186 +++ defs.h 28 May 2005 23:13:39 -0000 @@ -397,7 +397,6 @@ extern int yquery (const char *, ...) AT extern void init_page_info (void); -extern char *gdb_realpath (const char *); extern char *xfullpath (const char *); extern unsigned long gnu_debuglink_crc32 (unsigned long crc, Index: nto-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/nto-tdep.c,v retrieving revision 1.13 diff -u -p -r1.13 nto-tdep.c --- nto-tdep.c 17 Feb 2005 13:49:55 -0000 1.13 +++ nto-tdep.c 28 May 2005 23:13:39 -0000 @@ -148,7 +148,7 @@ nto_find_and_open_solib (char *solib, un if (temp_pathname) { if (ret >= 0) - *temp_pathname = gdb_realpath (arch_path); + *temp_pathname = lrealpath (arch_path); else **temp_pathname = '\0'; } Index: source.c =================================================================== RCS file: /cvs/src/src/gdb/source.c,v retrieving revision 1.68 diff -u -p -r1.68 source.c --- source.c 27 May 2005 04:39:32 -0000 1.68 +++ source.c 28 May 2005 23:13:40 -0000 @@ -756,7 +756,7 @@ done: if (filename_opened) { /* If a file was opened, canonicalize its filename. Use xfullpath - rather than gdb_realpath to avoid resolving the basename part + rather than lrealpath to avoid resolving the basename part of filenames when the associated file is a symbolic link. This fixes a potential inconsistency between the filenames known to GDB and the filenames it prints in the annotations. */ Index: symtab.c =================================================================== RCS file: /cvs/src/src/gdb/symtab.c,v retrieving revision 1.145 diff -u -p -r1.145 symtab.c --- symtab.c 8 Mar 2005 04:34:44 -0000 1.145 +++ symtab.c 28 May 2005 23:13:40 -0000 @@ -163,7 +163,7 @@ lookup_symtab (const char *name) { full_path = xfullpath (name); make_cleanup (xfree, full_path); - real_path = gdb_realpath (name); + real_path = lrealpath (name); make_cleanup (xfree, real_path); } @@ -195,7 +195,7 @@ got_symtab: char *fullname = symtab_to_fullname (s); if (fullname != NULL) { - char *rp = gdb_realpath (fullname); + char *rp = lrealpath (fullname); make_cleanup (xfree, rp); if (FILENAME_CMP (real_path, rp) == 0) { @@ -259,7 +259,7 @@ lookup_partial_symtab (const char *name) { full_path = xfullpath (name); make_cleanup (xfree, full_path); - real_path = gdb_realpath (name); + real_path = lrealpath (name); make_cleanup (xfree, real_path); } @@ -288,7 +288,7 @@ lookup_partial_symtab (const char *name) psymtab_to_fullname (pst); if (pst->fullname != NULL) { - rp = gdb_realpath (pst->fullname); + rp = lrealpath (pst->fullname); make_cleanup (xfree, rp); } if (rp != NULL && FILENAME_CMP (real_path, rp) == 0) Index: utils.c =================================================================== RCS file: /cvs/src/src/gdb/utils.c,v retrieving revision 1.160 diff -u -p -r1.160 utils.c --- utils.c 18 Mar 2005 20:46:38 -0000 1.160 +++ utils.c 28 May 2005 23:13:41 -0000 @@ -2920,80 +2920,8 @@ string_to_core_addr (const char *my_stri return addr; } -char * -gdb_realpath (const char *filename) -{ - /* Method 1: The system has a compile time upper bound on a filename - path. Use that and realpath() to canonicalize the name. This is - the most common case. Note that, if there isn't a compile time - upper bound, you want to avoid realpath() at all costs. */ -#if defined(HAVE_REALPATH) - { -# if defined (PATH_MAX) - char buf[PATH_MAX]; -# define USE_REALPATH -# elif defined (MAXPATHLEN) - char buf[MAXPATHLEN]; -# define USE_REALPATH -# endif -# if defined (USE_REALPATH) - const char *rp = realpath (filename, buf); - if (rp == NULL) - rp = filename; - return xstrdup (rp); -# endif - } -#endif /* HAVE_REALPATH */ - - /* Method 2: The host system (i.e., GNU) has the function - canonicalize_file_name() which malloc's a chunk of memory and - returns that, use that. */ -#if defined(HAVE_CANONICALIZE_FILE_NAME) - { - char *rp = canonicalize_file_name (filename); - if (rp == NULL) - return xstrdup (filename); - else - return rp; - } -#endif - - /* FIXME: cagney/2002-11-13: - - Method 2a: Use realpath() with a NULL buffer. Some systems, due - to the problems described in in method 3, have modified their - realpath() implementation so that it will allocate a buffer when - NULL is passed in. Before this can be used, though, some sort of - configure time test would need to be added. Otherwize the code - will likely core dump. */ - - /* Method 3: Now we're getting desperate! The system doesn't have a - compile time buffer size and no alternative function. Query the - OS, using pathconf(), for the buffer limit. Care is needed - though, some systems do not limit PATH_MAX (return -1 for - pathconf()) making it impossible to pass a correctly sized buffer - to realpath() (it could always overflow). On those systems, we - skip this. */ -#if defined (HAVE_REALPATH) && defined (HAVE_UNISTD_H) && defined(HAVE_ALLOCA) - { - /* Find out the max path size. */ - long path_max = pathconf ("/", _PC_PATH_MAX); - if (path_max > 0) - { - /* PATH_MAX is bounded. */ - char *buf = alloca (path_max); - char *rp = realpath (filename, buf); - return xstrdup (rp ? rp : filename); - } - } -#endif - - /* This system is a lost cause, just dup the buffer. */ - return xstrdup (filename); -} - /* Return a copy of FILENAME, with its directory prefix canonicalized - by gdb_realpath. */ + by lrealpath. */ char * xfullpath (const char *filename) @@ -3028,7 +2956,7 @@ xfullpath (const char *filename) /* Canonicalize the directory prefix, and build the resulting filename. If the dirname realpath already contains an ending directory separator, avoid doubling it. */ - real_path = gdb_realpath (dir_name); + real_path = lrealpath (dir_name); if (IS_DIR_SEPARATOR (real_path[strlen (real_path) - 1])) result = concat (real_path, base_name, NULL); else