* corelow.c, exec.c, inftarg.c, m3-nat.c, op50-rom.c, procfs.c,
[deliverable/binutils-gdb.git] / gdb / symfile.c
index 98c5c457bbd89436455e61ab61129230216b2dfc..24e7c6e3f625b667288bf18292c9dfc77787fc79 100644 (file)
@@ -1,5 +1,5 @@
 /* Generic symbol file reading for the GNU debugger, GDB.
-   Copyright 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
+   Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
    Contributed by Cygnus Support, using pieces from other GDB modules.
 
 This file is part of GDB.
@@ -73,6 +73,9 @@ load_command PARAMS ((char *, int));
 static void
 add_symbol_file_command PARAMS ((char *, int));
 
+static void
+add_shared_symbol_files_command PARAMS ((char *, int));
+
 static void
 cashier_psymtab PARAMS ((struct partial_symtab *));
 
@@ -294,11 +297,9 @@ init_entry_point_info (objfile)
   else
     {
       /* Examination of non-executable.o files.  Short-circuit this stuff.  */
-      /* ~0 will not be in any file, we hope.  */
-      objfile -> ei.entry_point = ~0;
-      /* set the startup file to be an empty range.  */
-      objfile -> ei.entry_file_lowpc = 0;
-      objfile -> ei.entry_file_highpc = 0;
+      objfile -> ei.entry_point = INVALID_ENTRY_POINT;
+      objfile -> ei.entry_file_lowpc = INVALID_ENTRY_LOWPC;
+      objfile -> ei.entry_file_highpc = INVALID_ENTRY_HIGHPC;
     }
 }
 
@@ -464,6 +465,13 @@ syms_from_objfile (objfile, addr, mainline, verbo)
 
   (*objfile -> sf -> sym_read) (objfile, section_offsets, mainline);
 
+  if (!have_partial_symbols () && !have_full_symbols ())
+    {
+      wrap_here ("");
+      printf_filtered ("(no debugging symbols found)...");
+      wrap_here ("");
+    }
+
   /* Don't allow char * to have a typename (else would get caddr_t).
      Ditto void *.  FIXME: Check whether this is now done by all the
      symbol readers themselves (many of them now do), and if so remove
@@ -612,17 +620,19 @@ symbol_file_add (name, from_tty, addr, mainline, mapped, readnow)
     }
 
   new_symfile_objfile (objfile, mainline, from_tty);
-      
-  /* Getting new symbols may change our opinion about what is
-     frameless.  */
-
-  reinit_frame_cache ();
 
   return (objfile);
 }
 
-/* This is the symbol-file command.  Read the file, analyze its symbols,
-   and add a struct symtab to a symtab list.  */
+/* This is the symbol-file command.  Read the file, analyze its
+   symbols, and add a struct symtab to a symtab list.  The syntax of
+   the command is rather bizarre--(1) buildargv implements various
+   quoting conventions which are undocumented and have little or
+   nothing in common with the way things are quoted (or not quoted)
+   elsewhere in GDB, (2) options are used, which are not generally
+   used in GDB (perhaps "set mapped on", "set readnow on" would be
+   better), (3) the order of options matters, which is contrary to GNU
+   conventions (because it is confusing and inconvenient).  */
 
 void
 symbol_file_command (args, from_tty)
@@ -675,7 +685,32 @@ symbol_file_command (args, from_tty)
            }
          else
            {
-             name = *argv;
+            char *p;
+
+              name = *argv;
+
+              /* this is for rombug remote only, to get the text relocation by
+              using link command */
+              p = strrchr(name, '/');
+              if (p != NULL) p++;
+              else p = name;
+
+              target_link(p, &text_relocation);
+
+              if (text_relocation == (CORE_ADDR)0)
+                return;
+              else if (text_relocation == (CORE_ADDR)-1)
+                symbol_file_add (name, from_tty, (CORE_ADDR)0, 1, mapped,
+                                readnow);
+              else
+                symbol_file_add (name, from_tty, (CORE_ADDR)text_relocation,
+                                0, mapped, readnow);
+
+             /* Getting new symbols may change our opinion about what is
+                frameless.  */
+             reinit_frame_cache ();
+
+              set_initial_language ();
            }
          argv++;
        }
