OSDN Git Service

Make thread messages more consistent in pass/fail cases.
[pf3gnuchains/pf3gnuchains3x.git] / gdb / solib-svr4.c
index bbe90a6..5c3938b 100644 (file)
@@ -1,5 +1,5 @@
 /* Handle SunOS and SVR4 shared libraries for GDB, the GNU Debugger.
-   Copyright 1990, 91, 92, 93, 94, 95, 96, 98, 1999, 2000
+   Copyright 1990, 91, 92, 93, 94, 95, 96, 98, 1999, 2000, 2001
    Free Software Foundation, Inc.
 
    This file is part of GDB.
@@ -82,6 +82,7 @@ static char *solib_break_names[] =
   "_r_debug_state",
   "_dl_debug_state",
   "rtld_db_dlactivity",
+  "_rtld_debug_state",
   NULL
 };
 #endif
@@ -209,7 +210,8 @@ default_svr4_fetch_link_map_offsets (void)
 
 #else
 
-  internal_error ("default_svr4_fetch_link_map_offsets called without HAVE_LINK_H defined.");
+  internal_error (__FILE__, __LINE__,
+                 "default_svr4_fetch_link_map_offsets called without HAVE_LINK_H defined.");
   return 0;
 
 #endif /* HAVE_LINK_H */
@@ -287,7 +289,6 @@ IGNORE_FIRST_LINK_MAP_ENTRY (struct so_list *so)
 
 #endif /* !SVR4_SHARED_LIBS */
 
-
 static CORE_ADDR debug_base;   /* Base of dynamic linker structures */
 static CORE_ADDR breakpoint_addr;      /* Address where end bkpt is set */
 
@@ -295,16 +296,6 @@ static CORE_ADDR breakpoint_addr;  /* Address where end bkpt is set */
 
 static int match_main (char *);
 
-/* If non-zero, this is a prefix that will be added to the front of the name
-   shared libraries with an absolute filename for loading.  */
-static char *solib_absolute_prefix = NULL;
-
-/* If non-empty, this is a search path for loading non-absolute shared library
-   symbol files.  This takes precedence over the environment variables PATH
-   and LD_LIBRARY_PATH.  */
-static char *solib_search_path = NULL;
-
-
 #ifndef SVR4_SHARED_LIBS
 
 /* Allocate the runtime common object file.  */
@@ -319,13 +310,13 @@ allocate_rt_common_objfile (void)
   memset (objfile, 0, sizeof (struct objfile));
   objfile->md = NULL;
   obstack_specify_allocation (&objfile->psymbol_cache.cache, 0, 0,
-                             xmalloc, free);
+                             xmalloc, xfree);
   obstack_specify_allocation (&objfile->psymbol_obstack, 0, 0, xmalloc,
-                             free);
+                             xfree);
   obstack_specify_allocation (&objfile->symbol_obstack, 0, 0, xmalloc,
-                             free);
+                             xfree);
   obstack_specify_allocation (&objfile->type_obstack, 0, 0, xmalloc,
-                             free);
+                             xfree);
   objfile->name = mstrsave (objfile->md, "rt_common");
 
   /* Add this file onto the tail of the linked list of other such files. */
@@ -362,7 +353,7 @@ solib_add_common_symbols (CORE_ADDR rtc_symp)
     {
       obstack_free (&rt_common_objfile->symbol_obstack, 0);
       obstack_specify_allocation (&rt_common_objfile->symbol_obstack, 0, 0,
-                                 xmalloc, free);
+                                 xmalloc, xfree);
       rt_common_objfile->minimal_symbol_count = 0;
       rt_common_objfile->msymbols = NULL;
     }
@@ -395,7 +386,7 @@ solib_add_common_symbols (CORE_ADDR rtc_symp)
 
          prim_record_minimal_symbol (name, inferior_rtc_nlist.n_value,
                                      mst_bss, rt_common_objfile);
-         free (name);
+         xfree (name);
        }
       rtc_symp = SOLIB_EXTRACT_ADDRESS (inferior_rtc_symb.rtc_next);
     }
@@ -450,7 +441,7 @@ bfd_lookup_symbol (bfd *abfd, char *symname)
   if (storage_needed > 0)
     {
       symbol_table = (asymbol **) xmalloc (storage_needed);
-      back_to = make_cleanup (free, (PTR) symbol_table);
+      back_to = make_cleanup (xfree, (PTR) symbol_table);
       number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table);
 
       for (i = 0; i < number_of_symbols; i++)
