PR ld/12549
[binutils-gdb.git] / gdb / symmisc.c
index 694a84a89e4cf3573f8b8487992334f290e64d2f..5fa4e4e0fbd03b86e5a505258f1c28f15ebf5291 100644 (file)
@@ -1,7 +1,6 @@
 /* Do various things to symbol tables (other than lookup), for GDB.
 
-   Copyright (C) 1986-2000, 2002-2004, 2007-2012 Free Software
-   Foundation, Inc.
+   Copyright (C) 1986-2013 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -36,6 +35,8 @@
 #include "gdb_stat.h"
 #include "dictionary.h"
 #include "typeprint.h"
+#include "gdbcmd.h"
+#include "source.h"
 
 #include "gdb_string.h"
 #include "readline/readline.h"
@@ -185,7 +186,7 @@ dump_objfile (struct objfile *objfile)
           symtab != NULL;
           symtab = symtab->next)
        {
-         printf_filtered ("%s at ", symtab->filename);
+         printf_filtered ("%s at ", symtab_to_filename_for_display (symtab));
          gdb_print_host_address (symtab, gdb_stdout);
          printf_filtered (", ");
          if (symtab->objfile != objfile)
@@ -294,7 +295,8 @@ dump_symtab_1 (struct objfile *objfile, struct symtab *symtab,
   struct block *b;
   int depth;
 
-  fprintf_filtered (outfile, "\nSymtab for file %s\n", symtab->filename);
+  fprintf_filtered (outfile, "\nSymtab for file %s\n",
+                   symtab_to_filename_for_display (symtab));
   if (symtab->dirname)
     fprintf_filtered (outfile, "Compilation directory is %s\n",
                      symtab->dirname);
@@ -401,7 +403,7 @@ dump_symtab (struct objfile *objfile, struct symtab *symtab,
     dump_symtab_1 (objfile, symtab, outfile);
 }
 
-void
+static void
 maintenance_print_symbols (char *args, int from_tty)
 {
   char **argv;
@@ -443,7 +445,8 @@ maintenance_print_symbols (char *args, int from_tty)
   ALL_SYMTABS (objfile, s)
     {
       QUIT;
-      if (symname == NULL || filename_cmp (symname, s->filename) == 0)
+      if (symname == NULL
+         || filename_cmp (symname, symtab_to_filename_for_display (s)) == 0)
        dump_symtab (objfile, s, outfile);
     }
   do_cleanups (cleanups);
@@ -626,7 +629,7 @@ print_symbol (void *args)
   return 1;
 }
 
-void
+static void
 maintenance_print_msymbols (char *args, int from_tty)
 {
   char **argv;
@@ -655,7 +658,7 @@ maintenance_print_msymbols (char *args, int from_tty)
       /* If a second arg is supplied, it is a source file name to match on.  */
       if (argv[1] != NULL)
        {
-         symname = xfullpath (argv[1]);
+         symname = gdb_realpath (argv[1]);
          make_cleanup (xfree, symname);
          if (symname && stat (symname, &sym_st))
            perror_with_name (symname);
@@ -675,6 +678,7 @@ maintenance_print_msymbols (char *args, int from_tty)
       {
        QUIT;
        if (symname == NULL || (!stat (objfile->name, &obj_st)
+                               && sym_st.st_dev == obj_st.st_dev
                                && sym_st.st_ino == obj_st.st_ino))
          dump_msymbols (objfile, outfile);
       }
@@ -682,7 +686,7 @@ maintenance_print_msymbols (char *args, int from_tty)
   do_cleanups (cleanups);
 }
 
-void
+static void
 maintenance_print_objfiles (char *ignore, int from_tty)
 {
   struct program_space *pspace;
@@ -700,7 +704,7 @@ maintenance_print_objfiles (char *ignore, int from_tty)
 
 /* List all the symbol tables whose names match REGEXP (optional).  */
 
-void
+static void
 maintenance_info_symtabs (char *regexp, int from_tty)
 {
   struct program_space *pspace;
@@ -723,7 +727,7 @@ maintenance_info_symtabs (char *regexp, int from_tty)
          QUIT;
 
          if (! regexp
-             || re_exec (symtab->filename))
+             || re_exec (symtab_to_filename_for_display (symtab)))
            {
              if (! printed_objfile_start)
                {
@@ -734,7 +738,8 @@ maintenance_info_symtabs (char *regexp, int from_tty)
                  printed_objfile_start = 1;
                }
 
-             printf_filtered ("        { symtab %s ", symtab->filename);
+             printf_filtered ("        { symtab %s ",
+                              symtab_to_filename_for_display (symtab));
              wrap_here ("    ");
              printf_filtered ("((struct symtab *) %s)\n", 
                               host_address_to_string (symtab));
@@ -784,4 +789,27 @@ _initialize_symmisc (void)
   std_in = stdin;
   std_out = stdout;
   std_err = stderr;
+
+  add_cmd ("symbols", class_maintenance, maintenance_print_symbols, _("\
+Print dump of current symbol definitions.\n\
+Entries in the full symbol table are dumped to file OUTFILE.\n\
+If a SOURCE file is specified, dump only that file's symbols."),
+          &maintenanceprintlist);
+
+  add_cmd ("msymbols", class_maintenance, maintenance_print_msymbols, _("\
+Print dump of current minimal symbol definitions.\n\
+Entries in the minimal symbol table are dumped to file OUTFILE.\n\
+If a SOURCE file is specified, dump only that file's minimal symbols."),
+          &maintenanceprintlist);
+
+  add_cmd ("objfiles", class_maintenance, maintenance_print_objfiles,
+          _("Print dump of current object file definitions."),
+          &maintenanceprintlist);
+
+  add_cmd ("symtabs", class_maintenance, maintenance_info_symtabs, _("\
+List the full symbol tables for all object files.\n\
+This does not include information about individual symbols, blocks, or\n\
+linetables --- just the symbol table structures themselves.\n\
+With an argument REGEXP, list the symbol tables whose names that match that."),
+          &maintenanceinfolist);
 }