@@ -684,25 +719,6 @@ symbol_file_command (args, from_tty)
        {
          error ("no symbol file name was specified");
        }
-      else
-       {
-         char *p;
-
-         /* If target_link can find out where the file is,
-            more power to it.  */
-         p = strrchr (name, '/');
-         if (p != NULL) p++;
-         else p = name;
-
-         target_link (p, &text_relocation);
-         if (text_relocation == (CORE_ADDR)-1)
-           text_relocation = 0;
-
-         symbol_file_add (name, from_tty, text_relocation, 1, mapped,
-                          readnow);
-         set_initial_language ();
-       }
-
       do_cleanups (cleanups);
     }
 }
@@ -841,6 +857,8 @@ load_command (arg, from_tty)
      char *arg;
      int from_tty;
 {
+  if (arg == NULL)
+    arg = get_exec_file (1);
   target_load (arg, from_tty);
 }
 
@@ -861,9 +879,6 @@ generic_load (filename, from_tty)
   asection *s;
   bfd *loadfile_bfd;
 
-  if (filename == NULL)
-    filename = get_exec_file (1);
-
   loadfile_bfd = bfd_openr (filename, gnutarget);
   if (loadfile_bfd == NULL)
     {
@@ -901,7 +916,7 @@ generic_load (filename, from_tty)
              printf_filtered ("Loading section %s, size 0x%lx vma ",
                               bfd_get_section_name (loadfile_bfd, s),
                               (unsigned long) size);
-             print_address_numeric (vma, gdb_stdout);
+             print_address_numeric (vma, 1, gdb_stdout);
              printf_filtered ("\n");
 
              bfd_get_section_contents (loadfile_bfd, s, buffer, 0, size);
@@ -1010,6 +1025,22 @@ add_symbol_file_command (args, from_tty)
     error ("Not confirmed.");
 
   symbol_file_add (name, 0, text_addr, 0, mapped, readnow);
+
+  /* Getting new symbols may change our opinion about what is
+     frameless.  */
+  reinit_frame_cache ();
+}
+\f
+static void
+add_shared_symbol_files_command  (args, from_tty)
+     char *args;
+     int from_tty;
+{
+#ifdef ADD_SHARED_SYMBOL_FILES
+  ADD_SHARED_SYMBOL_FILES (args, from_tty);
+#else
+  error ("This command is not available in this configuration of GDB.");
+#endif  
 }
 \f
 /* Re-read symbols if a symbol-file has changed.  */
@@ -1052,6 +1083,7 @@ reread_symbols ()
          struct section_offsets *offsets;
          int num_offsets;
          int section_offsets_size;
+         char *obfd_filename;
 
          printf_filtered ("`%s' has changed; re-reading symbols.\n",
                           objfile->name);
@@ -1073,9 +1105,10 @@ reread_symbols ()
          /* Clean up any state BFD has sitting around.  We don't need
             to close the descriptor but BFD lacks a way of closing the
             BFD without closing the descriptor.  */
+         obfd_filename = bfd_get_filename (objfile->obfd);
          if (!bfd_close (objfile->obfd))
            error ("Can't close BFD for %s.", objfile->name);
-         objfile->obfd = bfd_openr (objfile->name, gnutarget);
+         objfile->obfd = bfd_openr (obfd_filename, gnutarget);
          if (objfile->obfd == NULL)
            error ("Can't open %s to read symbols.", objfile->name);
          /* bfd_openr sets cacheable to true, which is what we want.  */
@@ -1160,6 +1193,12 @@ reread_symbols ()
             zero is OK since dbxread.c also does what it needs to do if
             objfile->global_psymbols.size is 0.  */
          (*objfile->sf->sym_read) (objfile, objfile->section_offsets, 0);
