Code cleanup: Change OPF_DISABLE_REALPATH to OPF_RETURN_REALPATH.
authorJan Kratochvil <jan.kratochvil@redhat.com>
Wed, 4 Sep 2013 20:09:39 +0000 (20:09 +0000)
committerJan Kratochvil <jan.kratochvil@redhat.com>
Wed, 4 Sep 2013 20:09:39 +0000 (20:09 +0000)
gdb/
2013-09-04  Jan Kratochvil  <jan.kratochvil@redhat.com>

Code cleanup: Change OPF_DISABLE_REALPATH to OPF_RETURN_REALPATH.
* cli/cli-cmds.c (find_and_open_script): Add OPF_RETURN_REALPATH to
variable search_flags.
* defs.h (OPF_DISABLE_REALPATH): Rename to ...
(OPF_RETURN_REALPATH): ... here.
* dwarf2read.c (try_open_dwop_file): Set OPF_RETURN_REALPATH for flags.
* exec.c (exec_file_attach): Remove OPF_DISABLE_REALPATH from openp
call.  Twice.
* nto-tdep.c (nto_find_and_open_solib): Add OPF_RETURN_REALPATH for
openp call.
* solib.c (solib_find): Likewise.  Four times.
* source.c (openp): Change OPF_DISABLE_REALPATH to OPF_RETURN_REALPATH
in the function comment and for the realpath_fptr variable.
(source_full_path_of): Add OPF_RETURN_REALPATH for openp call.
(find_and_open_source): Likewise.  Twice.
* symfile.c (symfile_bfd_open): Likewise, also twice.

gdb/ChangeLog
gdb/cli/cli-cmds.c
gdb/defs.h
gdb/dwarf2read.c
gdb/exec.c
gdb/nto-tdep.c
gdb/solib.c
gdb/source.c
gdb/symfile.c

index d5244c6358b9581e3951dd802608d8389de7c6d6..bd7a8fb0425da2039d91537c99e6bd8d017cb028 100644 (file)
@@ -1,3 +1,22 @@
+2013-09-04  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       Code cleanup: Change OPF_DISABLE_REALPATH to OPF_RETURN_REALPATH.
+       * cli/cli-cmds.c (find_and_open_script): Add OPF_RETURN_REALPATH to
+       variable search_flags.
+       * defs.h (OPF_DISABLE_REALPATH): Rename to ...
+       (OPF_RETURN_REALPATH): ... here.
+       * dwarf2read.c (try_open_dwop_file): Set OPF_RETURN_REALPATH for flags.
+       * exec.c (exec_file_attach): Remove OPF_DISABLE_REALPATH from openp
+       call.  Twice.
+       * nto-tdep.c (nto_find_and_open_solib): Add OPF_RETURN_REALPATH for
+       openp call.
+       * solib.c (solib_find): Likewise.  Four times.
+       * source.c (openp): Change OPF_DISABLE_REALPATH to OPF_RETURN_REALPATH
+       in the function comment and for the realpath_fptr variable.
+       (source_full_path_of): Add OPF_RETURN_REALPATH for openp call.
+       (find_and_open_source): Likewise.  Twice.
+       * symfile.c (symfile_bfd_open): Likewise, also twice.
+
 2013-09-04  Doug Evans  <dje@google.com>
 
        * progspace.c (save_current_space_and_thread): Remove unnecessary
