gdb/
authorJan Kratochvil <jan.kratochvil@redhat.com>
Sun, 13 Jan 2013 18:52:45 +0000 (18:52 +0000)
committerJan Kratochvil <jan.kratochvil@redhat.com>
Sun, 13 Jan 2013 18:52:45 +0000 (18:52 +0000)
* source.c (symtab_to_fullname): Apply rewrite_source_path also for
non-existing files.

gdb/testsuite/
* gdb.mi/mi-fullname-deleted.exp: Set srcfileabssubst and initdir.
(set substitute-path): New test.
(fullname present): Remove content.
(substituted fullname): New test.

gdb/ChangeLog
gdb/source.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.mi/mi-fullname-deleted.exp

index fb9545da04e1639edb1fdd705f0029ea30b091da..5495385010a875a259002f130918265ee80156b3 100644 (file)
@@ -1,3 +1,8 @@
+2013-01-13  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       * source.c (symtab_to_fullname): Apply rewrite_source_path also for
+       non-existing files.
+
 2013-01-11  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
        * macrocmd.c (macro_inform_no_debuginfo): Use puts_filtered instead of
index 6e12896d5f9c217a9cadbcf22c0d841ada00ec1a..ca6b4f316d6f58643eb02e271edc8aafe119a9ae 100644 (file)
@@ -1094,10 +1094,25 @@ symtab_to_fullname (struct symtab *s)
 
       if (fd >= 0)
        close (fd);
-      else if (s->dirname == NULL)
-       s->fullname = xstrdup (s->filename);
       else
-       s->fullname = concat (s->dirname, SLASH_STRING, s->filename, NULL);
+       {
+         char *fullname;
+         struct cleanup *back_to;
+
+         /* rewrite_source_path would be applied by find_and_open_source, we
+            should report the pathname where GDB tried to find the file.  */
+
+         if (s->dirname == NULL)
+           fullname = xstrdup (s->filename);
+         else
+           fullname = concat (s->dirname, SLASH_STRING, s->filename, NULL);
+
+         back_to = make_cleanup (xfree, fullname);
+         s->fullname = rewrite_source_path (fullname);
+         if (s->fullname == NULL)
+           s->fullname = xstrdup (fullname);
+         do_cleanups (back_to);
+       }
     } 
 
   return s->fullname;
index e6e4c500520a21c37da2f6894cea57ba1a539215..3e366d98e6cce80ef5710dd25abc434bb1bd2c4e 100644 (file)
@@ -1,3 +1,10 @@
+2013-01-13  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       * gdb.mi/mi-fullname-deleted.exp: Set srcfileabssubst and initdir.
+       (set substitute-path): New test.
+       (fullname present): Remove content.
+       (substituted fullname): New test.
+
 2013-01-13  Joel Brobecker  <brobecker@adacore.com>
 
        * gdb.python/py-finish-breakpoint.exp: Add skip_python_tests
index c2c822f4ea44739d1338ed75b97b204ee5ba21f5..1b9fd5ccfbf5aa428ade7ec836bb1c8471877773 100644 (file)
@@ -24,6 +24,12 @@ if [mi_gdb_start] {
 standard_testfile
 set srcfileabs [standard_output_file $srcfile]
 
+if { [regsub {^(/[^/]+)/} $srcfileabs {\1subst/} srcfileabssubst] != 1
+     || [regsub {^(/[^/]+)/.*$} $srcfileabs {\1} initdir] != 1 } {
+    xfail "Missing root subdirectory"
+    return -1
+}
+
 set f [open $srcfileabs "w"]
 puts $f "int main (void) { return 0; }"
 close $f
@@ -38,4 +44,8 @@ file delete -- $srcfileabs
 mi_gdb_reinitialize_dir $srcdir/$subdir
 mi_gdb_load ${binfile}
 
-mi_gdb_test "-file-list-exec-source-file" ".*\",fullname=\"[string_to_regexp $srcfileabs]\".*" "fullname present"
+mi_gdb_test "-interpreter-exec console \"set substitute-path ${initdir} ${initdir}subst\"" {\^done} "set substitute-path"
+
+mi_gdb_test "-file-list-exec-source-file" ".*\",fullname=\".*\".*" "fullname present"
+
+mi_gdb_test "-file-list-exec-source-file" ".*\",fullname=\"[string_to_regexp $srcfileabssubst]\".*" "substituted fullname"