+         if (!have_partial_symbols () && !have_full_symbols ())
+           {
+             wrap_here ("");
+             printf_filtered ("(no debugging symbols found)\n");
+             wrap_here ("");
+           }
          objfile -> flags |= OBJF_SYMS;
 
          /* We're done reading the symbol file; finish off complaints.  */
@@ -1197,14 +1236,19 @@ deduce_language_from_filename (filename)
     ; /* Get default */
   else if (0 == (c = strrchr (filename, '.')))
     ; /* Get default. */
-  else if (STREQ(c,".mod"))
-    return language_m2;
-  else if (STREQ(c,".c"))
+  else if (STREQ (c, ".c"))
     return language_c;
-  else if (STREQ (c,".cc") || STREQ (c,".C") || STREQ (c, ".cxx"))
+  else if (STREQ (c, ".cc") || STREQ (c, ".C") || STREQ (c, ".cxx")
+          || STREQ (c, ".cpp") || STREQ (c, ".cp"))
     return language_cplus;
-  else if (STREQ (c,".ch") || STREQ (c,".c186") || STREQ (c,".c286"))
+  else if (STREQ (c, ".ch") || STREQ (c, ".c186") || STREQ (c, ".c286"))
     return language_chill;
+  else if (STREQ (c, ".f") || STREQ (c, ".F"))
+    return language_fortran;
+  else if (STREQ (c, ".mod"))
+    return language_m2;
+  else if (STREQ (c, ".s") || STREQ (c, ".S"))
+    return language_asm;
 
   return language_unknown;             /* default */
 }
@@ -1567,7 +1611,7 @@ add_psymbol_to_list (name, namelength, namespace, class, list, val, language,
   SYMBOL_LANGUAGE (psym) = language;
   PSYMBOL_NAMESPACE (psym) = namespace;
   PSYMBOL_CLASS (psym) = class;
-  SYMBOL_INIT_DEMANGLED_NAME (psym, &objfile->psymbol_obstack);
+  SYMBOL_INIT_LANGUAGE_SPECIFIC (psym, language);
 }
 
 /* Add a symbol with a CORE_ADDR value to a psymtab. */
@@ -1601,7 +1645,7 @@ add_psymbol_addr_to_list (name, namelength, namespace, class, list, val,
   SYMBOL_LANGUAGE (psym) = language;
   PSYMBOL_NAMESPACE (psym) = namespace;
   PSYMBOL_CLASS (psym) = class;
-  SYMBOL_INIT_DEMANGLED_NAME (psym, &objfile->psymbol_obstack);
+  SYMBOL_INIT_LANGUAGE_SPECIFIC (psym, language);
 }
 
 #endif /* !INLINE_ADD_PSYMBOL */
@@ -1619,11 +1663,19 @@ to execute.", &cmdlist);
   c->completer = filename_completer;
 
   c = add_cmd ("add-symbol-file", class_files, add_symbol_file_command,
-   "Load the symbols from FILE, assuming FILE has been dynamically loaded.\n\
-The second argument provides the starting address of the file's text.",
+   "Usage: add-symbol-file FILE ADDR\n\
+Load the symbols from FILE, assuming FILE has been dynamically loaded.\n\
+ADDR is the starting address of the file's text.",
               &cmdlist);
   c->completer = filename_completer;
 
+  c = add_cmd ("add-shared-symbol-files", class_files,
+              add_shared_symbol_files_command,
+   "Load the symbols from shared objects in the dynamic linker's link map.",
+              &cmdlist);
+  c = add_alias_cmd ("assf", "add-shared-symbol-files", class_files, 1,
+                    &cmdlist);
+
   c = add_cmd ("load", class_files, load_command,
    "Dynamically load FILE into the running program, and record its symbols\n\
 for access from GDB.", &cmdlist);
This page took 0.027758 seconds and 4 git commands to generate.