From mboxrd@z Thu Jan 1 00:00:00 1970 From: Fred Fish To: gdb-patches@sources.redhat.com Cc: fnf@redhat.com Subject: [RFA] Fix a couple of auto-solib-add problems Date: Tue, 30 Oct 2001 15:35:00 -0000 Message-id: <200110302332.f9UNWjq31420@fishpond.ninemoons.com> X-SW-Source: 2001-10/msg00377.html Currently gdb has some problems with auto-solib-add. Normally auto-solib-add is on by default, but turning it off causes some side affects other than just suppressing automatic reading of shared library symbols: (1) If auto-solib-add is off gdb does not initialize some of its other low level information about shared libraries. For example, if you attach to a process that is stopped in a shared library on linux, gdb does not tell you the attached inferior is in a shared library: $ gdb-orig main (gdb) set auto-solib-add off (gdb) attach 22693 Attaching to program: main, process 22693 0x4013a544 in ?? () (gdb) after applying the attached patch, you get: $ gdb-new main (gdb) set auto-solib-add off (gdb) attach 22693 Attaching to program: main, process 22693 0x4013a544 in ?? () from /lib/i686/libc.so.6 (gdb) (2) On solaris, attaching to an inferior unconditionally reads all the shared library symbols regardless of the state of the auto-solib-add flag: $ gdb-orig main (gdb) set auto-solib-add off (gdb) attach 13294 Attaching to program `main', process 13294 Reading symbols from ./libAdd.so...done. Loaded symbols for ./libAdd.so Reading symbols from ./libSub.so...done. Loaded symbols for ./libSub.so Reading symbols from /usr/lib/libm.so.1...done. Loaded symbols for /usr/lib/libm.so.1 Reading symbols from /usr/lib/libc.so.1...done. Loaded symbols for /usr/lib/libc.so.1 Reading symbols from /usr/lib/libdl.so.1...done. Loaded symbols for /usr/lib/libdl.so.1 Reading symbols from /usr/platform/SUNW,Ultra-60/lib/libc_psr.so.1...done. Loaded symbols for /usr/platform/SUNW,Ultra-60/lib/libc_psr.so.1 0xff2971d0 in ?? () (gdb) after applying the attached patch, we get: $ gdb-new main (gdb) set auto-solib-add off (gdb) attach 13294 Attaching to program `main', process 13294 0xff2971d0 in ?? () (gdb) IMPLEMENTATION The solution is to always call the target's flavor of solib_add() and let it decide how much work it needs to do, optionally suppressing symbol table reading when auto-solib-add is on. I.E. replace sections of code like: if (auto_solib_add) SOLIB_ADD (blah, blah, blah) with SOLIB_ADD (blah, blah, blah, auto_solib_add) and change the solib_add functions from: solib_add (blah, blah, blah) { do low level stuff read symbols } to something like: solib_add (blah, blah, blah, readsyms) { do low level stuff if (!readsyms) return read symbols } The reason we add a new readsyms arg to the solib_add functions and then pass the auto_solib_add flag, rather than just having them test auto_solib_add themselves, is that there are times when we want to pass 1 instead, to force symbol table reading. An example is the implementation of the 'sharedlibrary' command where the user can explicitly load shared library symbols. Also note that for targets that use a solib_add function other than the generic one in solib.c, this change is essentially a NOP since all we are doing is calling a solib_add that immediately returns if the passed auto_solib_add flag is off, rather than not calling it at all if the flag is off. Only targets that use the solib_add function in solib.c start doing some additional low level shlib handling when auto_solib_add is off. Perhaps the other flavors of solib_add need to be fixed so they do similar work when auto_solib_add is off. This patch doesn't address that issue. -Fred ============================================================================ gdb/ChangeLog entry: 2001-10-30 Fred Fish * coff-solib.c (coff_solib_add): Add new readsyms arg. * irix5-nat.c (solib_add): Ditto. * osfsolib.c (solib_add): Ditto. * pa64solib.c (pa64_solib_add): Ditto. * pa64solib.c (add_to_solist): Ditto. * pa64solib.c (read_dld_descriptor): 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.h (coff_solib_add): Adjust prototype for new readsyms arg. * pa64solib.c (add_to_solist): Ditto. * pa64solib.c (read_dld_descriptor): 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): If readsyms is zero don't read symbols but do any other needed work for shared libs. * irix5-nat.c: Ditto. * osfsolib.c (solib_add): Ditto. * solib.c (solib_add): Ditto. * win32-nat.c (child_solib_add): Ditto. * xcoffsolib.c (solib_add): Ditto. * irix5-nat.c (sharedlibrary_command): Pass 1 as readsyms to solib_add to force reading of shared library symbols. * 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.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. * solib-osf.c (osf_solib_create_inferior_hook): Ditto. * solib-svr4.c (enable_break): Ditto. * solib-sunos.c (sunos_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 (handle_inferior_event): Ditto. * coff-solib.h (SOLIB_ADD): Add readsyms 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 readsyms. (read_dld_descriptor): Ditto. (pa64_solib_add): Call read_dld_descriptor with readsyms. (pa64_solib_in_dynamic_linker): Ditto. * corelow.c (symfile.h): Need this for auto_solib_add declaration. * sol-thread.c (symfile.h): Ditto. gdb/doc/ChangeLog entry: 2001-10-30 Fred Fish * gdbint.texinfo (SOLIB_ADD): Document additional new "readsyms" arg. Index: coff-solib.c =================================================================== RCS file: /cvs/src/src/gdb/coff-solib.c,v retrieving revision 1.4 diff -u -p -r1.4 coff-solib.c --- coff-solib.c 2001/06/28 19:54:41 1.4 +++ coff-solib.c 2001/10/30 21:35:04 @@ -43,17 +43,20 @@ SYNOPSIS void coff_solib_add (char *arg_string, int from_tty, - struct target_ops *target) + struct target_ops *target, int readsyms) DESCRIPTION */ void -coff_solib_add (char *arg_string, int from_tty, struct target_ops *target) +coff_solib_add (char *arg_string, int from_tty, struct target_ops *target, int readsyms) { asection *libsect; + if (!readsyms) + return; + libsect = bfd_get_section_by_name (exec_bfd, ".lib"); if (libsect) @@ -127,5 +130,5 @@ coff_solib_add (char *arg_string, int fr void coff_solib_create_inferior_hook (void) { - coff_solib_add ((char *) 0, 0, (struct target_ops *) 0); + 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.3 diff -u -p -r1.3 coff-solib.h --- coff-solib.h 2001/03/06 08:21:06 1.3 +++ coff-solib.h 2001/10/30 21:35:04 @@ -32,10 +32,10 @@ extern void coff_clear_solib (void); /* 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) +#define SOLIB_ADD(filename, from_tty, targ, readsyms) \ + coff_solib_add (filename, from_tty, targ, readsyms) -extern void coff_solib_add (char *, int, struct target_ops *); +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.17 diff -u -p -r1.17 corelow.c --- corelow.c 2001/05/15 00:03:36 1.17 +++ corelow.c 2001/10/30 21:35:04 @@ -37,6 +37,7 @@ #include "gdbcore.h" #include "gdbthread.h" #include "regcache.h" +#include "symfile.h" #ifndef O_BINARY #define O_BINARY 0 @@ -222,7 +223,7 @@ core_close_cleanup (void *ignore) static int solib_add_stub (PTR from_ttyp) { - SOLIB_ADD (NULL, *(int *) from_ttyp, ¤t_target); + SOLIB_ADD (NULL, *(int *) from_ttyp, ¤t_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.13 diff -u -p -r1.13 fork-child.c --- fork-child.c 2001/05/04 04:15:24 1.13 +++ fork-child.c 2001/10/30 21:35:04 @@ -388,8 +388,6 @@ fork_inferior (char *exec_file_arg, char 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. */ Index: infcmd.c =================================================================== RCS file: /cvs/src/src/gdb/infcmd.c,v retrieving revision 1.31 diff -u -p -r1.31 infcmd.c --- infcmd.c 2001/10/01 18:11:19 1.31 +++ infcmd.c 2001/10/30 21:35:05 @@ -1633,10 +1633,6 @@ nofp_registers_info (char *addr_exp, int 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; @@ -1698,12 +1694,9 @@ attach_command (char *args, int from_tty } #ifdef SOLIB_ADD - if (auto_solib_add) - { - /* Add shared library symbols from the newly attached process, if any. */ - SOLIB_ADD ((char *) 0, from_tty, ¤t_target); - re_enable_breakpoints_in_shlibs (); - } + /* Add shared library symbols from the newly attached process, if any. */ + SOLIB_ADD ((char *) 0, from_tty, ¤t_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.47 diff -u -p -r1.47 infrun.c --- infrun.c 2001/10/21 17:19:37 1.47 +++ infrun.c 2001/10/30 21:35:06 @@ -1526,15 +1526,12 @@ handle_inferior_event (struct execution_ 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 (); - } + 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) @@ -2454,15 +2451,12 @@ handle_inferior_event (struct execution_ 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 (); - } + 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.15 diff -u -p -r1.15 irix5-nat.c --- irix5-nat.c 2001/10/30 04:05:34 1.15 +++ irix5-nat.c 2001/10/30 21:35:06 @@ -862,14 +862,14 @@ symbol_add_stub (void *arg) SYNOPSIS void solib_add (char *arg_string, int from_tty, - struct target_ops *target) + struct target_ops *target, int readsyms) DESCRIPTION */ void -solib_add (char *arg_string, int from_tty, struct target_ops *target) +solib_add (char *arg_string, int from_tty, struct target_ops *target, int readsyms) { register struct so_list *so = NULL; /* link map state variable */ @@ -880,6 +880,9 @@ solib_add (char *arg_string, int from_tt int count; int old; + if (!readsyms) + return; + if ((re_err = re_comp (arg_string ? arg_string : ".")) != NULL) { error ("Invalid regexp: %s", re_err); @@ -1252,8 +1255,7 @@ solib_create_inferior_hook (void) 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); + solib_add ((char *) 0, 0, (struct target_ops *) 0, auto_solib_add); stop_soon_quietly = 0; } @@ -1275,7 +1277,7 @@ static void sharedlibrary_command (char *args, int from_tty) { dont_repeat (); - solib_add (args, from_tty, (struct target_ops *) 0); + solib_add (args, from_tty, (struct target_ops *) 0, 1); } void Index: osfsolib.c =================================================================== RCS file: /cvs/src/src/gdb/osfsolib.c,v retrieving revision 1.11 diff -u -p -r1.11 osfsolib.c --- osfsolib.c 2001/10/30 04:05:34 1.11 +++ osfsolib.c 2001/10/30 21:35:07 @@ -596,14 +596,14 @@ symbol_add_stub (char *arg) SYNOPSIS void solib_add (char *arg_string, int from_tty, - struct target_ops *target) + struct target_ops *target, int readsyms) DESCRIPTION */ void -solib_add (char *arg_string, int from_tty, struct target_ops *target) +solib_add (char *arg_string, int from_tty, struct target_ops *target, int readsyms) { register struct so_list *so = NULL; /* link map state variable */ @@ -614,6 +614,9 @@ solib_add (char *arg_string, int from_tt int count; int old; + if (!readsyms) + return; + if ((re_err = re_comp (arg_string ? arg_string : ".")) != NULL) { error ("Invalid regexp: %s", re_err); @@ -888,8 +891,7 @@ solib_create_inferior_hook (void) 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); + solib_add ((char *) 0, 0, (struct target_ops *) 0, auto_solib_add); stop_soon_quietly = 0; } @@ -912,7 +914,7 @@ static void sharedlibrary_command (char *args, int from_tty) { dont_repeat (); - solib_add (args, from_tty, (struct target_ops *) 0); + solib_add (args, from_tty, (struct target_ops *) 0, 1); } void Index: pa64solib.c =================================================================== RCS file: /cvs/src/src/gdb/pa64solib.c,v retrieving revision 1.13 diff -u -p -r1.13 pa64solib.c --- pa64solib.c 2001/10/30 17:34:30 1.13 +++ pa64solib.c 2001/10/30 21:35:07 @@ -127,11 +127,11 @@ static void pa64_solib_sharedlibrary_com static void *pa64_target_read_memory (void *, CORE_ADDR, size_t, int); -static boolean read_dld_descriptor (struct target_ops *); +static boolean read_dld_descriptor (struct target_ops *, int readsyms); static boolean read_dynamic_info (asection *, dld_cache_t *); -static void add_to_solist (boolean, char *, struct load_module_desc *, +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 @@ -372,7 +372,7 @@ pa64_solib_load_symbols (struct so_list be exceeded. */ void -pa64_solib_add (char *arg_string, int from_tty, struct target_ops *target) +pa64_solib_add (char *arg_string, int from_tty, struct target_ops *target, int readsyms) { struct minimal_symbol *msymbol; CORE_ADDR addr; @@ -415,7 +415,7 @@ pa64_solib_add (char *arg_string, int fr /* 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)) + if (! read_dld_descriptor (target, readsyms)) return; /* If the libraries were not mapped private, warn the user. */ @@ -439,7 +439,7 @@ pa64_solib_add (char *arg_string, int fr if (!dll_path) error ("pa64_solib_add, unable to read shared library path."); - add_to_solist (from_tty, dll_path, &dll_desc, 0, target); + add_to_solist (from_tty, dll_path, readsyms, &dll_desc, 0, target); } } @@ -700,7 +700,7 @@ pa64_solib_in_dynamic_linker (int pid, C return 0; if (!dld_cache.have_read_dld_descriptor) - if (!read_dld_descriptor (¤t_target)) + if (!read_dld_descriptor (¤t_target, auto_solib_add)) return 0; return (pc >= dld_cache.dld_desc.text_base @@ -818,7 +818,7 @@ static void pa64_solib_sharedlibrary_command (char *args, int from_tty) { dont_repeat (); - pa64_solib_add (args, from_tty, (struct target_ops *) 0); + pa64_solib_add (args, from_tty, (struct target_ops *) 0, 1); } /* Return the name of the shared library containing ADDR or NULL if ADDR @@ -936,7 +936,7 @@ so_lib_thread_start_addr (struct so_list return nonzero. */ static boolean -read_dld_descriptor (struct target_ops *target) +read_dld_descriptor (struct target_ops *target, int readsyms) { char *dll_path; asection *dyninfo_sect; @@ -995,7 +995,7 @@ read_dld_descriptor (struct target_ops * pa64_target_read_memory, 0, dld_cache.load_map); - add_to_solist(0, dll_path, &dld_cache.dld_desc, 0, target); + add_to_solist(0, dll_path, readsyms, &dld_cache.dld_desc, 0, target); return 1; } @@ -1102,7 +1102,7 @@ pa64_target_read_memory (void *buffer, C be read from the inferior process at the address load_module_desc_addr. */ static void -add_to_solist (boolean from_tty, char *dll_path, +add_to_solist (boolean from_tty, char *dll_path, int readsyms, struct load_module_desc *load_module_desc_p, CORE_ADDR load_module_desc_addr, struct target_ops *target) { @@ -1166,7 +1166,7 @@ add_to_solist (boolean from_tty, char *d st_size = pa64_solib_sizeof_symbol_table (dll_path); pa64_solib_st_size_threshhold_exceeded = !from_tty - && auto_solib_add + && readsyms && ( (st_size + pa64_solib_total_st_size) > (auto_solib_limit * (LONGEST) (1024 * 1024))); if (pa64_solib_st_size_threshhold_exceeded) Index: pa64solib.h =================================================================== RCS file: /cvs/src/src/gdb/pa64solib.h,v retrieving revision 1.3 diff -u -p -r1.3 pa64solib.h --- pa64solib.h 2001/03/06 08:21:11 1.3 +++ pa64solib.h 2001/10/30 21:35:07 @@ -25,10 +25,10 @@ struct section_offsets; /* 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) +#define SOLIB_ADD(filename, from_tty, targ, readsyms) \ + pa64_solib_add (filename, from_tty, targ, readsyms) -extern void pa64_solib_add (char *, int, struct target_ops *); +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.27 diff -u -p -r1.27 sol-thread.c --- sol-thread.c 2001/05/15 00:03:36 1.27 +++ sol-thread.c 2001/10/30 21:35:07 @@ -60,6 +60,7 @@ #include "gdbcmd.h" #include "gdbcore.h" #include "regcache.h" +#include "symfile.h" extern struct target_ops sol_thread_ops; /* Forward declaration */ extern struct target_ops sol_core_ops; /* Forward declaration */ @@ -415,7 +416,7 @@ sol_thread_attach (char *args, int from_ 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); + SOLIB_ADD ((char *) 0, from_tty, (struct target_ops *) 0, auto_solib_add); if (sol_thread_active) { Index: solib-osf.c =================================================================== RCS file: /cvs/src/src/gdb/solib-osf.c,v retrieving revision 1.2 diff -u -p -r1.2 solib-osf.c --- solib-osf.c 2001/06/28 10:36:19 1.2 +++ solib-osf.c 2001/10/30 21:35:07 @@ -336,8 +336,7 @@ osf_solib_create_inferior_hook (void) 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); + solib_add ((char *) 0, 0, (struct target_ops *) 0, auto_solib_add); stop_soon_quietly = 0; /* Enable breakpoints disabled (unnecessarily) by clear_solib(). */ Index: solib-sunos.c =================================================================== RCS file: /cvs/src/src/gdb/solib-sunos.c,v retrieving revision 1.1 diff -u -p -r1.1 solib-sunos.c --- solib-sunos.c 2001/10/02 23:11:20 1.1 +++ solib-sunos.c 2001/10/30 21:35:08 @@ -852,8 +852,7 @@ sunos_solib_create_inferior_hook (void) warning ("shared library handler failed to disable breakpoint"); } - if (auto_solib_add) - solib_add ((char *) 0, 0, (struct target_ops *) 0); + solib_add ((char *) 0, 0, (struct target_ops *) 0, auto_solib_add); } static void Index: solib-svr4.c =================================================================== RCS file: /cvs/src/src/gdb/solib-svr4.c,v retrieving revision 1.20 diff -u -p -r1.20 solib-svr4.c --- solib-svr4.c 2001/10/02 23:11:20 1.20 +++ solib-svr4.c 2001/10/30 21:35:08 @@ -909,7 +909,7 @@ enable_break (void) if (inferior_sos) { /* Connected to a running target. Update our shared library table. */ - solib_add (NULL, 0, NULL); + solib_add (NULL, 0, NULL, auto_solib_add); } while (inferior_sos) { Index: solib.c =================================================================== RCS file: /cvs/src/src/gdb/solib.c,v retrieving revision 1.44 diff -u -p -r1.44 solib.c --- solib.c 2001/10/30 04:05:34 1.44 +++ solib.c 2001/10/30 21:35:08 @@ -493,7 +493,8 @@ update_solib_list (int from_tty, struct SYNOPSIS - void solib_add (char *pattern, int from_tty, struct target_ops *TARGET) + void solib_add (char *pattern, int from_tty, struct target_ops + *TARGET, int readsyms) DESCRIPTION @@ -501,10 +502,13 @@ update_solib_list (int from_tty, struct match PATTERN. (If we've already read a shared object's symbol info, leave it alone.) If PATTERN is zero, read them all. + If READSYMS is 0, defer reading symbolic information until later + but still do any needed low level processing. + FROM_TTY and TARGET are as described for update_solib_list, above. */ void -solib_add (char *pattern, int from_tty, struct target_ops *target) +solib_add (char *pattern, int from_tty, struct target_ops *target, int readsyms) { struct so_list *gdb; @@ -536,7 +540,7 @@ solib_add (char *pattern, int from_tty, printf_unfiltered ("Symbols already loaded for %s\n", gdb->so_name); } - else + else if (readsyms) { if (catch_errors (symbol_add_stub, gdb, @@ -806,7 +810,7 @@ static void sharedlibrary_command (char *args, int from_tty) { dont_repeat (); - solib_add (args, from_tty, (struct target_ops *) 0); + solib_add (args, from_tty, (struct target_ops *) 0, 1); } /* LOCAL FUNCTION Index: solib.h =================================================================== RCS file: /cvs/src/src/gdb/solib.h,v retrieving revision 1.7 diff -u -p -r1.7 solib.h --- solib.h 2001/05/14 18:45:45 1.7 +++ solib.h 2001/10/30 21:35:08 @@ -31,10 +31,10 @@ 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) +#define SOLIB_ADD(filename, from_tty, targ, readsyms) \ + solib_add (filename, from_tty, targ, readsyms) -extern void solib_add (char *, int, struct target_ops *); +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.16 diff -u -p -r1.16 somsolib.c --- somsolib.c 2001/10/30 17:34:30 1.16 +++ somsolib.c 2001/10/30 21:35:09 @@ -406,7 +406,7 @@ som_solib_load_symbols (struct so_list * be exceeded. */ void -som_solib_add (char *arg_string, int from_tty, struct target_ops *target) +som_solib_add (char *arg_string, int from_tty, struct target_ops *target, int readsyms) { struct minimal_symbol *msymbol; struct so_list *so_list_tail; @@ -777,7 +777,7 @@ som_solib_add (char *arg_string, int fro st_size = som_solib_sizeof_symbol_table (name); som_solib_st_size_threshold_exceeded = !from_tty && - auto_solib_add && + readsyms && ((st_size + som_solib_total_st_size) > (auto_solib_limit * (LONGEST) (1024 * 1024))); if (som_solib_st_size_threshold_exceeded) @@ -1470,7 +1470,7 @@ static void som_solib_sharedlibrary_command (char *args, int from_tty) { dont_repeat (); - som_solib_add (args, from_tty, (struct target_ops *) 0); + som_solib_add (args, from_tty, (struct target_ops *) 0, 1); } Index: somsolib.h =================================================================== RCS file: /cvs/src/src/gdb/somsolib.h,v retrieving revision 1.3 diff -u -p -r1.3 somsolib.h --- somsolib.h 2001/03/06 08:21:17 1.3 +++ somsolib.h 2001/10/30 21:35:09 @@ -29,10 +29,10 @@ 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) +#define SOLIB_ADD(filename, from_tty, targ, readsyms) \ + som_solib_add (filename, from_tty, targ, readsyms) -extern void som_solib_add (char *, int, struct target_ops *); +extern void som_solib_add (char *, int, struct target_ops *, int); extern CORE_ADDR som_solib_get_got_by_pc (CORE_ADDR); Index: win32-nat.c =================================================================== RCS file: /cvs/src/src/gdb/win32-nat.c,v retrieving revision 1.34 diff -u -p -r1.34 win32-nat.c --- win32-nat.c 2001/10/30 17:34:30 1.34 +++ win32-nat.c 2001/10/30 21:35:09 @@ -1692,8 +1692,10 @@ out: } void -child_solib_add (char *filename ATTRIBUTE_UNUSED, int from_tty, struct target_ops *target) +child_solib_add (char *filename ATTRIBUTE_UNUSED, int from_tty, struct target_ops *target, int readsyms) { + if (!readsyms) + return; if (core_bfd) { child_clear_solibs (); Index: config/i386/tm-cygwin.h =================================================================== RCS file: /cvs/src/src/gdb/config/i386/tm-cygwin.h,v retrieving revision 1.9 diff -u -p -r1.9 tm-cygwin.h --- tm-cygwin.h 2001/10/12 04:32:16 1.9 +++ tm-cygwin.h 2001/10/30 21:35:09 @@ -32,14 +32,14 @@ extern CORE_ADDR skip_trampoline_code (C #endif #define ATTACH_NO_WAIT -#define SOLIB_ADD(filename, from_tty, targ) child_solib_add(filename, from_tty, targ) +#define SOLIB_ADD(filename, from_tty, targ, readsyms) child_solib_add(filename, from_tty, targ, readsyms) #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 (ptid_t ptid); -void child_solib_add (char *, int, struct target_ops *); +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.8 diff -u -p -r1.8 nm-rs6000.h --- nm-rs6000.h 2001/05/04 04:15:33 1.8 +++ nm-rs6000.h 2001/10/30 21:35:09 @@ -43,7 +43,7 @@ /* 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) \ +#define SOLIB_ADD(a, b, c, d) \ if (PIDGET (inferior_ptid)) \ /* Attach to process. */ \ xcoff_relocate_symtab (PIDGET (inferior_ptid)); \ Index: doc/gdbint.texinfo =================================================================== RCS file: /cvs/src/src/gdb/doc/gdbint.texinfo,v retrieving revision 1.41 diff -u -p -r1.41 gdbint.texinfo --- gdbint.texinfo 2001/10/16 01:58:07 1.41 +++ gdbint.texinfo 2001/10/30 21:35:11 @@ -4000,10 +4000,12 @@ inferior. If defined, this is the name of the shell to use to run the inferior. Defaults to @code{"/bin/sh"}. -@item SOLIB_ADD (@var{filename}, @var{from_tty}, @var{targ}) +@item SOLIB_ADD (@var{filename}, @var{from_tty}, @var{targ}, @var{readsyms}) @findex SOLIB_ADD Define this to expand into an expression that will cause the symbols in -@var{filename} to be added to @value{GDBN}'s symbol table. +@var{filename} to be added to @value{GDBN}'s symbol table. If +@var{readsyms} is zero symbols are not read but any necessary low level +processing for @var{filename} is still done. @item SOLIB_CREATE_INFERIOR_HOOK @findex SOLIB_CREATE_INFERIOR_HOOK