index 0649cbc02a0dcbe84bb0a302e229b14cd7a2f0ae..4317ea351fb168113a20cf91ef334982ebb20fc3 100644 (file)
@@ -479,7 +479,7 @@ find_and_open_script (const char *script_file, int search_path,
   char *file;
   int fd;
   struct cleanup *old_cleanups;
-  int search_flags = OPF_TRY_CWD_FIRST;
+  int search_flags = OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH;
 
   file = tilde_expand (script_file);
   old_cleanups = make_cleanup (xfree, file);
index 2ea49f8f4494b52bcf5a21bbe7aa37349b03ef95..1e5521fc371bc1038e3fa20916aa232dfb85d38d 100644 (file)
@@ -349,7 +349,7 @@ extern const char *pc_prefix (CORE_ADDR);
 /* See openp function definition for their description.  */
 #define OPF_TRY_CWD_FIRST     0x01
 #define OPF_SEARCH_IN_PATH    0x02
-#define OPF_DISABLE_REALPATH  0x04
+#define OPF_RETURN_REALPATH   0x04
 
 extern int openp (const char *, int, const char *, int, char **);
 
index 03b956ac634808c9f3a6597478342d4b8d2e4bc6..59b7b01a2fe47ad1dda219a5a13d42dd937241e5 100644 (file)
@@ -9349,7 +9349,7 @@ try_open_dwop_file (const char *file_name, int is_dwp, int search_cwd)
   else
     search_path = xstrdup (debug_file_directory);
 
-  flags = 0;
+  flags = OPF_RETURN_REALPATH;
   if (is_dwp)
     flags |= OPF_SEARCH_IN_PATH;
   desc = openp (search_path, flags, file_name,
index c61d5307521d75e08c5e5d9243aefd1f78abfbd9..c7370e3d40bf8758febf7f473c1ca53fc6e25a94 100644 (file)
@@ -187,8 +187,7 @@ exec_file_attach (char *filename, int from_tty)
       struct target_section *sections = NULL, *sections_end = NULL;
       char **matching;
 
-      scratch_chan = openp (getenv ("PATH"),
-                           OPF_TRY_CWD_FIRST | OPF_DISABLE_REALPATH, filename,
+      scratch_chan = openp (getenv ("PATH"), OPF_TRY_CWD_FIRST, filename,
                   write_files ? O_RDWR | O_BINARY : O_RDONLY | O_BINARY,
                            &scratch_pathname);
 #if defined(__GO32__) || defined(_WIN32) || defined(__CYGWIN__)
@@ -197,9 +196,7 @@ exec_file_attach (char *filename, int from_tty)
          char *exename = alloca (strlen (filename) + 5);
 
          strcat (strcpy (exename, filename), ".exe");
-         scratch_chan = openp (getenv ("PATH"),
-                               OPF_TRY_CWD_FIRST | OPF_DISABLE_REALPATH,
-                               exename,
+         scratch_chan = openp (getenv ("PATH"), OPF_TRY_CWD_FIRST, exename,
             write_files ? O_RDWR | O_BINARY : O_RDONLY | O_BINARY,
             &scratch_pathname);
        }
index 69ab5adb2cf95aa8004b85ced28696bfca462cda..5ec746d61a22e019c224809f78988a7952e5d9d5 100644 (file)
@@ -128,7 +128,8 @@ nto_find_and_open_solib (char *solib, unsigned o_flags, char **temp_pathname)
             arch_path);
 
   base = lbasename (solib);
-  ret = openp (buf, OPF_TRY_CWD_FIRST, base, o_flags, temp_pathname);
+  ret = openp (buf, OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH, base, o_flags,
+              temp_pathname);
   if (ret < 0 && base != solib)
     {
       xsnprintf (arch_path, arch_len, "/%s", solib);
index fd266876a74852b4b9377c98b26a0878864d0187..5456d6f390e7aded12f4ef46485ae4bc071e8912 100644 (file)
@@ -319,14 +319,16 @@ solib_find (char *in_pathname, int *fd)
 
   /* If not found, search the solib_search_path (if any).  */
   if (found_file < 0 && solib_search_path != NULL)
-    found_file = openp (solib_search_path, OPF_TRY_CWD_FIRST,
+    found_file = openp (solib_search_path,
+                       OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH,
                        in_pathname, O_RDONLY | O_BINARY, &temp_pathname);
 
   /* If not found, next search the solib_search_path (if any) for the basename
      only (ignoring the path).  This is to allow reading solibs from a path
      that differs from the opened path.  */
   if (found_file < 0 && solib_search_path != NULL)
-    found_file = openp (solib_search_path, OPF_TRY_CWD_FIRST,
+    found_file = openp (solib_search_path,
+                       OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH,
                        target_lbasename (fskind, in_pathname),
                        O_RDONLY | O_BINARY, &temp_pathname);
 
@@ -339,16 +341,16 @@ solib_find (char *in_pathname, int *fd)
   if (found_file < 0 && gdb_sysroot_is_empty)
     found_file = openp (get_in_environ (current_inferior ()->environment,
                                        "PATH"),
-                       OPF_TRY_CWD_FIRST, in_pathname, O_RDONLY | O_BINARY,
-                       &temp_pathname);
+                       OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH, in_pathname,
+                       O_RDONLY | O_BINARY, &temp_pathname);
 
   /* If not found, next search the inferior's $LD_LIBRARY_PATH
      environment variable.  */
   if (found_file < 0 && gdb_sysroot_is_empty)
     found_file = openp (get_in_environ (current_inferior ()->environment,
                                        "LD_LIBRARY_PATH"),
-                       OPF_TRY_CWD_FIRST, in_pathname, O_RDONLY | O_BINARY,
-                       &temp_pathname);
+                       OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH, in_pathname,
+                       O_RDONLY | O_BINARY, &temp_pathname);
 
   *fd = found_file;
   return temp_pathname;
index de3fb7c5a34c5852e128c2410cd85a83ddcaa3ce..9fa99b4d3de73be7fdef9598b8256b3676ae6319 100644 (file)
@@ -689,10 +689,10 @@ is_regular_file (const char *name)
    and the file, sigh!  Emacs gets confuzzed by this when we print the
    source file name!!! 
 
-   If OPTS does not have OPF_DISABLE_REALPATH set return FILENAME_OPENED
-   resolved by gdb_realpath.  Even with OPF_DISABLE_REALPATH this function
-   still returns filename starting with "/".  If FILENAME_OPENED is NULL
-   this option has no effect.
+   If OPTS has OPF_RETURN_REALPATH set return FILENAME_OPENED resolved by
+   gdb_realpath.  Even without OPF_RETURN_REALPATH this function still returns
+   filename starting with "/".  If FILENAME_OPENED is NULL this option has no
+   effect.
 
    If a file is found, return the descriptor.
    Otherwise, return -1, with errno set for the last name we tried to open.  */
@@ -857,8 +857,8 @@ done:
        {
          char *(*realpath_fptr) (const char *);
 
-         realpath_fptr = ((opts & OPF_DISABLE_REALPATH) != 0
-                          ? xstrdup : gdb_realpath);
+         realpath_fptr = ((opts & OPF_RETURN_REALPATH) != 0
+                          ? gdb_realpath : xstrdup);
 
          if (IS_ABSOLUTE_PATH (filename))
            *filename_opened = realpath_fptr (filename);
@@ -897,8 +897,9 @@ source_full_path_of (const char *filename, char **full_pathname)
 {
   int fd;
 
-  fd = openp (source_path, OPF_TRY_CWD_FIRST | OPF_SEARCH_IN_PATH, filename,
-             O_RDONLY, full_pathname);
+  fd = openp (source_path,
+             OPF_TRY_CWD_FIRST | OPF_SEARCH_IN_PATH | OPF_RETURN_REALPATH,
+             filename, O_RDONLY, full_pathname);
   if (fd < 0)
     {
       *full_pathname = NULL;
@@ -1077,13 +1078,15 @@ find_and_open_source (const char *filename,
         }
     }
 
-  result = openp (path, OPF_SEARCH_IN_PATH, filename, OPEN_MODE, fullname);
+  result = openp (path, OPF_SEARCH_IN_PATH | OPF_RETURN_REALPATH, filename,
+                 OPEN_MODE, fullname);
   if (result < 0)
     {
       /* Didn't work.  Try using just the basename.  */
       p = lbasename (filename);
       if (p != filename)
-       result = openp (path, OPF_SEARCH_IN_PATH, p, OPEN_MODE, fullname);
+       result = openp (path, OPF_SEARCH_IN_PATH | OPF_RETURN_REALPATH, p,
+                       OPEN_MODE, fullname);
     }
 
   do_cleanups (cleanup);
index 67206cdf239782f563fcfb049c4a7018b179191d..9005e195b088aec0fd3abc81683703b8c8e77627 100644 (file)
@@ -1679,7 +1679,7 @@ symfile_bfd_open (char *name)
   name = tilde_expand (name);  /* Returns 1st new malloc'd copy.  */
 
   /* Look down path for it, allocate 2nd new malloc'd copy.  */
-  desc = openp (getenv ("PATH"), OPF_TRY_CWD_FIRST, name,
+  desc = openp (getenv ("PATH"), OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH, name,
                O_RDONLY | O_BINARY, &absolute_name);
 #if defined(__GO32__) || defined(_WIN32) || defined (__CYGWIN__)
   if (desc < 0)
@@ -1687,8 +1687,8 @@ symfile_bfd_open (char *name)
       char *exename = alloca (strlen (name) + 5);
 
       strcat (strcpy (exename, name), ".exe");
-      desc = openp (getenv ("PATH"), OPF_TRY_CWD_FIRST, exename,
-                   O_RDONLY | O_BINARY, &absolute_name);
+      desc = openp (getenv ("PATH"), OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH,
+                   exename, O_RDONLY | O_BINARY, &absolute_name);
     }
 #endif
   if (desc < 0)