aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDoug Evans <dje@google.com>2015-12-10 12:00:34 -0800
committerDoug Evans <dje@google.com>2015-12-10 12:00:34 -0800
commitf0b5062c409c01d5adf917c931b784b21a950ed8 (patch)
tree53fa73f54ae88efc417cc9d3493773ecd55ef432
parent13265fa94289f4276e1011903b6d88003669bd6b (diff)
downloadfsf-binutils-gdb-f0b5062c409c01d5adf917c931b784b21a950ed8.zip
fsf-binutils-gdb-f0b5062c409c01d5adf917c931b784b21a950ed8.tar.gz
fsf-binutils-gdb-f0b5062c409c01d5adf917c931b784b21a950ed8.tar.bz2
patch ../103142854.patch
-rw-r--r--README.google16
-rw-r--r--gdb/dwarf2read.c3
-rw-r--r--gdb/source.c45
-rw-r--r--gdb/source.h8
-rw-r--r--gdb/symtab.c3
5 files changed, 67 insertions, 8 deletions
diff --git a/README.google b/README.google
index df0c3f9..3db46cf 100644
--- a/README.google
+++ b/README.google
@@ -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.
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 68c4b87..5246e91 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -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];
}
diff --git a/gdb/source.c b/gdb/source.c
index fbec0f1..c6e0401 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -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);
+}
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);
}
diff --git a/gdb/source.h b/gdb/source.h
index 9050357..8431460 100644
--- a/gdb/source.h
+++ b/gdb/source.h
@@ -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
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 6c09da6..8a0bb8a 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -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));
}