[PATCH] Fix auto-solib-add bug (patch revised again)

fnf@ninemoons.com fnf@ninemoons.com
Tue Sep 19 14:41:00 GMT 2000


This is the third patch I've posted for this problem.  As it turns
out, the second patch was too simple and the "attach" command ignored
the value of auto-solib-add.

Neither of the previous patches have been applied yet, so they can be
ignored.

Please review and apply this patch, or let me know how it needs to be
fixed.

Thanks

-Fred

============================================================================

2000-09-19  Fred Fish  <fnf@cygnus.com>

	* symfile.h (auto_solib_add): Remove decl.
	* coff-solib.h (auto_solib_add): Add decl.
	* solib.h (auto_solib_add): Ditto.
	* somsolib.h (auto_solib_add): Ditto.

	* coff-solib.c (coff_solib_add):  Add syms if threshold is nonzero.
	* irix5-nat.c: Ditto.
	* osfsolib.c (solib_add): Ditto.
	* solib.c (solib_add): Ditto.
	* xcoffsolib.c (solib_add): Ditto.

	* irix5-nat.c (sharedlibrary_command): Pass large integer value as
	threshold arg to solib_add.
	* osfsolib.c (sharedlibrary_command;): Ditto.
	* pa64solib.c (pa64_solib_sharedlibrary_command): Ditto.
	* solib.c (sharedlibrary_command): Ditto.
	* somsolib.c (som_solib_sharedlibrary_command): Ditto.
	* xcoffsolib.c (sharedlibrary_command): Ditto.

	* coff-solib.h (coff_solib_add): Adjust prototype for new threshold arg.
	* pa64solib.c (add_to_solist): Ditto.
	* pa64solib.h (pa64_solib_add): Ditto.
	* solib.h (solib_add): Ditto.
	* somsolib.h (som_solib_add): Ditto.
	* config/i386/tm-cygwin.h (child_solib_add): Ditto.

	* coff-solib.c (coff_solib_add): Add new threshold arg.
	* irix5-nat.c (solib_add): Ditto.
	* osfsolib.c (solib_add): Ditto.
	* pa64solib.c (add_to_solist): Ditto.
	* solib.c (solib_add): Ditto.
	* somsolib.c (som_solib_add): Ditto.
	* win32-nat.c (child_solib_add): Ditto.
	* xcoffsolib.c (solib_add): Ditto.

	* coff-solib.c (coff_solib_create_inferior_hook): Call solib_add
	unconditionally with auto_solib_add.
	* irix5-nat.c (solib_create_inferior_hook): Ditto.
	* osfsolib.c (solib_create_inferior_hook): Ditto.
	* solib.c (solib_create_inferior_hook): Ditto.

	* corelow.c (solib_add_stub): Add auto_solib_add to args passed
	via SOLIB_ADD.
	* sol-thread.c (sol_thread_attach): Ditto.
	* config/rs6000/nm-rs6000.h (SOLIB_ADD): Ditto.

	* infcmd.c (attach_command): Remove auto_solib_add decl.
	Call SOLIB_ADD directly with auto_solib_add.
	* infrun.c (wait_for_inferior): Ditto.

	* coff-solib.h (SOLIB_ADD): Add threshold arg.
	* pa64solib.h (SOLIB_ADD): Ditto.
	* solib.h (SOLIB_ADD): Ditto.
	* somsolib.h (SOLIB_ADD): Ditto.
	* config/i386/tm-cygwin.h (SOLIB_ADD): Ditto.

	* fork-child.c (clone_and_follow_inferior): Remove unused
	auto_solib_add decl.

	* pa64solib.c (pa64_solib_add): Call add_to_solist with threshold.
	(read_dld_descriptor): Ditto.

Index: coff-solib.c
===================================================================
RCS file: /cvs/src/src/gdb/coff-solib.c,v
retrieving revision 1.2
diff -c -p -r1.2 coff-solib.c
*** coff-solib.c	2000/07/30 01:48:24	1.2
--- coff-solib.c	2000/09/19 21:36:02
***************
*** 41,57 ****
     SYNOPSIS
  
     void coff_solib_add (char *arg_string, int from_tty,
!    struct target_ops *target)
  
     DESCRIPTION
  
   */
  
  void
