-solib_add (arg_string, from_tty, target)
- char *arg_string;
- int from_tty;
- struct target_ops *target;
-{
- register struct so_list *so = NULL; /* link map state variable */
-
- /* Last shared library that we read. */
- struct so_list *so_last = NULL;
-
- char *re_err;
- int count;
- int old;
-
- if ((re_err = re_comp (arg_string ? arg_string : ".")) != NULL)
- {
- error ("Invalid regexp: %s", re_err);
- }
-
- /* Add the shared library sections to the section table of the
- specified target, if any. */
- if (target)
- {
- /* Count how many new section_table entries there are. */
- so = NULL;
- count = 0;
- while ((so = find_solib (so)) != NULL)
- {
- if (so -> lm.o_path[0])
- {
- count += so -> sections_end - so -> sections;
- }
- }
-
- if (count)
- {
- /* Reallocate the target's section table including the new size. */
- if (target -> to_sections)
- {
- old = target -> to_sections_end - target -> to_sections;
- target -> to_sections = (struct section_table *)
- xrealloc ((char *)target -> to_sections,
- (sizeof (struct section_table)) * (count + old));
- }
- else
- {
- old = 0;
- target -> to_sections = (struct section_table *)
- xmalloc ((sizeof (struct section_table)) * count);
- }
- target -> to_sections_end = target -> to_sections + (count + old);
-
- /* Add these section table entries to the target's table. */
- while ((so = find_solib (so)) != NULL)
- {
- if (so -> lm.o_path[0])
- {
- count = so -> sections_end - so -> sections;
- memcpy ((char *) (target -> to_sections + old),
- so -> sections,
- (sizeof (struct section_table)) * count);
- old += count;
- }
- }
- }
- }
-
- /* Now add the symbol files. */
- while ((so = find_solib (so)) != NULL)
- {
- if (so -> lm.o_path[0] && re_exec (so -> lm.o_path))
- {
- so -> from_tty = from_tty;
- if (so -> symbols_loaded)
- {
- if (from_tty)
- {
- printf_unfiltered ("Symbols already loaded for %s\n", so -> lm.o_path);
- }
- }
- else if (catch_errors
- (symbol_add_stub, (char *) so,
- "Error while reading shared library symbols:\n",
- RETURN_MASK_ALL))
- {
- so_last = so;
- so -> symbols_loaded = 1;
- }
- }
- }
-
- /* Getting new symbols may change our opinion about what is
- frameless. */
- if (so_last)
- reinit_frame_cache ();
-}
-
-/*
-
-LOCAL FUNCTION
-
- info_sharedlibrary_command -- code for "info sharedlibrary"
-
-SYNOPSIS
-
- static void info_sharedlibrary_command ()
-
-DESCRIPTION
-
- Walk through the shared library list and print information
- about each attached library.
-*/
-
-static void
-info_sharedlibrary_command (ignore, from_tty)
- char *ignore;
- int from_tty;
-{
- register struct so_list *so = NULL; /* link map state variable */
- int header_done = 0;
-
- if (exec_bfd == NULL)
- {
- printf_unfiltered ("No exec file.\n");
- return;
- }
- while ((so = find_solib (so)) != NULL)
- {
- if (so -> lm.o_path[0])
- {
- if (!header_done)
- {
- printf_unfiltered("%-12s%-12s%-12s%s\n", "From", "To", "Syms Read",
- "Shared Object Library");
- header_done++;
- }
- printf_unfiltered ("%-12s",
- local_hex_string_custom ((unsigned long) LM_ADDR (so),
- "08l"));
- printf_unfiltered ("%-12s",
- local_hex_string_custom ((unsigned long) so -> lmend,
- "08l"));
- printf_unfiltered ("%-12s", so -> symbols_loaded ? "Yes" : "No");
- printf_unfiltered ("%s\n", so -> lm.o_path);
- }
- }
- if (so_list_head == NULL)
- {
- printf_unfiltered ("No shared libraries loaded at this time.\n");
- }
-}
-
-/*
-
-GLOBAL FUNCTION
-
- solib_address -- check to see if an address is in a shared lib
-
-SYNOPSIS
-
- int solib_address (CORE_ADDR address)
-
-DESCRIPTION
-
- Provides a hook for other gdb routines to discover whether or
- not a particular address is within the mapped address space of
- a shared library. Any address between the base mapping address
- and the first address beyond the end of the last mapping, is
- considered to be within the shared library address space, for
- our purposes.
-
- For example, this routine is called at one point to disable
- breakpoints which are in shared libraries that are not currently
- mapped in.
- */
-
-int
-solib_address (address)
- CORE_ADDR address;