* gdb.base/attach.exp (do_attach_tests): Don't forget to kill second
[deliverable/binutils-gdb.git] / gdb / symfile.c
index c06fbd1ceeade6a25c4972313992a595f5b23436..f3108a3c70e5c2f794cc9650efa4f0ec3aaefdcc 100644 (file)
 #define O_BINARY 0
 #endif
 
-#ifdef HPUXHPPA
-
-/* Some HP-UX related globals to clear when a new "main"
-   symbol file is loaded. HP-specific.  */
-
-extern int hp_cxx_exception_support_initialized;
-#define RESET_HP_UX_GLOBALS() do {\
-                                    deprecated_hp_som_som_object_present = 0;             /* indicates HP-compiled code */        \
-                                    hp_cxx_exception_support_initialized = 0;  /* must reinitialize exception stuff */ \
-                              } while (0)
-#endif
-
-int (*ui_load_progress_hook) (const char *section, unsigned long num);
-void (*show_load_progress) (const char *section,
+int (*deprecated_ui_load_progress_hook) (const char *section, unsigned long num);
+void (*deprecated_show_load_progress) (const char *section,
                            unsigned long section_sent,
                            unsigned long section_size,
                            unsigned long total_sent,
                            unsigned long total_size);
-void (*pre_add_symbol_hook) (const char *);
-void (*post_add_symbol_hook) (void);
-void (*target_new_objfile_hook) (struct objfile *);
+void (*deprecated_pre_add_symbol_hook) (const char *);
+void (*deprecated_post_add_symbol_hook) (void);
+void (*deprecated_target_new_objfile_hook) (struct objfile *);
 
 static void clear_symtab_users_cleanup (void *ignore);
 
@@ -207,8 +195,8 @@ compare_psymbols (const void *s1p, const void *s2p)
   struct partial_symbol *const *s1 = s1p;
   struct partial_symbol *const *s2 = s2p;
 
-  return strcmp_iw_ordered (SYMBOL_NATURAL_NAME (*s1),
-                           SYMBOL_NATURAL_NAME (*s2));
+  return strcmp_iw_ordered (SYMBOL_SEARCH_NAME (*s1),
+                           SYMBOL_SEARCH_NAME (*s2));
 }
 
 void