! coff_solib_add (char *arg_string, int from_tty, struct target_ops *target)
  {
    asection *libsect;
  
    libsect = bfd_get_section_by_name (exec_bfd, ".lib");
  
    if (libsect)
--- 41,60 ----
     SYNOPSIS
  
     void coff_solib_add (char *arg_string, int from_tty,
!    struct target_ops *target, int threshold)
  
     DESCRIPTION
  
   */
  
  void
! coff_solib_add (char *arg_string, int from_tty, struct target_ops *target, int threshold)
  {
    asection *libsect;
  
+   if (threshold == 0)
+     return;
+ 
    libsect = bfd_get_section_by_name (exec_bfd, ".lib");
  
    if (libsect)
*************** coff_solib_add (char *arg_string, int fr
*** 125,129 ****
  void
  coff_solib_create_inferior_hook (void)
  {
!   coff_solib_add ((char *) 0, 0, (struct target_ops *) 0);
  }
--- 128,132 ----
  void
  coff_solib_create_inferior_hook (void)
  {
!   coff_solib_add ((char *) 0, 0, (struct target_ops *) 0, auto_solib_add);
  }
Index: coff-solib.h
===================================================================
RCS file: /cvs/src/src/gdb/coff-solib.h,v
retrieving revision 1.2
diff -c -p -r1.2 coff-solib.h
*** coff-solib.h	2000/05/28 01:12:26	1.2
--- coff-solib.h	2000/09/19 21:36:02
*************** struct target_ops;
*** 30,41 ****
  extern void coff_clear_solib (void);
  #endif
  
  /* Called to add symbols from a shared library to gdb's symbol table. */
  
! #define SOLIB_ADD(filename, from_tty, targ) \
!     coff_solib_add (filename, from_tty, targ)
  
! extern void coff_solib_add (char *, int, struct target_ops *);
  
  /* Function to be called when the inferior starts up, to discover the names
     of shared libraries that are dynamically linked, the base addresses to
--- 30,53 ----
  extern void coff_clear_solib (void);
  #endif
  
+ /* Whether to auto load solibs at startup time:  0/1. 
+ 
+    On all platforms, 0 means "don't auto load".
+ 
+    On HP-UX, > 0 means a threshhold, in megabytes, of symbol table which will
+    be auto loaded.  When the cumulative size of solib symbol table exceeds
+    this threshhold, solibs' symbol tables will not be loaded.
+ 
+    On other platforms, > 0 means, "always auto load".  */
+ 
+ extern int auto_solib_add;
+ 
  /* Called to add symbols from a shared library to gdb's symbol table. */
  
! #define SOLIB_ADD(filename, from_tty, targ, threshold) \
!     coff_solib_add (filename, from_tty, targ, threshold)
  
! extern void coff_solib_add (char *, int, struct target_ops *, int);
  
  /* Function to be called when the inferior starts up, to discover the names
     of shared libraries that are dynamically linked, the base addresses to
Index: corelow.c
===================================================================
RCS file: /cvs/src/src/gdb/corelow.c,v
retrieving revision 1.9
diff -c -p -r1.9 corelow.c
*** corelow.c	2000/09/01 23:41:20	1.9
--- corelow.c	2000/09/19 21:36:02
*************** core_close_cleanup (void *ignore)
*** 219,225 ****
  static int
  solib_add_stub (PTR from_ttyp)
  {
!   SOLIB_ADD (NULL, *(int *) from_ttyp, &current_target);
    re_enable_breakpoints_in_shlibs ();
    return 0;
  }
--- 219,225 ----
  static int
  solib_add_stub (PTR from_ttyp)
  {
!   SOLIB_ADD (NULL, *(int *) from_ttyp, &current_target, auto_solib_add);
    re_enable_breakpoints_in_shlibs ();
    return 0;
  }
Index: fork-child.c
===================================================================
RCS file: /cvs/src/src/gdb/fork-child.c,v
retrieving revision 1.6
diff -c -p -r1.6 fork-child.c
*** fork-child.c	2000/09/01 23:39:11	1.6
--- fork-child.c	2000/09/19 21:36:03
*************** fork_inferior (char *exec_file, char *al
*** 380,387 ****
  void
  clone_and_follow_inferior (int child_pid, int *followed_child)
  {
-   extern int auto_solib_add;
- 
    int debugger_pid;
    int status;
    char pid_spelling[100];	/* Arbitrary but sufficient length. */
--- 380,385 ----
Index: infcmd.c
===================================================================
RCS file: /cvs/src/src/gdb/infcmd.c,v
retrieving revision 1.11
diff -c -p -r1.11 infcmd.c
*** infcmd.c	2000/09/02 00:07:13	1.11
--- infcmd.c	2000/09/19 21:36:03
*************** nofp_registers_info (char *addr_exp, int
*** 1624,1633 ****
  void
  attach_command (char *args, int from_tty)
  {
- #ifdef SOLIB_ADD
-   extern int auto_solib_add;
- #endif
- 
    char *exec_file;
    char *full_exec_path = NULL;
  
--- 1624,1629 ----
*************** attach_command (char *args, int from_tty
*** 1689,1700 ****
      }
  
  #ifdef SOLIB_ADD
!   if (auto_solib_add)
!     {
!       /* Add shared library symbols from the newly attached process, if any.  */
!       SOLIB_ADD ((char *) 0, from_tty, &current_target);
!       re_enable_breakpoints_in_shlibs ();
!     }
  #endif
  
    /* Take any necessary post-attaching actions for this platform.
--- 1685,1693 ----
      }
  
  #ifdef SOLIB_ADD
!   /* Add shared library symbols from the newly attached process, if any.  */
!   SOLIB_ADD ((char *) 0, from_tty, &current_target, auto_solib_add);
!   re_enable_breakpoints_in_shlibs ();
  #endif
  
    /* Take any necessary post-attaching actions for this platform.
Index: infrun.c
===================================================================
RCS file: /cvs/src/src/gdb/infrun.c,v
retrieving revision 1.18
diff -c -p -r1.18 infrun.c
*** infrun.c	2000/09/02 00:08:05	1.18
--- infrun.c	2000/09/19 21:36:04
*************** handle_inferior_event (struct execution_
*** 1517,1531 ****
  	      remove_breakpoints ();
  
  	    /* Check for any newly added shared libraries if we're
! 	       supposed to be adding them automatically.  */
! 	    if (auto_solib_add)
! 	      {
! 		/* Switch terminal for any messages produced by
! 		   breakpoint_re_set.  */
! 		target_terminal_ours_for_output ();
! 		SOLIB_ADD (NULL, 0, NULL);
! 		target_terminal_inferior ();
! 	      }
  
  	    /* Reinsert breakpoints and continue.  */
  	    if (breakpoints_inserted)
--- 1517,1528 ----
  	      remove_breakpoints ();
  
  	    /* Check for any newly added shared libraries if we're
! 	       supposed to be adding them automatically.  Switch
! 	       terminal for any messages produced by
! 	       breakpoint_re_set.  */
! 	    target_terminal_ours_for_output ();
! 	    SOLIB_ADD (NULL, 0, NULL, auto_solib_add);
! 	    target_terminal_inferior ();
  
  	    /* Reinsert breakpoints and continue.  */
  	    if (breakpoints_inserted)
*************** handle_inferior_event (struct execution_
*** 2438,2452 ****
  	    breakpoints_inserted = 0;
  
  	    /* Check for any newly added shared libraries if we're
! 	       supposed to be adding them automatically.  */
! 	    if (auto_solib_add)
! 	      {
! 		/* Switch terminal for any messages produced by
! 		   breakpoint_re_set.  */
! 		target_terminal_ours_for_output ();
! 		SOLIB_ADD (NULL, 0, NULL);
! 		target_terminal_inferior ();
! 	      }
  
  	    /* Try to reenable shared library breakpoints, additional
  	       code segments in shared libraries might be mapped in now. */
--- 2435,2446 ----
  	    breakpoints_inserted = 0;
  
  	    /* Check for any newly added shared libraries if we're
! 	       supposed to be adding them automatically.  Switch
! 	       terminal for any messages produced by
! 	       breakpoint_re_set.  */
! 	    target_terminal_ours_for_output ();
! 	    SOLIB_ADD (NULL, 0, NULL, auto_solib_add);
! 	    target_terminal_inferior ();
  
  	    /* Try to reenable shared library breakpoints, additional
  	       code segments in shared libraries might be mapped in now. */
Index: irix5-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/irix5-nat.c,v
retrieving revision 1.9
diff -c -p -r1.9 irix5-nat.c
*** irix5-nat.c	2000/09/11 07:36:07	1.9
--- irix5-nat.c	2000/09/19 21:36:05
*************** symbol_add_stub (void *arg)
*** 861,874 ****
     SYNOPSIS
  
     void solib_add (char *arg_string, int from_tty,
!    struct target_ops *target)
  
     DESCRIPTION
  
   */
  
  void
! solib_add (char *arg_string, int from_tty, struct target_ops *target)
  {
    register struct so_list *so = NULL;	/* link map state variable */
  
--- 861,874 ----
     SYNOPSIS
  
     void solib_add (char *arg_string, int from_tty,
!    struct target_ops *target, int threshold)
  
     DESCRIPTION
  
   */
  
  void
! solib_add (char *arg_string, int from_tty, struct target_ops *target, int threshold)
  {
    register struct so_list *so = NULL;	/* link map state variable */
  
*************** solib_add (char *arg_string, int from_tt
*** 879,884 ****
--- 879,887 ----
    int count;
    int old;
  
+   if (threshold == 0)
+     return;
+ 
    if ((re_err = re_comp (arg_string ? arg_string : ".")) != NULL)
      {
        error ("Invalid regexp: %s", re_err);
*************** solib_create_inferior_hook (void)
*** 1250,1257 ****
       and will put out an annoying warning.
       Delaying the resetting of stop_soon_quietly until after symbol loading
       suppresses the warning.  */
!   if (auto_solib_add)
!     solib_add ((char *) 0, 0, (struct target_ops *) 0);
    stop_soon_quietly = 0;
  }
  
--- 1253,1259 ----
       and will put out an annoying warning.
       Delaying the resetting of stop_soon_quietly until after symbol loading
       suppresses the warning.  */
!   solib_add ((char *) 0, 0, (struct target_ops *) 0, auto_solib_add);
    stop_soon_quietly = 0;
  }
  
*************** static void
*** 1273,1279 ****
  sharedlibrary_command (char *args, int from_tty)
  {
    dont_repeat ();
!   solib_add (args, from_tty, (struct target_ops *) 0);
  }
  
  void
--- 1275,1281 ----
  sharedlibrary_command (char *args, int from_tty)
  {
    dont_repeat ();
!   solib_add (args, from_tty, (struct target_ops *) 0, INT_MAX >> 22);
  }
  
  void
Index: osfsolib.c
===================================================================
RCS file: /cvs/src/src/gdb/osfsolib.c,v
retrieving revision 1.5
diff -c -p -r1.5 osfsolib.c
*** osfsolib.c	2000/07/30 01:48:26	1.5
--- osfsolib.c	2000/09/19 21:36:05
*************** symbol_add_stub (char *arg)
*** 596,609 ****
     SYNOPSIS
  
     void solib_add (char *arg_string, int from_tty,
!    struct target_ops *target)
  
     DESCRIPTION
  
   */
  
  void
! solib_add (char *arg_string, int from_tty, struct target_ops *target)
  {
    register struct so_list *so = NULL;	/* link map state variable */
  
--- 596,609 ----
     SYNOPSIS
  
     void solib_add (char *arg_string, int from_tty,
!    struct target_ops *target, int threshold)
  
     DESCRIPTION
  
   */
  
  void
! solib_add (char *arg_string, int from_tty, struct target_ops *target, int threshold)
  {
    register struct so_list *so = NULL;	/* link map state variable */
  
*************** solib_add (char *arg_string, int from_tt
*** 614,619 ****
--- 614,622 ----
    int count;
    int old;
  
+   if (threshold == 0)
+     return;
+ 
    if ((re_err = re_comp (arg_string ? arg_string : ".")) != NULL)
      {
        error ("Invalid regexp: %s", re_err);
*************** solib_create_inferior_hook (void)
*** 887,894 ****
       and will put out an annoying warning.
       Delaying the resetting of stop_soon_quietly until after symbol loading
       suppresses the warning.  */
!   if (auto_solib_add)
!     solib_add ((char *) 0, 0, (struct target_ops *) 0);
    stop_soon_quietly = 0;
  }
  
--- 890,896 ----
       and will put out an annoying warning.
       Delaying the resetting of stop_soon_quietly until after symbol loading
       suppresses the warning.  */
!   solib_add ((char *) 0, 0, (struct target_ops *) 0, auto_solib_add);
    stop_soon_quietly = 0;
  }
  
*************** static void
*** 911,917 ****
  sharedlibrary_command (char *args, int from_tty)
  {
    dont_repeat ();
!   solib_add (args, from_tty, (struct target_ops *) 0);
  }
  
  void
--- 913,919 ----
  sharedlibrary_command (char *args, int from_tty)
  {
    dont_repeat ();
!   solib_add (args, from_tty, (struct target_ops *) 0, INT_MAX >> 22);
  }
  
  void
Index: pa64solib.c
===================================================================
RCS file: /cvs/src/src/gdb/pa64solib.c,v
retrieving revision 1.7
diff -c -p -r1.7 pa64solib.c
*** pa64solib.c	2000/08/27 22:30:29	1.7
--- pa64solib.c	2000/09/19 21:36:05
*************** static void pa64_solib_sharedlibrary_com
*** 126,136 ****
  
  static void *pa64_target_read_memory (void *, CORE_ADDR, size_t, int);
  
! static boolean read_dld_descriptor (struct target_ops *);
  
  static boolean read_dynamic_info (asection *, dld_cache_t *);
  
! static void add_to_solist (boolean, char *, struct load_module_desc *,
  			   CORE_ADDR, struct target_ops *);
  
  /* When examining the shared library for debugging information we have to
--- 126,136 ----
  
  static void *pa64_target_read_memory (void *, CORE_ADDR, size_t, int);
  
! static boolean read_dld_descriptor (struct target_ops *, int threshold);
  
  static boolean read_dynamic_info (asection *, dld_cache_t *);
  
! static void add_to_solist (boolean, char *, int, struct load_module_desc *,
  			   CORE_ADDR, struct target_ops *);
  
  /* When examining the shared library for debugging information we have to
*************** pa64_solib_load_symbols (struct so_list 
*** 371,377 ****
     be exceeded.  */
  
  void
! pa64_solib_add (char *arg_string, int from_tty, struct target_ops *target)
  {
    struct minimal_symbol *msymbol;
    CORE_ADDR addr;
--- 371,377 ----
     be exceeded.  */
  
  void
! pa64_solib_add (char *arg_string, int from_tty, struct target_ops *target, int threshold)
  {
    struct minimal_symbol *msymbol;
    CORE_ADDR addr;
*************** pa64_solib_add (char *arg_string, int fr
*** 414,420 ****
  
    /* Read in the load map pointer if we have not done so already.  */
    if (! dld_cache.have_read_dld_descriptor)
!     if (! read_dld_descriptor (target))
        return;
  
    /* If the libraries were not mapped private, warn the user.  */
--- 414,420 ----
  
    /* Read in the load map pointer if we have not done so already.  */
    if (! dld_cache.have_read_dld_descriptor)
!     if (! read_dld_descriptor (target, threshold))
        return;
  
    /* If the libraries were not mapped private, warn the user.  */
*************** pa64_solib_add (char *arg_string, int fr
*** 438,444 ****
        if (!dll_path)
  	error ("pa64_solib_add, unable to read shared library path.");
  
!       add_to_solist (from_tty, dll_path, &dll_desc, 0, target);
      }
  }
  
--- 438,444 ----
        if (!dll_path)
  	error ("pa64_solib_add, unable to read shared library path.");
  
!       add_to_solist (from_tty, dll_path, threshold, &dll_desc, 0, target);
      }
  }
  
*************** pa64_solib_in_dynamic_linker (int pid, C
*** 699,705 ****
      return 0;
  
    if (!dld_cache.have_read_dld_descriptor)
!     if (!read_dld_descriptor (&current_target))
        return 0;
  
    return (pc >= dld_cache.dld_desc.text_base
--- 699,705 ----
      return 0;
  
    if (!dld_cache.have_read_dld_descriptor)
!     if (!read_dld_descriptor (&current_target, auto_solib_add))
        return 0;
  
    return (pc >= dld_cache.dld_desc.text_base
*************** static void
*** 817,823 ****
  pa64_solib_sharedlibrary_command (char *args, int from_tty)
  {
    dont_repeat ();
!   pa64_solib_add (args, from_tty, (struct target_ops *) 0);
  }
  
  /* Return the name of the shared library containing ADDR or NULL if ADDR
--- 817,823 ----
  pa64_solib_sharedlibrary_command (char *args, int from_tty)
  {
    dont_repeat ();
!   pa64_solib_add (args, from_tty, (struct target_ops *) 0, INT_MAX >> 22);
  }
  
  /* Return the name of the shared library containing ADDR or NULL if ADDR
*************** so_lib_thread_start_addr (struct so_list
*** 926,932 ****
     return nonzero.  */
  
  static boolean
! read_dld_descriptor (struct target_ops *target)
  {
    char *dll_path;
    asection *dyninfo_sect;
--- 926,932 ----
     return nonzero.  */
  
  static boolean
! read_dld_descriptor (struct target_ops *target, int threshold)
  {
    char *dll_path;
    asection *dyninfo_sect;
*************** read_dld_descriptor (struct target_ops *
*** 985,991 ****
  			pa64_target_read_memory, 
  			0, 
  			dld_cache.load_map);
!   add_to_solist(0, dll_path,  &dld_cache.dld_desc, 0, target);
    
    return 1;
  }
--- 985,991 ----
  			pa64_target_read_memory, 
  			0, 
  			dld_cache.load_map);
!   add_to_solist(0, dll_path, threshold, &dld_cache.dld_desc, 0, target);
    
    return 1;
  }
*************** pa64_target_read_memory (void *buffer, C
*** 1092,1098 ****
     be read from the inferior process at the address load_module_desc_addr.  */
  
  static void
! add_to_solist (boolean from_tty, char *dll_path,
  	       struct load_module_desc *load_module_desc_p,
  	       CORE_ADDR load_module_desc_addr, struct target_ops *target)
  {
--- 1092,1098 ----
     be read from the inferior process at the address load_module_desc_addr.  */
  
  static void
! add_to_solist (boolean from_tty, char *dll_path, int threshold,
  	       struct load_module_desc *load_module_desc_p,
  	       CORE_ADDR load_module_desc_addr, struct target_ops *target)
  {
*************** add_to_solist (boolean from_tty, char *d
*** 1157,1163 ****
    pa64_solib_st_size_threshhold_exceeded =
         !from_tty 
      && (  (st_size + pa64_solib_total_st_size) 
! 	> (auto_solib_add * (LONGEST)1000000));
    if (pa64_solib_st_size_threshhold_exceeded)
      {
        pa64_solib_add_solib_objfile (new_so, dll_path, from_tty, 1);
--- 1157,1163 ----
    pa64_solib_st_size_threshhold_exceeded =
         !from_tty 
      && (  (st_size + pa64_solib_total_st_size) 
! 	> (threshold * (LONGEST)1000000));
    if (pa64_solib_st_size_threshhold_exceeded)
      {
        pa64_solib_add_solib_objfile (new_so, dll_path, from_tty, 1);
Index: pa64solib.h
===================================================================
RCS file: /cvs/src/src/gdb/pa64solib.h,v
retrieving revision 1.2
diff -c -p -r1.2 pa64solib.h
*** pa64solib.h	2000/05/28 01:12:28	1.2
--- pa64solib.h	2000/09/19 21:36:05
*************** struct section_offsets;
*** 25,34 ****
  
  /* Called to add symbols from a shared library to gdb's symbol table.  */
  
! #define SOLIB_ADD(filename, from_tty, targ) \
!     pa64_solib_add (filename, from_tty, targ)
  
! extern void pa64_solib_add (char *, int, struct target_ops *);
  
  extern CORE_ADDR pa64_solib_get_got_by_pc (CORE_ADDR);
  
--- 25,34 ----
  
  /* Called to add symbols from a shared library to gdb's symbol table.  */
  
! #define SOLIB_ADD(filename, from_tty, targ, threshold) \
!     pa64_solib_add (filename, from_tty, targ, threshold)
  
! extern void pa64_solib_add (char *, int, struct target_ops *, int);
  
  extern CORE_ADDR pa64_solib_get_got_by_pc (CORE_ADDR);
  
Index: sol-thread.c
===================================================================
RCS file: /cvs/src/src/gdb/sol-thread.c,v
retrieving revision 1.16
diff -c -p -r1.16 sol-thread.c
*** sol-thread.c	2000/09/05 17:43:00	1.16
--- sol-thread.c	2000/09/19 21:36:06
*************** sol_thread_attach (char *args, int from_
*** 454,460 ****
    procfs_ops.to_attach (args, from_tty);
  
    /* Must get symbols from solibs before libthread_db can run! */
!   SOLIB_ADD ((char *) 0, from_tty, (struct target_ops *) 0);
  
    if (sol_thread_active)
      {
--- 454,460 ----
    procfs_ops.to_attach (args, from_tty);
  
    /* Must get symbols from solibs before libthread_db can run! */
!   SOLIB_ADD ((char *) 0, from_tty, (struct target_ops *) 0, auto_solib_add);
  
    if (sol_thread_active)
      {
Index: solib.c
===================================================================
RCS file: /cvs/src/src/gdb/solib.c,v
retrieving revision 1.22
diff -c -p -r1.22 solib.c
*** solib.c	2000/08/31 00:39:10	1.22
--- solib.c	2000/09/19 21:36:06
*************** update_solib_list (int from_tty, struct 
*** 1551,1557 ****
  
     SYNOPSIS
  
!    void solib_add (char *pattern, int from_tty, struct target_ops *TARGET)
  
     DESCRIPTION
  
--- 1551,1558 ----
  
     SYNOPSIS
  
!    void solib_add (char *pattern, int from_tty, struct target_ops
!    *TARGET, int threshold)
  
     DESCRIPTION
  
*************** update_solib_list (int from_tty, struct 
*** 1562,1568 ****
     FROM_TTY and TARGET are as described for update_solib_list, above.  */
  
  void
! solib_add (char *pattern, int from_tty, struct target_ops *target)
  {
    struct so_list *gdb;
  
--- 1563,1569 ----
     FROM_TTY and TARGET are as described for update_solib_list, above.  */
  
  void
! solib_add (char *pattern, int from_tty, struct target_ops *target, int threshold)
  {
    struct so_list *gdb;
  
*************** solib_add (char *pattern, int from_tty, 
*** 1596,1602 ****
  	    }
  	  else
  	    {
! 	      if (catch_errors
  		  (symbol_add_stub, gdb,
  		   "Error while reading shared library symbols:\n",
  		   RETURN_MASK_ALL))
--- 1597,1603 ----
  	    }
  	  else
  	    {
! 	      if ((threshold > 0) && catch_errors
  		  (symbol_add_stub, gdb,
  		   "Error while reading shared library symbols:\n",
  		   RETURN_MASK_ALL))
*************** solib_create_inferior_hook (void)
*** 2187,2194 ****
        warning ("shared library handler failed to disable breakpoint");
      }
  
!   if (auto_solib_add)
!     solib_add ((char *) 0, 0, (struct target_ops *) 0);
  #endif /* ! _SCO_DS */
  #endif
  }
--- 2188,2194 ----
        warning ("shared library handler failed to disable breakpoint");
      }
  
!   solib_add ((char *) 0, 0, (struct target_ops *) 0, auto_solib_add);
  #endif /* ! _SCO_DS */
  #endif
  }
*************** static void
*** 2278,2284 ****
  sharedlibrary_command (char *args, int from_tty)
  {
    dont_repeat ();
!   solib_add (args, from_tty, (struct target_ops *) 0);
  }
  
  #endif /* HAVE_LINK_H */
--- 2278,2284 ----
  sharedlibrary_command (char *args, int from_tty)
  {
    dont_repeat ();
!   solib_add (args, from_tty, (struct target_ops *) 0, INT_MAX >> 22);
  }
  
  #endif /* HAVE_LINK_H */
Index: solib.h
===================================================================
RCS file: /cvs/src/src/gdb/solib.h,v
retrieving revision 1.2
diff -c -p -r1.2 solib.h
*** solib.h	2000/05/28 01:12:29	1.2
--- solib.h	2000/09/19 21:36:06
*************** struct target_ops;
*** 28,39 ****
  
  extern void clear_solib (void);
  
  /* Called to add symbols from a shared library to gdb's symbol table. */
  
! #define SOLIB_ADD(filename, from_tty, targ) \
!     solib_add (filename, from_tty, targ)
  
! extern void solib_add (char *, int, struct target_ops *);
  
  /* Function to be called when the inferior starts up, to discover the names
     of shared libraries that are dynamically linked, the base addresses to
--- 28,51 ----
  
  extern void clear_solib (void);
  
+ /* Whether to auto load solibs at startup time:  0/1. 
+ 
+    On all platforms, 0 means "don't auto load".
+ 
+    On HP-UX, > 0 means a threshhold, in megabytes, of symbol table which will
+    be auto loaded.  When the cumulative size of solib symbol table exceeds
+    this threshhold, solibs' symbol tables will not be loaded.
+ 
+    On other platforms, > 0 means, "always auto load".  */
+ 
+ extern int auto_solib_add;
+ 
  /* Called to add symbols from a shared library to gdb's symbol table. */
  
! #define SOLIB_ADD(filename, from_tty, targ, threshold) \
!     solib_add (filename, from_tty, targ, threshold)
  
! extern void solib_add (char *, int, struct target_ops *, int);
  
  /* Function to be called when the inferior starts up, to discover the names
     of shared libraries that are dynamically linked, the base addresses to
Index: somsolib.c
===================================================================
RCS file: /cvs/src/src/gdb/somsolib.c,v
retrieving revision 1.6
diff -c -p -r1.6 somsolib.c
*** somsolib.c	2000/08/27 22:30:29	1.6
--- somsolib.c	2000/09/19 21:36:07
*************** som_solib_load_symbols (struct so_list *
*** 385,395 ****
  
  
  /* Add symbols from shared libraries into the symtab list, unless the
!    size threshold (specified by auto_solib_add, in megabytes) would
     be exceeded.  */
  
  void
! som_solib_add (char *arg_string, int from_tty, struct target_ops *target)
  {
    struct minimal_symbol *msymbol;
    struct so_list *so_list_tail;
--- 385,395 ----
  
  
  /* Add symbols from shared libraries into the symtab list, unless the
!    size threshold (specified by THRESHOLD, in megabytes) would
     be exceeded.  */
  
  void
! som_solib_add (char *arg_string, int from_tty, struct target_ops *target, int threshold)
  {
    struct minimal_symbol *msymbol;
    struct so_list *so_list_tail;
*************** som_solib_add (char *arg_string, int fro
*** 759,765 ****
        st_size = som_solib_sizeof_symbol_table (name);
        som_solib_st_size_threshold_exceeded =
  	!from_tty &&
! 	((st_size + som_solib_total_st_size) > (auto_solib_add * (LONGEST) 1000000));
  
        if (som_solib_st_size_threshold_exceeded)
  	{
--- 759,765 ----
        st_size = som_solib_sizeof_symbol_table (name);
        som_solib_st_size_threshold_exceeded =
  	!from_tty &&
! 	((st_size + som_solib_total_st_size) > (threshold * (LONGEST) 1000000));
  
        if (som_solib_st_size_threshold_exceeded)
  	{
*************** static void
*** 1458,1464 ****
  som_solib_sharedlibrary_command (char *args, int from_tty)
  {
    dont_repeat ();
!   som_solib_add (args, from_tty, (struct target_ops *) 0);
  }
  
  
--- 1458,1464 ----
  som_solib_sharedlibrary_command (char *args, int from_tty)
  {
    dont_repeat ();
!   som_solib_add (args, from_tty, (struct target_ops *) 0, INT_MAX >> 22);
  }
  
  
Index: somsolib.h
===================================================================
RCS file: /cvs/src/src/gdb/somsolib.h,v
retrieving revision 1.2
diff -c -p -r1.2 somsolib.h
*** somsolib.h	2000/05/28 01:12:29	1.2
--- somsolib.h	2000/09/19 21:36:07
*************** struct target_ops;
*** 26,37 ****
  struct objfile;
  struct section_offsets;
  
  /* Called to add symbols from a shared library to gdb's symbol table. */
  
! #define SOLIB_ADD(filename, from_tty, targ) \
!     som_solib_add (filename, from_tty, targ)
  
! extern void som_solib_add (char *, int, struct target_ops *);
  
  extern CORE_ADDR som_solib_get_got_by_pc (CORE_ADDR);
  
--- 26,49 ----
  struct objfile;
  struct section_offsets;
  
+ /* Whether to auto load solibs at startup time:  0/1. 
+ 
+    On all platforms, 0 means "don't auto load".
+ 
+    On HP-UX, > 0 means a threshhold, in megabytes, of symbol table which will
+    be auto loaded.  When the cumulative size of solib symbol table exceeds
+    this threshhold, solibs' symbol tables will not be loaded.
+ 
+    On other platforms, > 0 means, "always auto load".  */
+ 
+ extern int auto_solib_add;
+ 
  /* Called to add symbols from a shared library to gdb's symbol table. */
  
! #define SOLIB_ADD(filename, from_tty, targ, threshold) \
!     som_solib_add (filename, from_tty, targ, threshold)
  
! extern void som_solib_add (char *, int, struct target_ops *, int);
  
  extern CORE_ADDR som_solib_get_got_by_pc (CORE_ADDR);
  
Index: symfile.h
===================================================================
RCS file: /cvs/src/src/gdb/symfile.h,v
retrieving revision 1.6
diff -c -p -r1.6 symfile.h
*** symfile.h	2000/09/02 00:12:17	1.6
--- symfile.h	2000/09/19 21:36:07
*************** extern char *obconcat (struct obstack *o
*** 217,235 ****
  
  			/*   Variables   */
  
- /* whether to auto load solibs at startup time:  0/1. 
- 
-    On all platforms, 0 means "don't auto load".
- 
-    On HP-UX, > 0 means a threshhold, in megabytes, of symbol table which will
-    be auto loaded.  When the cumulative size of solib symbol table exceeds
-    this threshhold, solibs' symbol tables will not be loaded.
- 
-    On other platforms, > 0 means, "always auto load".
-  */
- 
- extern int auto_solib_add;
- 
  /* From symfile.c */
  
  extern CORE_ADDR entry_point_address (void);
--- 217,222 ----
Index: win32-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/win32-nat.c,v
retrieving revision 1.15
diff -c -p -r1.15 win32-nat.c
*** win32-nat.c	2000/08/27 04:21:35	1.15
--- win32-nat.c	2000/09/19 21:36:07
*************** out:
*** 1618,1625 ****
  }
  
  void
! child_solib_add (char *filename ATTRIBUTE_UNUSED, int from_tty ATTRIBUTE_UNUSED, struct target_ops *target)
  {
    if (core_bfd)
      {
        child_clear_solibs ();
--- 1618,1628 ----
  }
  
  void
! child_solib_add (char *filename ATTRIBUTE_UNUSED, int from_tty ATTRIBUTE_UNUSED, struct target_ops *target, int threshold)
  {
+   if (threshold == 0)
+     return;
+ 
    if (core_bfd)
      {
        child_clear_solibs ();
Index: xcoffsolib.c
===================================================================
RCS file: /cvs/src/src/gdb/xcoffsolib.c,v
retrieving revision 1.5
diff -c -p -r1.5 xcoffsolib.c
*** xcoffsolib.c	2000/07/30 01:48:28	1.5
--- xcoffsolib.c	2000/09/19 21:36:07
*************** extern int current_source_line;
*** 45,51 ****
     the section list.  */
  
  void
! solib_add (char *arg_string, int from_tty, struct target_ops *target)
  {
    char *val;
    struct vmap *vp = vmap;
--- 45,51 ----
     the section list.  */
  
  void
! solib_add (char *arg_string, int from_tty, struct target_ops *target, int threshold)
  {
    char *val;
    struct vmap *vp = vmap;
*************** solib_add (char *arg_string, int from_tt
*** 56,61 ****
--- 56,64 ----
    int loaded = 0;		/* true if any shared obj loaded */
    int matched = 0;		/* true if any shared obj matched */
  
+   if (threshold == 0)
+     return;
+ 
    if (arg_string == 0)
      re_comp (".");
    else if (val = (char *) re_comp (arg_string))
*************** sharedlibrary_command (char *args, int f
*** 207,213 ****
      (*xcoff_relocate_symtab_hook) (inferior_pid);
  
  #ifdef SOLIB_SYMBOLS_MANUAL
!   solib_add (args, from_tty, (struct target_ops *) 0);
  #endif /* SOLIB_SYMBOLS_MANUAL */
  }
  
--- 210,216 ----
      (*xcoff_relocate_symtab_hook) (inferior_pid);
  
  #ifdef SOLIB_SYMBOLS_MANUAL
!   solib_add (args, from_tty, (struct target_ops *) 0, INT_MAX >> 22);
  #endif /* SOLIB_SYMBOLS_MANUAL */
  }
  
Index: config/i386/tm-cygwin.h
===================================================================
RCS file: /cvs/src/src/gdb/config/i386/tm-cygwin.h,v
retrieving revision 1.6
diff -c -p -r1.6 tm-cygwin.h
*** tm-cygwin.h	2000/08/27 04:21:35	1.6
--- tm-cygwin.h	2000/09/19 21:36:07
*************** extern CORE_ADDR skip_trampoline_code (C
*** 31,44 ****
  #endif
  
  #define ATTACH_NO_WAIT
! #define SOLIB_ADD(filename, from_tty, targ) child_solib_add(filename, from_tty, targ)
  #define SOLIB_LOADED_LIBRARY_PATHNAME(pid) child_solib_loaded_library_pathname(pid)
  #define CLEAR_SOLIB child_clear_solibs
  #define ADD_SHARED_SYMBOL_FILES dll_symbol_command
  
  struct target_ops;
  char *cygwin_pid_to_str (int pid);
! void child_solib_add (char *, int, struct target_ops *);
  char *child_solib_loaded_library_pathname(int);
  void child_clear_solibs (void);
  void dll_symbol_command (char *, int);
--- 31,44 ----
  #endif
  
  #define ATTACH_NO_WAIT
! #define SOLIB_ADD(filename, from_tty, targ, threshold) child_solib_add(filename, from_tty, targ, threshold)
  #define SOLIB_LOADED_LIBRARY_PATHNAME(pid) child_solib_loaded_library_pathname(pid)
  #define CLEAR_SOLIB child_clear_solibs
  #define ADD_SHARED_SYMBOL_FILES dll_symbol_command
  
  struct target_ops;
  char *cygwin_pid_to_str (int pid);
! void child_solib_add (char *, int, struct target_ops *, int);
  char *child_solib_loaded_library_pathname(int);
  void child_clear_solibs (void);
  void dll_symbol_command (char *, int);
Index: config/rs6000/nm-rs6000.h
===================================================================
RCS file: /cvs/src/src/gdb/config/rs6000/nm-rs6000.h,v
retrieving revision 1.3
diff -c -p -r1.3 nm-rs6000.h
*** nm-rs6000.h	2000/06/16 21:02:22	1.3
--- nm-rs6000.h	2000/09/19 21:36:07
***************
*** 45,51 ****
  /* When a target process or core-file has been attached, we sneak in
     and figure out where the shared libraries have got to.  */
  
! #define	SOLIB_ADD(a, b, c)	\
    if (inferior_pid)	\
      /* Attach to process.  */  \
      xcoff_relocate_symtab (inferior_pid); \
--- 45,51 ----
  /* When a target process or core-file has been attached, we sneak in
     and figure out where the shared libraries have got to.  */
  
! #define	SOLIB_ADD(a, b, c, threshold)	\
    if (inferior_pid)	\
      /* Attach to process.  */  \
      xcoff_relocate_symtab (inferior_pid); \
Index: doc/ChangeLog
===================================================================
RCS file: /cvs/src/src/gdb/doc/ChangeLog,v
retrieving revision 1.49
diff -c -p -r1.49 ChangeLog
*** ChangeLog	2000/08/10 13:42:29	1.49
--- ChangeLog	2000/09/19 21:36:08
***************
*** 1,3 ****
--- 1,7 ----
+ 2000-09-18  Fred Fish  <fnf@cygnus.com>
+ 
+ 	* gdbint.texinfo (SOLIB_ADD): Document the new threshold arg.
+ 
  2000-08-10  Mark Kettenis  <kettenis@gnu.org>
  
  	* gdbint.texinfo (Overall Structure): Spelling fix.
Index: doc/gdbint.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdbint.texinfo,v
retrieving revision 1.15
diff -c -p -r1.15 gdbint.texinfo
*** gdbint.texinfo	2000/08/10 13:42:29	1.15
--- gdbint.texinfo	2000/09/19 21:36:09
*************** Defaults to @code{"/bin/sh"}.
*** 2564,2570 ****
  
  @item SOLIB_ADD (filename, from_tty, targ)
  Define this to expand into an expression that will cause the symbols in
! @var{filename} to be added to @value{GDBN}'s symbol table.
  
  @item SOLIB_CREATE_INFERIOR_HOOK
  Define this to expand into any shared-library-relocation code that you
--- 2564,2575 ----
  
  @item SOLIB_ADD (filename, from_tty, targ)
  Define this to expand into an expression that will cause the symbols in
! @var{filename} to be added to @value{GDBN}'s symbol table.  If
! @var{threshold} is zero symbols are not read but any necessary low level
! processing for @var{filename} is still done.  If @var{threshold} is
! non-zero, it is interpreted on some systems as a threshold (in MB) above
! which symbol reading is suppressed, and on all other systems as a flag
! to enable symbol reading.
  
  @item SOLIB_CREATE_INFERIOR_HOOK
  Define this to expand into any shared-library-relocation code that you


More information about the Gdb-patches mailing list