]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix regression in -file-list-exec-source-files command.
authorJoel Brobecker <brobecker@gnat.com>
Thu, 19 Aug 2010 09:12:33 +0000 (09:12 +0000)
committerJoel Brobecker <brobecker@gnat.com>
Thu, 19 Aug 2010 09:12:33 +0000 (09:12 +0000)
See http://sourceware.org/ml/gdb/2010-07/msg00118.html for
a description of the problem. Namely, the file and fullname
fields are inverted in the output of the -file-list-exec-source-files
GDB/MI command:

    (gdb) interpreter-exec mi -file-list-exec-source-files
    ^done,files=[{file="/takamaka.a/brobecke/ex/list-exec-source-files/foo.c",fullname="foo.c"},{file="/takamaka.a/brobecke/ex/list-exec-source-files/foo.c",fullname="foo.c"},{file="",fullname="init.c"},{file="",fullname="../sysdeps/x86_64/elf/start.S"},{file="",fullname="../sysdeps/x86_64/elf/start.S"}]

It turns out to be a silly thinko: The map_symbol_filenames function
calls the psymtab version of map_symbol_filenames routine, and this
version called the callback function with filename and fullname
in the wrong order (fullname/filename instead of filename/fullname).

The routine description in symfile.h confirst that expected order for
the FUN callback parameters:

    /* Call a callback for every file defined in OBJFILE.  FUN is the
       callback.  It is passed the file's name, the file's full name,
       and the DATA passed to this function.  */
    void (*map_symbol_filenames) (struct objfile *objfile,
                                  void (*fun) (const char *, const char *,
                                               void *),
                                  void *data);

Fixing this error uncovered another location where the arguments
were reversed: maybe_add_partial_symtab_filename.  Once the first
error was fixed, the debugger would crash while attempting to do
completion, because it was given a NULL fullname instead of the
non-NULL filename.

gdb/ChangeLog:

        * psymtab.c (map_symbol_filenames_psymtab): Call FUN with
        the arguments in the correct order.
        * symtab.c (maybe_add_partial_symtab_filename): Declare
        the arguments in the correct order.

gdb/ChangeLog
gdb/psymtab.c
gdb/symtab.c

index 0950f43e93dc52838d6dd7052e50d64903b2e246..5a378e3098d37d46dc4431a4bc34017ec8dc39da 100644 (file)
@@ -1,3 +1,10 @@
+2010-08-19  Joel Brobecker  <brobecker@adacore.com>
+
+       * psymtab.c (map_symbol_filenames_psymtab): Call FUN with
+       the arguments in the correct order.
+       * symtab.c (maybe_add_partial_symtab_filename): Declare
+       the arguments in the correct order.
+
 2010-08-18  Tom Tromey  <tromey@redhat.com>
 
        PR python/11900:
index 367cf1ea12be3bdf7b74f7252460e3928007396b..97a4eecd41f173bd20c7b30c28f8293413d76ed7 100644 (file)
@@ -905,7 +905,7 @@ map_symbol_filenames_psymtab (struct objfile *objfile,
        continue;
 
       fullname = psymtab_to_fullname (ps);
-      (*fun) (fullname, ps->filename, data);
+      (*fun) (ps->filename, fullname, data);
     }
 }
 
index 9472c24e4b7e7273c6421c8c8c2b2a80d9e93c92..2c4c9e495e3bb51bea4a35766187cf04dc339544 100644 (file)
@@ -3997,7 +3997,7 @@ struct add_partial_filename_data
 
 /* A callback for map_partial_symbol_filenames.  */
 static void
-maybe_add_partial_symtab_filename (const char *fullname, const char *filename,
+maybe_add_partial_symtab_filename (const char *filename, const char *fullname,
                                   void *user_data)
 {
   struct add_partial_filename_data *data = user_data;