@@ -817,8 +805,8 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd, int from_tty,
      performed, or need to read an unmapped symbol table. */
   if (from_tty || info_verbose)
     {
-      if (pre_add_symbol_hook)
-       pre_add_symbol_hook (name);
+      if (deprecated_pre_add_symbol_hook)
+       deprecated_pre_add_symbol_hook (name);
       else
        {
          printf_unfiltered ("Reading symbols from %s...", name);
@@ -883,8 +871,8 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd, int from_tty,
 
   if (from_tty || info_verbose)
     {
-      if (post_add_symbol_hook)
-       post_add_symbol_hook ();
+      if (deprecated_post_add_symbol_hook)
+       deprecated_post_add_symbol_hook ();
       else
        {
          printf_unfiltered ("done.\n");
@@ -903,13 +891,29 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd, int from_tty,
 
   new_symfile_objfile (objfile, mainline, from_tty);
 
-  if (target_new_objfile_hook)
-    target_new_objfile_hook (objfile);
+  if (deprecated_target_new_objfile_hook)
+    deprecated_target_new_objfile_hook (objfile);
 
   return (objfile);
 }
 
 
+/* Process the symbol file ABFD, as either the main file or as a
+   dynamically loaded file.
+
+   See symbol_file_add_with_addrs_or_offsets's comments for
+   details.  */
+struct objfile *
+symbol_file_add_from_bfd (bfd *abfd, int from_tty,
+                          struct section_addr_info *addrs,
+                          int mainline, int flags)
+{
+  return symbol_file_add_with_addrs_or_offsets (abfd,
+                                               from_tty, addrs, 0, 0,
+                                                mainline, flags);
+}
+
+
 /* Process a symbol file, as either the main file or as a dynamically
    loaded file.  See symbol_file_add_with_addrs_or_offsets's comments
    for details.  */
@@ -917,9 +921,8 @@ struct objfile *
 symbol_file_add (char *name, int from_tty, struct section_addr_info *addrs,
                 int mainline, int flags)
 {
-  return symbol_file_add_with_addrs_or_offsets (symfile_bfd_open (name),
-                                               from_tty, addrs, 0, 0,
-                                                mainline, flags);
+  return symbol_file_add_from_bfd (symfile_bfd_open (name), from_tty,
+                                   addrs, mainline, flags);
 }
 
 
@@ -942,10 +945,6 @@ symbol_file_add_main_1 (char *args, int from_tty, int flags)
 {
   symbol_file_add (args, from_tty, NULL, 1, flags);
 
-#ifdef HPUXHPPA
-  RESET_HP_UX_GLOBALS ();
-#endif
-
   /* Getting new symbols may change our opinion about
      what is frameless.  */
   reinit_frame_cache ();
@@ -974,9 +973,6 @@ symbol_file_clear (int from_tty)
     symfile_objfile = NULL;
     if (from_tty)
       printf_unfiltered ("No symbol file now.\n");
-#ifdef HPUXHPPA
-    RESET_HP_UX_GLOBALS ();
-#endif
 }
 
 static char *
@@ -1354,7 +1350,7 @@ add_section_size_callback (bfd *abfd, asection *asec, void *data)
 {
   bfd_size_type *sum = data;
 
-  *sum += bfd_get_section_size_before_reloc (asec);
+  *sum += bfd_get_section_size (asec);
 }
 
 /* Opaque data for load_section_callback.  */
@@ -1374,7 +1370,7 @@ load_section_callback (bfd *abfd, asection *asec, void *data)
 
   if (bfd_get_section_flags (abfd, asec) & SEC_LOAD)
     {
-      bfd_size_type size = bfd_get_section_size_before_reloc (asec);
+      bfd_size_type size = bfd_get_section_size (asec);
       if (size > 0)
        {
          char *buffer;
@@ -1440,13 +1436,14 @@ load_section_callback (bfd *abfd, asection *asec, void *data)
              args->write_count += 1;
              sent += len;
              if (quit_flag
-                 || (ui_load_progress_hook != NULL
-                     && ui_load_progress_hook (sect_name, sent)))
+                 || (deprecated_ui_load_progress_hook != NULL
+                     && deprecated_ui_load_progress_hook (sect_name, sent)))
                error ("Canceled the download");
 
-             if (show_load_progress != NULL)
-               show_load_progress (sect_name, sent, size,
-                                   args->data_count, args->total_size);
+             if (deprecated_show_load_progress != NULL)
+               deprecated_show_load_progress (sect_name, sent, size,
+                                              args->data_count,
+                                              args->total_size);
            }
          while (sent < size);
 
@@ -1768,93 +1765,6 @@ add_shared_symbol_files_command (char *args, int from_tty)
 #endif
 }
 \f
-#if 0
-/* Read inferior memory at ADDR to find the header of a loaded object file
-   and read its in-core symbols out of inferior memory.  TEMPL is a bfd
-   representing the target's format.  */
-struct objfile *
-symbol_file_add_from_memory (bfd *templ, CORE_ADDR addr, int from_tty)
-{
-  struct objfile *objf;
-  bfd *nbfd;
-  asection *sec;
-  bfd_vma loadbase;
-  struct section_addr_info *sai;
-  unsigned int i;
-
-  if (bfd_get_flavour (templ) != bfd_target_elf_flavour)
-    error ("add-symbol-file-from-memory not supported for this target");
-
-  nbfd = bfd_elf_bfd_from_remote_memory (templ, addr, &loadbase,
-                                        target_read_memory);
-  if (nbfd == NULL)
-    {
-      error ("Failed to read a valid object file image from memory.");
-      return NULL;
-    }
-
-  nbfd->filename = xstrdup ("shared object read from target memory");
-
-  if (!bfd_check_format (nbfd, bfd_object))
-    {
-      /* FIXME: should be checking for errors from bfd_close (for one thing,
-         on error it does not free all the storage associated with the
-         bfd).  */
-      bfd_close (nbfd);
-      error ("Got object file from memory but can't read symbols: %s.",
-            bfd_errmsg (bfd_get_error ()));
-      return NULL;
-    }
-
-  sai = alloc_section_addr_info (bfd_count_sections (nbfd));
-  make_cleanup (xfree, sai);
-  i = 0;
-  for (sec = nbfd->sections; sec != NULL; sec = sec->next)
-    if ((bfd_get_section_flags (nbfd, sec) & (SEC_ALLOC|SEC_LOAD)) != 0)
-      {
-       sai->other[i].addr = bfd_get_section_vma (nbfd, sec) + loadbase;
-       sai->other[i].name = (char *) bfd_get_section_name (nbfd, sec);
-       sai->other[i].sectindex = sec->index;
-       ++i;
-      }
-
-  objf = symbol_file_add_with_addrs_or_offsets (nbfd, from_tty,
-                                               sai, NULL, 0, 0, OBJF_SHARED);
-
-  /* This might change our ideas about frames already looked at.  */
-  reinit_frame_cache ();
-
-  return objf;
-}
-#endif
-
-static void
-add_symbol_file_from_memory_command (char *args, int from_tty)
-{
-#if 0
-  CORE_ADDR addr;
-  bfd *templ;
-
-  if (args == NULL)
-    error ("add-symbol-file-from-memory requires an expression argument");
-
-  addr = parse_and_eval_address (args);
-
-  /* We need some representative bfd to know the target we are looking at.  */
-  if (symfile_objfile != NULL)
-    templ = symfile_objfile->obfd;
-  else
-    templ = exec_bfd;
-  if (templ == NULL)
-    error ("\
-Must use symbol-file or exec-file before add-symbol-file-from-memory.");
-
-  symbol_file_add_from_memory (templ, addr, from_tty);
-#else
-  error ("add-symbol-file-from-memory not implemented");
-#endif
-}
-\f
 /* Re-read symbols if a symbol-file has changed.  */
 void
 reread_symbols (void)
@@ -2015,9 +1925,6 @@ reread_symbols (void)
              if (objfile == symfile_objfile)
                {
                  (*objfile->sf->sym_new_init) (objfile);
-#ifdef HPUXHPPA
-                 RESET_HP_UX_GLOBALS ();
-#endif
                }
 
              (*objfile->sf->sym_init) (objfile);
@@ -2398,8 +2305,8 @@ clear_symtab_users (void)
   set_default_breakpoint (0, 0, 0, 0);
   clear_current_source_symtab_and_line ();
   clear_pc_function_cache ();
-  if (target_new_objfile_hook)
-    target_new_objfile_hook (NULL);
+  if (deprecated_target_new_objfile_hook)
+    deprecated_target_new_objfile_hook (NULL);
 }
 
 static void
@@ -2967,7 +2874,7 @@ pc_in_unmapped_range (CORE_ADDR pc, asection *section)
   if (overlay_debugging)
     if (section && section_is_overlay (section))
       {
-       size = bfd_get_section_size_before_reloc (section);
+       size = bfd_get_section_size (section);
        if (section->lma <= pc && pc < section->lma + size)
          return 1;
       }
@@ -2987,7 +2894,7 @@ pc_in_mapped_range (CORE_ADDR pc, asection *section)
   if (overlay_debugging)
     if (section && section_is_overlay (section))
       {
-       size = bfd_get_section_size_before_reloc (section);
+       size = bfd_get_section_size (section);
        if (section->vma <= pc && pc < section->vma + size)
          return 1;
       }
@@ -3003,9 +2910,9 @@ sections_overlap (asection *a, asection *b)
   /* FIXME: need bfd *, so we can use bfd_section_vma methods. */
 
   CORE_ADDR a_start = a->vma;
-  CORE_ADDR a_end = a->vma + bfd_get_section_size_before_reloc (a);
+  CORE_ADDR a_end = a->vma + bfd_get_section_size (a);
   CORE_ADDR b_start = b->vma;
-  CORE_ADDR b_end = b->vma + bfd_get_section_size_before_reloc (b);
+  CORE_ADDR b_end = b->vma + bfd_get_section_size (b);
 
   return (a_start < b_end && b_start < a_end);
 }
