/* Handle shared libraries for GDB, the GNU Debugger.
- Copyright 1990, 91, 92, 93, 94, 95, 96, 98, 1999, 2000
+ Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+ 2000, 2001
Free Software Foundation, Inc.
This file is part of GDB.
#include "environ.h"
#include "language.h"
#include "gdbcmd.h"
+#include "completer.h"
+#include "filenames.h" /* for DOSish file names */
#include "solist.h"
Search order:
* If path is absolute, look in SOLIB_ABSOLUTE_PREFIX.
- * If path is absolute, look for it literally (unmodified).
+ * If path is absolute or relative, look for it literally (unmodified).
* Look in SOLIB_SEARCH_PATH.
* Look in inferior's $PATH.
* Look in inferior's $LD_LIBRARY_PATH.
RETURNS
-
+
file handle for opened solib, or -1 for failure. */
int
{
int found_file = -1;
char *temp_pathname = NULL;
+ char *p = in_pathname;
+
+ while (*p && !IS_DIR_SEPARATOR (*p))
+ p++;
- if (ROOTED_P (in_pathname))
+ if (*p)
{
- if (solib_absolute_prefix == NULL)
+ if (! IS_ABSOLUTE_PATH (in_pathname) || solib_absolute_prefix == NULL)
temp_pathname = in_pathname;
else
{
- int prefix_len = strlen (solib_absolute_prefix);
+ int prefix_len = strlen (solib_absolute_prefix);
/* Remove trailing slashes from absolute prefix. */
- while (prefix_len > 0 && SLASH_P (solib_absolute_prefix[prefix_len - 1]))
+ while (prefix_len > 0
+ && IS_DIR_SEPARATOR (solib_absolute_prefix[prefix_len - 1]))
prefix_len--;
/* Cat the prefixed pathname together. */
strncpy (temp_pathname, solib_absolute_prefix, prefix_len);
temp_pathname[prefix_len] = '\0';
strcat (temp_pathname, in_pathname);
-
}
+
/* Now see if we can open it. */
found_file = open (temp_pathname, O_RDONLY, 0);
}
/* Done. If not found, tough luck. Return found_file and
(optionally) found_pathname. */
if (found_pathname != NULL && temp_pathname != NULL)
- *found_pathname = strsave (temp_pathname);
+ *found_pathname = xstrdup (temp_pathname);
return found_file;
}
catch_errors (solib_map_sections, i,
"Error while mapping shared library sections:\n",
RETURN_MASK_ALL);
- }
- /* If requested, add the shared objects' sections to the the
- TARGET's section table. */
- if (target)
- {
- int new_sections;
-
- /* Figure out how many sections we'll need to add in total. */
- new_sections = 0;
- for (i = inferior; i; i = i->next)
- new_sections += (i->sections_end - i->sections);
-
- if (new_sections > 0)
+ /* If requested, add the shared object's sections to the TARGET's
+ section table. Do this immediately after mapping the object so
+ that later nodes in the list can query this object, as is needed
+ in solib-osf.c. */
+ if (target)
{
- int space = target_resize_to_sections (target, new_sections);
-
- for (i = inferior; i; i = i->next)
+ int count = (i->sections_end - i->sections);
+ if (count > 0)
{
- int count = (i->sections_end - i->sections);
+ int space = target_resize_to_sections (target, count);
memcpy (target->to_sections + space,
i->sections,
count * sizeof (i->sections[0]));
- space += count;
}
}
}
}
arch_size = bfd_get_arch_size (exec_bfd);
- /* Default to 32-bit in case of failure (non-elf). */
+ if (arch_size == -1)
+ arch_size = bfd_arch_bits_per_address(exec_bfd);
+
+ /* Default to 32-bit in case of failure. */
if (arch_size == 32 || arch_size == -1)
{
addr_width = 8 + 4;
}
else
{
- internal_error ("%s:%d: bfd_get_arch_size() returned unknown size %d",
- __FILE__, __LINE__, arch_size);
+ internal_error (__FILE__, __LINE__,
+ "bfd_get_arch_size() returned unknown size %d",
+ arch_size);
}
update_solib_list (from_tty, 0);
printf_unfiltered ("%-*s", addr_width,
so->textsection != NULL
- ? local_hex_string_custom (
- (unsigned long) so->textsection->addr,
+ ? longest_local_hex_string_custom (
+ (LONGEST) so->textsection->addr,
addr_fmt)
: "");
printf_unfiltered ("%-*s", addr_width,
so->textsection != NULL
- ? local_hex_string_custom (
- (unsigned long) so->textsection->endaddr,
+ ? longest_local_hex_string_custom (
+ (LONGEST) so->textsection->endaddr,
addr_fmt)
: "");
printf_unfiltered ("%-12s", so->symbols_loaded ? "Yes" : "No");
TARGET_SO_SOLIB_CREATE_INFERIOR_HOOK ();
}
+/* GLOBAL FUNCTION
+
+ in_solib_dynsym_resolve_code -- check to see if an address is in
+ dynamic loader's dynamic symbol
+ resolution code
+
+ SYNOPSIS
+
+ int in_solib_dynsym_resolve_code (CORE_ADDR pc)
+
+ DESCRIPTION
+
+ Determine if PC is in the dynamic linker's symbol resolution
+ code. Return 1 if so, 0 otherwise.
+*/
+
+int
+in_solib_dynsym_resolve_code (CORE_ADDR pc)
+{
+ return TARGET_SO_IN_DYNSYM_RESOLVE_CODE (pc);
+}
/*
solib_add (args, from_tty, (struct target_ops *) 0);
}
+/* LOCAL FUNCTION
+
+ no_shared_libraries -- handle command to explicitly discard symbols
+ from shared libraries.
+
+ DESCRIPTION
+
+ Implements the command "nosharedlibrary", which discards symbols
+ that have been auto-loaded from shared libraries. Symbols from
+ shared libraries that were added by explicit request of the user
+ are not discarded. Also called from remote.c. */
+
+void
+no_shared_libraries (char *ignored, int from_tty)
+{
+ objfile_purge_solibs ();
+ do_clear_solib (NULL);
+}
void
_initialize_solib (void)
{
+ struct cmd_list_element *c;
+
add_com ("sharedlibrary", class_files, sharedlibrary_command,
"Load shared object library symbols for files matching REGEXP.");
add_info ("sharedlibrary", info_sharedlibrary_command,
"Status of loaded shared object libraries.");
+ add_com ("nosharedlibrary", class_files, no_shared_libraries,
+ "Unload all shared object library symbols.");
add_show_from_set
(add_set_cmd ("auto-solib-add", class_support, var_zinteger,
&setlist),
&showlist);
- add_show_from_set
- (add_set_cmd ("solib-absolute-prefix", class_support, var_filename,
- (char *) &solib_absolute_prefix,
- "Set prefix for loading absolute shared library symbol files.\n\
+ c = add_set_cmd ("solib-absolute-prefix", class_support, var_filename,
+ (char *) &solib_absolute_prefix,
+ "Set prefix for loading absolute shared library symbol files.\n\
For other (relative) files, you can add values using `set solib-search-path'.",
- &setlist),
- &showlist);
- add_show_from_set
- (add_set_cmd ("solib-search-path", class_support, var_string,
- (char *) &solib_search_path,
- "Set the search path for loading non-absolute shared library symbol files.\n\
-This takes precedence over the environment variables PATH and LD_LIBRARY_PATH.",
- &setlist),
- &showlist);
+ &setlist);
+ add_show_from_set (c, &showlist);
+ c->completer = filename_completer;
+ c = add_set_cmd ("solib-search-path", class_support, var_string,
+ (char *) &solib_search_path,
+ "Set the search path for loading non-absolute shared library symbol files.\n\
+This takes precedence over the environment variables PATH and LD_LIBRARY_PATH.",
+ &setlist);
+ add_show_from_set (c, &showlist);
+ c->completer = filename_completer;
}