]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
patch ../103142854.patch
authorDoug Evans <dje@google.com>
Thu, 10 Dec 2015 20:00:34 +0000 (12:00 -0800)
committerDoug Evans <dje@google.com>
Thu, 10 Dec 2015 20:00:34 +0000 (12:00 -0800)
README.google
gdb/dwarf2read.c
gdb/source.c
gdb/source.h
gdb/symtab.c

index df0c3f90eec0b9bfea74d9b675dcaf9a0dec96ad..3db46cf70d1ef90d4ec39e1051bdbcc78e00af19 100644 (file)
@@ -481,3 +481,19 @@ they are an ongoing maintenance burden.
 +      testsuite/
 +      * gdb.python/python.exp: Add test for symlink from .py file to .notpy
 +      file.
+--- README.google      2015-09-15 16:23:33.000000000 -0700
++++ README.google      2015-09-15 16:26:22.000000000 -0700
++
++2015-09-15  Doug Evans  <dje@google.com>
++
++      Ref# 23817600
++      * dwarf2read.c (dw2_get_real_path): Call canonicalize_source_path
++      instead of gdb_realpath.
++      * symtab.c (iterate_over_symtabs): Ditto.
++      * source.c (canonicalize_source_paths): New static global.
++      (source_full_path_of): Only pass OPF_RETURN_REALPATH to openp if
++      canonicalize_source_paths.
++      (find_and_open_source): Ditto.  Call canonicalize_source_path.
++      (canonicalize_source_path): New function.
++      (_initialize_source): New parameter "canonicalize-source-paths".
++      * source.h (canonicalize_source_path): Declare.
index 68c4b87bf2251c04ac0456a815c8b3d79e0566c4..5246e91f27d2b9324083233c522e0e3b0891f7d5 100644 (file)
@@ -3464,7 +3464,8 @@ dw2_get_real_path (struct objfile *objfile,
                                      qfn->num_file_names, const char *);
 
   if (qfn->real_names[index] == NULL)
-    qfn->real_names[index] = gdb_realpath (qfn->file_names[index]);
+    /* GOOGLE LOCAL: ref# 23817600 */
+    qfn->real_names[index] = canonicalize_source_path (qfn->file_names[index]);
 
   return qfn->real_names[index];
 }
index fbec0f1212f2537492fea4930f610f04440c98b8..c6e04015f7f748882e3e2acc948f2c694a86a347 100644 (file)
@@ -62,6 +62,11 @@ static void line_info (char *, int);
 
 static void source_info (char *, int);
 
+/* GOOGLE LOCAL ref# 23817600 */
+/* Non-zero if source file paths should be canonicalized (realpath'd).  */
+
+static int canonicalize_source_paths = 1;
+
 /* Path of directories to search for source files.
    Same format as the PATH environment variable's value.  */
 
@@ -916,7 +921,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 | OPF_RETURN_REALPATH,
+             (OPF_TRY_CWD_FIRST | OPF_SEARCH_IN_PATH
+              /* GOOGLE LOCAL ref# 23817600 */
+              | (canonicalize_source_paths ? OPF_RETURN_REALPATH : 0)),
              filename, O_RDONLY, full_pathname);
   if (fd < 0)
     {
@@ -1028,7 +1035,8 @@ find_and_open_source (const char *filename,
       result = gdb_open_cloexec (*fullname, OPEN_MODE, 0);
       if (result >= 0)
        {
-         char *lpath = gdb_realpath (*fullname);
+         /* GOOGLE LOCAL ref# 23817600 */
+         char *lpath = canonicalize_source_path (*fullname);
 
          xfree (*fullname);
          *fullname = lpath;
@@ -1089,15 +1097,22 @@ find_and_open_source (const char *filename,
         }
     }
 
-  result = openp (path, OPF_SEARCH_IN_PATH | OPF_RETURN_REALPATH, filename,
-                 OPEN_MODE, fullname);
+  /* GOOGLE LOCAL ref# 23817600 */
+  result = openp (path,
+                 (OPF_SEARCH_IN_PATH
+                  | (canonicalize_source_paths ? OPF_RETURN_REALPATH : 0)),
+                 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 | OPF_RETURN_REALPATH, p,
-                       OPEN_MODE, fullname);
+       result = openp (path,
+                       /* GOOGLE LOCAL ref# 23817600 */
+                       (OPF_SEARCH_IN_PATH
+                        | (canonicalize_source_paths
+                           ? OPF_RETURN_REALPATH : 0)),
+                       p, OPEN_MODE, fullname);
     }
 
   do_cleanups (cleanup);
@@ -2002,6 +2017,16 @@ set_substitute_path_command (char *args, int from_tty)
   do_cleanups (cleanup);
 }
 
+/* GOOGLE LOCAL ref# 23817600 */
+/* See source.h.  */
+
+char *
+canonicalize_source_path (const char *source_path)
+{
+  if (canonicalize_source_paths)
+    return gdb_realpath (source_path);
+  return gdb_abspath (source_path);
+}
 \f
 void
 _initialize_source (void)
@@ -2120,4 +2145,12 @@ By default, relative filenames are displayed."),
                        show_filename_display_string,
                        &setlist, &showlist);
 
+  /* GOOGLE LOCAL ref# 23817600 */
+  add_setshow_boolean_cmd ("canonicalize-source-paths", class_obscure,
+                          &canonicalize_source_paths, _("\
+Set whether source file paths are canonicalized."), _("\
+Show whether source file paths are canonicalized."), _("\
+If set, GDB will canonicalize all source paths (e.g., expand symlinks)."),
+                          NULL, NULL,
+                          &setlist, &showlist);
 }
index 9050357f8a9f19e0ff627f5d76a20b282dc95915..84314606057d49a22765173aab4553a78a07f561 100644 (file)
@@ -98,4 +98,12 @@ extern void clear_current_source_symtab_and_line (void);
 
 /* Add a source path substitution rule.  */
 extern void add_substitute_path_rule (char *, char *);
+
+/* GOOGLE LOCAL ref# 23817600 */
+/* Return the possibly canonicalized version of SOURCE_PATH.
+   Whether to do so is controlled by the "canonicalize-source-paths"
+   parameter.  The result is always an absolute path.
+   Space for the result is always malloc'd, caller must free.  */
+extern char *canonicalize_source_path (const char *source_path);
+
 #endif
index 6c09da674684c8914491f898703e3893711f4acc..8a0bb8add83cc11d4ba8856cac243b8b58ce8339 100644 (file)
@@ -437,7 +437,8 @@ iterate_over_symtabs (const char *name,
      absolutizing a relative path.  */
   if (IS_ABSOLUTE_PATH (name))
     {
-      real_path = gdb_realpath (name);
+      /* GOOGLE LOCAL ref# 23817600 */
+      real_path = canonicalize_source_path (name);
       make_cleanup (xfree, real_path);
       gdb_assert (IS_ABSOLUTE_PATH (real_path));
     }