]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Improve Executable displayed path (PR 15415 regression kind #2)
authorJan Kratochvil <jan.kratochvil@redhat.com>
Sun, 13 Oct 2013 16:11:08 +0000 (16:11 +0000)
committerJan Kratochvil <jan.kratochvil@redhat.com>
Sun, 13 Oct 2013 16:11:08 +0000 (16:11 +0000)
gdb/
2013-10-13  Jan Kratochvil  <jan.kratochvil@redhat.com>

Canonicalize directories for EXEC_FILENAME.
* exec.c (exec_file_attach): Use gdb_realpath_keepfile for
exec_filename.
* utils.c (gdb_realpath_keepfile): New function.
* utils.h (gdb_realpath_keepfile): New declaration.

gdb/testsuite/
2013-10-13  Jan Kratochvil  <jan.kratochvil@redhat.com>

Canonicalize directories for EXEC_FILENAME.
* gdb.base/argv0-symlink.exp
(kept file symbolic link name for info inferiors): New.
(kept directory symbolic link name): Setup kfail.
(kept directory symbolic link name for info inferiors): New.

gdb/ChangeLog
gdb/exec.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/argv0-symlink.exp
gdb/utils.c
gdb/utils.h

index 322decc2bfb5b82ff2c727b511039ddb51070a72..ef37d1427d7de828302e53d230e128701f7d1d58 100644 (file)
@@ -1,3 +1,11 @@
+2013-10-13  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       Canonicalize directories for EXEC_FILENAME.
+       * exec.c (exec_file_attach): Use gdb_realpath_keepfile for
+       exec_filename.
+       * utils.c (gdb_realpath_keepfile): New function.
+       * utils.h (gdb_realpath_keepfile): New declaration.
+
 2013-10-11  Doug Evans  <dje@google.com>
 
        * Makefile.in (GDBFLAGS): New variable.
index c7370e3d40bf8758febf7f473c1ca53fc6e25a94..758cdc10ed16e296ac95e0130d2df513e66ea038 100644 (file)
@@ -224,7 +224,7 @@ exec_file_attach (char *filename, int from_tty)
        }
 
       gdb_assert (exec_filename == NULL);
-      exec_filename = xstrdup (scratch_pathname);
+      exec_filename = gdb_realpath_keepfile (scratch_pathname);
 
       if (!bfd_check_format_matches (exec_bfd, bfd_object, &matching))
        {
index 6cd8c23d305747ddc8d4ac06f9172c17d1442026..a5c678bc38394d59a8180c9ee19551e8f646f76b 100644 (file)
@@ -1,3 +1,11 @@
+2013-10-13  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       Canonicalize directories for EXEC_FILENAME.
+       * gdb.base/argv0-symlink.exp
+       (kept file symbolic link name for info inferiors): New.
+       (kept directory symbolic link name): Setup kfail.
+       (kept directory symbolic link name for info inferiors): New.
+
 2013-10-11  Andreas Arnez  <arnez@linux.vnet.ibm.com>
 
        * gdb.arch/s390-multiarch.exp: New file.
index dc11f740e710f905a1de70ec705bf460d0e5b5f4..cf5785c856e18988c8a1a352a37e49fa19f58d2a 100644 (file)
@@ -37,6 +37,7 @@ if ![runto_main] {
 }
 
 gdb_test {print argv[0]} "/$filelink\"" $test
+gdb_test "info inferiors" "/$subdir/$filelink *" "$test for info inferiors"
 
 
 set test "kept directory symbolic link name"
@@ -59,4 +60,9 @@ if ![runto_main] {
     return -1
 }
 
+# gdbserver does not have this issue.
+if ![is_remote target] {
+    setup_kfail "*-*-*" gdb/15934
+}
 gdb_test {print argv[0]} "/$dirlink/$filelink\"" $test
+gdb_test "info inferiors" "/$subdir/$filelink *" "$test for info inferiors"
index 89c248cc46d93b4ca7f95ff6153d162882047e75..47f9dfe321943404f568698b642da21360c139e2 100644 (file)
@@ -3233,6 +3233,52 @@ gdb_realpath (const char *filename)
   return xstrdup (filename);
 }
 
+/* Return a copy of FILENAME, with its directory prefix canonicalized
+   by gdb_realpath.  */
+
+char *
+gdb_realpath_keepfile (const char *filename)
+{
+  const char *base_name = lbasename (filename);
+  char *dir_name;
+  char *real_path;
+  char *result;
+
+  /* Extract the basename of filename, and return immediately 
+     a copy of filename if it does not contain any directory prefix.  */
+  if (base_name == filename)
+    return xstrdup (filename);
+
+  dir_name = alloca ((size_t) (base_name - filename + 2));
+  /* Allocate enough space to store the dir_name + plus one extra
+     character sometimes needed under Windows (see below), and
+     then the closing \000 character.  */
+  strncpy (dir_name, filename, base_name - filename);
+  dir_name[base_name - filename] = '\000';
+
+#ifdef HAVE_DOS_BASED_FILE_SYSTEM
+  /* We need to be careful when filename is of the form 'd:foo', which
+     is equivalent of d:./foo, which is totally different from d:/foo.  */
+  if (strlen (dir_name) == 2 && isalpha (dir_name[0]) && dir_name[1] == ':')
+    {
+      dir_name[2] = '.';
+      dir_name[3] = '\000';
+    }
+#endif
+
+  /* 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);
+  if (IS_DIR_SEPARATOR (real_path[strlen (real_path) - 1]))
+    result = concat (real_path, base_name, (char *) NULL);
+  else
+    result = concat (real_path, SLASH_STRING, base_name, (char *) NULL);
+
+  xfree (real_path);
+  return result;
+}
+
 ULONGEST
 align_up (ULONGEST v, int n)
 {
index 7ea0ff4205deb46e18a163cd06c1c4d950e8a600..208251142bb6c0e6b18ba2f0fc62679cffc61215 100644 (file)
@@ -128,6 +128,8 @@ extern struct cleanup *make_bpstat_clear_actions_cleanup (void);
 
 extern char *gdb_realpath (const char *);
 
+extern char *gdb_realpath_keepfile (const char *);
+
 extern int gdb_filename_fnmatch (const char *pattern, const char *string,
                                 int flags);