@@ -3140,7 +3047,7 @@ list_overlays_command (char *args, int from_tty)
 
        vma = bfd_section_vma (objfile->obfd, osect->the_bfd_section);
        lma = bfd_section_lma (objfile->obfd, osect->the_bfd_section);
-       size = bfd_get_section_size_before_reloc (osect->the_bfd_section);
+       size = bfd_get_section_size (osect->the_bfd_section);
        name = bfd_section_name (objfile->obfd, osect->the_bfd_section);
 
        printf_filtered ("Section %s, loaded at ", name);
@@ -3480,7 +3387,7 @@ simple_overlay_update_1 (struct obj_section *osect)
   bfd *obfd = osect->objfile->obfd;
   asection *bsect = osect->the_bfd_section;
 
-  size = bfd_get_section_size_before_reloc (osect->the_bfd_section);
+  size = bfd_get_section_size (osect->the_bfd_section);
   for (i = 0; i < cache_novlys; i++)
     if (cache_ovly_table[i][VMA] == bfd_section_vma (obfd, bsect)
        && cache_ovly_table[i][LMA] == bfd_section_lma (obfd, bsect)
@@ -3541,7 +3448,7 @@ simple_overlay_update (struct obj_section *osect)
       bfd *obfd = osect->objfile->obfd;
       asection *bsect = osect->the_bfd_section;
 
-      size = bfd_get_section_size_before_reloc (osect->the_bfd_section);
+      size = bfd_get_section_size (bsect);
       for (i = 0; i < cache_novlys; i++)
        if (cache_ovly_table[i][VMA] == bfd_section_vma (obfd, bsect)
            && cache_ovly_table[i][LMA] == bfd_section_lma (obfd, bsect)
@@ -3614,13 +3521,6 @@ with the text.  SECT is a section name to be loaded at SECT_ADDR.",
               &cmdlist);
   set_cmd_completer (c, filename_completer);
 
-  c = add_cmd ("add-symbol-file-from-memory", class_files,
-              add_symbol_file_from_memory_command,
-              "\
-Load the symbols out of memory from a dynamically loaded object file.\n\
-Give an expression for the address of the file's shared object file header.",
-              &cmdlist);
-
   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.",
This page took 0.03226 seconds and 4 git commands to generate.