1999-01-19 Fernando Nasser <fnasser@totem.to.cygnus.com>
[deliverable/binutils-gdb.git] / gdb / solib.c
index 7d52b6984d70b587ee8de28a386ceaafae68d2a6..c8a8ce7ec109b9b4df21d0e1103718099d75a2cd 100644 (file)
@@ -174,8 +174,7 @@ enable_break PARAMS ((void));
 static void
 info_sharedlibrary_command PARAMS ((char *, int));
 
-static int
-symbol_add_stub PARAMS ((char *));
+static int symbol_add_stub PARAMS ((PTR));
 
 static struct so_list *
 find_solib PARAMS ((struct so_list *));
@@ -186,8 +185,7 @@ first_link_map_member PARAMS ((void));
 static CORE_ADDR
 locate_base PARAMS ((void));
 
-static void
-solib_map_sections PARAMS ((struct so_list *));
+static int solib_map_sections PARAMS ((PTR));
 
 #ifdef SVR4_SHARED_LIBS
 
@@ -207,6 +205,8 @@ solib_add_common_symbols PARAMS ((struct rtc_symb *));
 
 #endif
 
+void _initialize_solib PARAMS ((void));
+
 /* 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;
@@ -224,7 +224,7 @@ LOCAL FUNCTION
 
 SYNOPSIS
 
-       static void solib_map_sections (struct so_list *so)
+       static int solib_map_sections (struct so_list *so)
 
 DESCRIPTION
 
@@ -243,10 +243,11 @@ FIXMES
        expansion stuff?).
  */
 
-static void
-solib_map_sections (so)
-     struct so_list *so;
+static int
+solib_map_sections (arg)
+     PTR arg;
 {
+  struct so_list *so = (struct so_list *) arg; /* catch_errors bogon */
   char *filename;
   char *scratch_pathname;
   int scratch_chan;
@@ -343,6 +344,8 @@ solib_map_sections (so)
 
   /* Free the file names, close the file now.  */
   do_cleanups (old_chain);
+
+  return (1);
 }
 
 #ifndef SVR4_SHARED_LIBS
@@ -409,7 +412,7 @@ solib_add_common_symbols (rtc_symp)
     }
 
   init_minimal_symbol_collection ();
-  make_cleanup (discard_minimal_symbols, 0);
+  make_cleanup ((make_cleanup_func) discard_minimal_symbols, 0);
 
   while (rtc_symp)
     {
@@ -580,7 +583,7 @@ look_for_base (fd, baseaddr)
 
   if (fd == -1
       || (exec_bfd != NULL
-         && fdmatch (fileno ((GDB_FILE *)(exec_bfd -> iostream)), fd)))
+         && fdmatch (fileno ((FILE *)(exec_bfd -> iostream)), fd)))
     {
       return (0);
     }
@@ -966,7 +969,7 @@ find_solib (so_list_ptr)
 
          if (! solib_cleanup_queued)
            {
-             make_run_cleanup (do_clear_solib);
+             make_run_cleanup (do_clear_solib, NULL);
              solib_cleanup_queued = 1;
            }
          
@@ -986,12 +989,17 @@ find_solib (so_list_ptr)
          target_read_string ((CORE_ADDR) LM_NAME (new), &buffer,
                              MAX_PATH_SIZE - 1, &errcode);
          if (errcode != 0)
-           error ("find_solib: Can't read pathname for load map: %s\n",
-                  safe_strerror (errcode));
+           {
+             warning ("find_solib: Can't read pathname for load map: %s\n",
+                      safe_strerror (errcode));
+             return (so_list_next);
+           }
          strncpy (new -> so_name, buffer, MAX_PATH_SIZE - 1);
          new -> so_name[MAX_PATH_SIZE - 1] = '\0';
          free (buffer);
-         solib_map_sections (new);
+         catch_errors (solib_map_sections, new,
+                       "Error while mapping shared library sections:\n",
+                       RETURN_MASK_ALL);
        }      
     }
   return (so_list_next);
@@ -1001,14 +1009,14 @@ find_solib (so_list_ptr)
 
 static int
 symbol_add_stub (arg)
-     char *arg;
+     PTR arg;
 {
   register struct so_list *so = (struct so_list *) arg;        /* catch_errs bogon */
   CORE_ADDR text_addr = 0;
 
   if (so -> textsection)
     text_addr = so -> textsection -> addr;
-  else
+  else if (so -> abfd != NULL)
     {
       asection *lowest_sect;
 
@@ -1032,7 +1040,7 @@ symbol_add_stub (arg)
   so -> objfile =
     symbol_file_add (so -> so_name, so -> from_tty,
                     text_addr,
-                    0, 0, 0);
+                    0, 0, 0, 0, 1);
   return (1);
 }
 
@@ -1111,7 +1119,7 @@ solib_add (arg_string, from_tty, target)
             here, otherwise we dereference a potential dangling pointer
             for each call to target_read/write_memory within this routine.  */
          update_coreops = core_ops.to_sections == target->to_sections;
-            
+                    
          /* Reallocate the target's section table including the new size.  */
          if (target -> to_sections)
            {
@@ -1166,7 +1174,7 @@ solib_add (arg_string, from_tty, target)
                }
            }
          else if (catch_errors
-                  (symbol_add_stub, (char *) so,
+                  (symbol_add_stub, so,
                    "Error while reading shared library symbols:\n",
                    RETURN_MASK_ALL))
            {
@@ -1303,6 +1311,8 @@ clear_solib()
   struct so_list *next;
   char *bfd_filename;
   
+  disable_breakpoints_in_shlibs (1);
+
   while (so_list_head)
     {
       if (so_list_head -> sections)
@@ -1319,7 +1329,7 @@ clear_solib()
       else
        /* This happens for the executable on SVR4.  */
        bfd_filename = NULL;
-      
+
       next = so_list_head -> next;
       if (bfd_filename)
        free ((PTR)bfd_filename);
@@ -1544,7 +1554,7 @@ enable_break ()
 
         This address is stored on the stack.  However, I've been unable
         to find any magic formula to find it for Solaris (appears to
-        be trivial on Linux).  Therefore, we have to try an alternate
+        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);
       if (tmp_bfd == NULL)
@@ -1703,8 +1713,8 @@ solib_create_inferior_hook()
       return;
     }
 
-#ifndef SVR4_SHARED_LIBS
-  /* Only SunOS needs the loop below, other systems should be using the
+#if !defined(SVR4_SHARED_LIBS) || defined(_SCO_DS)
+  /* SCO and SunOS need the loop below, other systems should be using the
      special shared library breakpoints and the shared library breakpoint
      service routine.
 
@@ -1723,7 +1733,8 @@ solib_create_inferior_hook()
     }
   while (stop_signal != TARGET_SIGNAL_TRAP);
   stop_soon_quietly = 0;
-  
+
+#if !defined(_SCO_DS)
   /* We are now either at the "mapping complete" breakpoint (or somewhere
      else, a condition we aren't prepared to deal with anyway), so adjust
      the PC as necessary after a breakpoint, disable the breakpoint, and
@@ -1742,6 +1753,7 @@ solib_create_inferior_hook()
 
   if (auto_solib_add)
     solib_add ((char *) 0, 0, (struct target_ops *) 0);
+#endif /* ! _SCO_DS */
 #endif
 }
 
This page took 0.025962 seconds and 4 git commands to generate.