[patch] Fix substitution for MI fullname of non-existing files
Jan Kratochvil
jan.kratochvil@redhat.com
Sun Jan 6 09:29:00 GMT 2013
Hi,
the patch of mine
[rfc] Print MI fullname even for non-existing files
http://sourceware.org/ml/gdb-patches/2012-12/msg00557.html
Message-ID: <20121217155859.GA8029@host2.jankratochvil.net>
had IMO a bug as it prints the inferior compiled in pathname while GDB first
applies substitution rules to it, not checking the compiled in pathname.
It is not absolutely correct as GDB tries to search all the directories from
"show directories" list while for non-existing files GDB now reports only the
first tried one. Still I find it more useful as discussed before.
No regressions on {x86_64,x86_64-m32,i686}-fedora18-linux-gnu.
Thanks,
Jan
gdb/
2013-01-06 Jan Kratochvil <jan.kratochvil@redhat.com>
* source.c (symtab_to_fullname): Apply rewrite_source_path also for
non-existing files.
gdb/testsuite/
2013-01-06 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.
diff --git a/gdb/source.c b/gdb/source.c
index 6e12896..ca6b4f3 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -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;
diff --git a/gdb/testsuite/gdb.mi/mi-fullname-deleted.exp b/gdb/testsuite/gdb.mi/mi-fullname-deleted.exp
index c2c822f..1b9fd5c 100644
--- a/gdb/testsuite/gdb.mi/mi-fullname-deleted.exp
+++ b/gdb/testsuite/gdb.mi/mi-fullname-deleted.exp
@@ -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"
More information about the Gdb-patches
mailing list