@@ -477,7 +468,7 @@ bfd_lookup_symbol (bfd *abfd, char *symname)
   if (storage_needed > 0)
     {
       symbol_table = (asymbol **) xmalloc (storage_needed);
-      back_to = make_cleanup (free, (PTR) symbol_table);
+      back_to = make_cleanup (xfree, (PTR) symbol_table);
       number_of_symbols = bfd_canonicalize_dynamic_symtab (abfd, symbol_table);
 
       for (i = 0; i < number_of_symbols; i++)
@@ -864,7 +855,7 @@ first_link_map_member (void)
 #else /* SVR4_SHARED_LIBS */
   struct link_map_offsets *lmo = SVR4_FETCH_LINK_MAP_OFFSETS ();
   char *r_map_buf = xmalloc (lmo->r_map_size);
-  struct cleanup *cleanups = make_cleanup (free, r_map_buf);
+  struct cleanup *cleanups = make_cleanup (xfree, r_map_buf);
 
   read_memory (debug_base + lmo->r_map_offset, r_map_buf, lmo->r_map_size);
 
@@ -913,7 +904,7 @@ open_symbol_file_object (void *from_ttyp)
   int from_tty = *(int *)from_ttyp;
   struct link_map_offsets *lmo = SVR4_FETCH_LINK_MAP_OFFSETS ();
   char *l_name_buf = xmalloc (lmo->l_name_size);
-  struct cleanup *cleanups = make_cleanup (free, l_name_buf);
+  struct cleanup *cleanups = make_cleanup (xfree, l_name_buf);
 
   if (symfile_objfile)
     if (!query ("Attempt to reload symbols from process? "))
@@ -948,9 +939,9 @@ open_symbol_file_object (void *from_ttyp)
       return 0;
     }
 
-  make_cleanup (free, filename);
+  make_cleanup (xfree, filename);
   /* Have a pathname: read the symbol file.  */
-  symbol_file_command (filename, from_tty);
+  symbol_file_add_main (filename, from_tty);
 
   return 1;
 }
@@ -1011,15 +1002,15 @@ svr4_current_sos (void)
       struct link_map_offsets *lmo = SVR4_FETCH_LINK_MAP_OFFSETS ();
       struct so_list *new
        = (struct so_list *) xmalloc (sizeof (struct so_list));
-      struct cleanup *old_chain = make_cleanup (free, new);
+      struct cleanup *old_chain = make_cleanup (xfree, new);
 
       memset (new, 0, sizeof (*new));
 
       new->lm_info = xmalloc (sizeof (struct lm_info));
-      make_cleanup (free, new->lm_info);
+      make_cleanup (xfree, new->lm_info);
 
       new->lm_info->lm = xmalloc (lmo->link_map_size);
-      make_cleanup (free, new->lm_info->lm);
+      make_cleanup (xfree, new->lm_info->lm);
       memset (new->lm_info->lm, 0, lmo->link_map_size);
 
       read_memory (lm, new->lm_info->lm, lmo->link_map_size);
@@ -1050,7 +1041,7 @@ svr4_current_sos (void)
            {
              strncpy (new->so_name, buffer, SO_NAME_MAX_PATH_SIZE - 1);
              new->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0';
-             free (buffer);
+             xfree (buffer);
              strcpy (new->so_original_name, new->so_name);
            }
 
@@ -1269,7 +1260,9 @@ enable_break (void)
       unsigned int interp_sect_size;
       char *buf;
       CORE_ADDR load_addr;
-      bfd *tmp_bfd;
+      bfd *tmp_bfd = NULL;
+      int tmp_fd = -1;
+      char *tmp_pathname = NULL;
       CORE_ADDR sym_addr = 0;
 
       /* Read the contents of the .interp section into a local buffer;
@@ -1287,7 +1280,11 @@ enable_break (void)
          to find any magic formula to find it for Solaris (appears to
          be trivial on GNU/Linux).  Therefore, we have to try an alternate
          mechanism to find the dynamic linker's base address.  */
-      tmp_bfd = bfd_openr (buf, gnutarget);
+
+      tmp_fd  = solib_open (buf, &tmp_pathname);
+      if (tmp_fd >= 0)
+       tmp_bfd = bfd_fdopenr (tmp_pathname, gnutarget, tmp_fd);
+
       if (tmp_bfd == NULL)
        goto bkpt_at_symbol;
 
@@ -1527,7 +1524,7 @@ svr4_relocate_main_executable (void)
 
       new_offsets = xcalloc (sizeof (struct section_offsets),
                             symfile_objfile->num_sections);
-      old_chain = make_cleanup (free, new_offsets);
+      old_chain = make_cleanup (xfree, new_offsets);
 
       for (i = 0; i < symfile_objfile->num_sections; i++)
        {
@@ -1672,8 +1669,8 @@ svr4_clear_solib (void)
 static void
 svr4_free_so (struct so_list *so)
 {
-  free (so->lm_info->lm);
-  free (so->lm_info);
+  xfree (so->lm_info->lm);
+  xfree (so->lm_info);
 }
 
 static void