22 #include <sys/types.h> 38 #include "filenames.h" 42 #include "readline/readline.h" 103 "shared library symbol files is %s.\n"),
108 #if (HAVE_DOS_BASED_FILE_SYSTEM) 109 # define DOS_BASED_FILE_SYSTEM 1 111 # define DOS_BASED_FILE_SYSTEM 0 156 char *temp_pathname = NULL;
160 int prefix_len, orig_prefix_len;
172 prefix_len = orig_prefix_len = strlen (sysroot);
174 while (prefix_len > 0 && IS_DIR_SEPARATOR (sysroot[prefix_len - 1]))
179 else if (prefix_len != orig_prefix_len)
194 p = (
char *) alloca (strlen (in_pathname) + 1);
195 strcpy (p, in_pathname);
218 temp_pathname = xstrdup (in_pathname);
221 int need_dir_separator;
240 need_dir_separator = !(IS_DIR_SEPARATOR (in_pathname[0])
244 temp_pathname = concat (sysroot,
246 in_pathname, (
char *) NULL);
255 return temp_pathname;
261 xfree (temp_pathname);
272 int need_dir_separator = !IS_DIR_SEPARATOR (in_pathname[2]);
275 temp_pathname = concat (sysroot,
279 in_pathname + 2, (
char *) NULL);
285 xfree (temp_pathname);
293 temp_pathname = concat (sysroot,
295 in_pathname + 2, (
char *) NULL);
299 xfree (temp_pathname);
311 temp_pathname = NULL;
333 in_pathname, O_RDONLY |
O_BINARY, &temp_pathname);
343 O_RDONLY |
O_BINARY, &temp_pathname);
347 if (is_solib && found_file < 0 && ops->find_and_open_solib)
352 if (found_file < 0 && sysroot == NULL)
355 O_RDONLY |
O_BINARY, &temp_pathname);
359 if (is_solib && found_file < 0 && sysroot == NULL)
363 O_RDONLY |
O_BINARY, &temp_pathname);
373 return temp_pathname;
387 if (in_pathname == NULL)
398 new_pathname = (
char *) alloca (strlen (in_pathname) + 5);
399 strcpy (new_pathname, in_pathname);
400 strcat (new_pathname,
".exe");
416 result = xstrdup (in_pathname);
435 const char *solib_symbols_extension
440 if (solib_symbols_extension != NULL)
442 const char *p = in_pathname + strlen (in_pathname);
444 while (p > in_pathname && *p !=
'.')
452 = (
char *) alloca (p - in_pathname + 1
453 + strlen (solib_symbols_extension) + 1);
454 memcpy (new_pathname, in_pathname, p - in_pathname + 1);
455 strcpy (new_pathname + (p - in_pathname) + 1,
456 solib_symbols_extension);
458 in_pathname = new_pathname;
479 bfd_set_cacheable (abfd.
get (), 1);
484 error (
_(
"Could not open `%s' as an executable file: %s"),
485 pathname, bfd_errmsg (bfd_get_error ()));
498 char *found_pathname;
500 const struct bfd_arch_info *b;
503 found_pathname =
solib_find (pathname, &found_file);
504 if (found_pathname == NULL)
518 if (!bfd_check_format (abfd.
get (), bfd_object))
519 error (
_(
"`%s': not in executable format: %s"),
520 bfd_get_filename (abfd), bfd_errmsg (bfd_get_error ()));
524 if (!b->compatible (b, bfd_get_arch_info (abfd.
get ())))
525 warning (
_(
"`%s': Shared library architecture %s is not compatible " 526 "with target architecture %s."), bfd_get_filename (abfd),
527 bfd_get_arch_info (abfd.
get ())->printable_name,
567 error (
_(
"Shared library file name is too long."));
572 error (
_(
"Can't find the file sections in `%s': %s"),
573 bfd_get_filename (so->
abfd), bfd_errmsg (bfd_get_error ()));
576 for (p = so->
sections; p < so->sections_end; p++)
682 else if (so->
abfd == NULL)
719 " library symbols for %s:\n"),
771 "Error reading attached " 772 "process's symbol file.\n");
835 gdb_link = &
gdb->next;
847 xstrdup (
gdb->so_name));
849 *gdb_link =
gdb->next;
871 const char *not_found_filename = NULL;
891 if (not_found_filename == NULL)
899 _(
"Error while mapping shared " 900 "library sections:\n"));
917 warning (
_(
"Could not load shared library symbols for %s.\n" 918 "Do you need \"set solib-search-path\" " 919 "or \"set sysroot\"?"),
921 else if (not_found > 1)
923 Could not load shared library symbols for %d libraries, e.g. %s.\n\ 924 Use the \"info sharedlibrary\" command to see the complete listing.\n\ 925 Do you need \"set solib-search-path\" or \"set sysroot\"?"),
926 not_found, not_found_filename);
940 return (strstr (
name,
"/libpthread") != NULL);
961 solib_add (
const char *pattern,
int from_tty,
int readsyms)
980 char *re_err =
re_comp (pattern);
983 error (
_(
"Invalid regexp: %s"), re_err);
993 int loaded_any_symbols = 0;
1000 if (! pattern || re_exec (
gdb->so_name))
1007 const int add_this_solib =
1013 if (
gdb->symbols_loaded)
1022 loaded_any_symbols = 1;
1026 if (loaded_any_symbols)
1029 if (from_tty && pattern && ! any_matches)
1031 (
"No loaded shared libraries match the pattern `%s'.\n", pattern);
1033 if (loaded_any_symbols)
1051 int so_missing_debug_info = 0;
1059 char *re_err =
re_comp (pattern);
1062 error (
_(
"Invalid regexp: %s"), re_err);
1077 if (pattern && ! re_exec (so->
so_name))
1098 if (pattern && ! re_exec (so->
so_name))
1118 so_missing_debug_info = 1;
1133 uiout->
message (
_(
"No shared libraries matched.\n"));
1135 uiout->
message (
_(
"No shared libraries loaded at this time.\n"));
1139 if (so_missing_debug_info)
1140 uiout->
message (
_(
"(*): Shared library is missing " 1141 "debugging information.\n"));
1153 for (p = solib->
sections; p < solib->sections_end; p++)
1316 char *found_pathname = NULL;
1327 found_pathname = bfd_get_filename (
abfd.get ());
1331 if ((found_pathname == NULL && was_loaded)
1332 || (found_pathname != NULL
1333 && filename_cmp (found_pathname, so->
so_name) != 0))
1344 if (found_pathname != NULL
1346 || filename_cmp (found_pathname, so->
so_name) != 0))
1358 _(
"Error while mapping " 1359 "shared library sections:\n"));
1430 const char *old_prefix =
"remote:";
1435 static int warning_issued = 0;
1437 gdb_assert (strlen (old_prefix) == strlen (new_prefix));
1438 memcpy (
gdb_sysroot, new_prefix, strlen (new_prefix));
1440 if (!warning_issued)
1442 warning (
_(
"\"%s\" is deprecated, use \"%s\" instead."),
1443 old_prefix, new_prefix);
1484 int (*match_sym) (
const asymbol *,
1488 long storage_needed = bfd_get_symtab_upper_bound (abfd);
1491 if (storage_needed > 0)
1495 asymbol **symbol_table = (asymbol **)
xmalloc (storage_needed);
1497 unsigned int number_of_symbols =
1498 bfd_canonicalize_symtab (abfd, symbol_table);
1500 for (i = 0; i < number_of_symbols; i++)
1502 asymbol *sym = *symbol_table++;
1504 if (match_sym (sym, data))
1507 symaddr = sym->value;
1515 if (bfd_get_flavour (abfd) == bfd_target_elf_flavour
1520 memset (&msym, 0,
sizeof (msym));
1527 symaddr += sym->section->vma;
1544 int (*match_sym) (
const asymbol *,
1548 long storage_needed = bfd_get_dynamic_symtab_upper_bound (abfd);
1551 if (storage_needed > 0)
1554 asymbol **symbol_table = (asymbol **)
xmalloc (storage_needed);
1556 unsigned int number_of_symbols =
1557 bfd_canonicalize_dynamic_symtab (abfd, symbol_table);
1559 for (i = 0; i < number_of_symbols; i++)
1561 asymbol *sym = *symbol_table++;
1563 if (match_sym (sym, data))
1566 symaddr = sym->value + sym->section->vma;
1583 int (*match_sym) (
const asymbol *,
const void *),
1621 _(
"Load shared object library symbols for files matching REGEXP."));
1623 _(
"Status of loaded shared object libraries."));
1626 _(
"Unload all shared object library symbols."));
1630 Set autoloading of shared library symbols."),
_(
"\ 1631 Show autoloading of shared library symbols."),
_(
"\ 1632 If \"on\", symbols from all shared object libraries will be loaded\n\ 1633 automatically when the inferior begins execution, when the dynamic linker\n\ 1634 informs gdb that a new library has been loaded, or when attaching to the\n\ 1635 inferior. Otherwise, symbols must be loaded manually, using \ 1643 Set an alternate system root."),
_(
"\ 1644 Show the current system root."),
_(
"\ 1645 The system root is used to load absolute shared library symbol files.\n\ 1646 For other (relative) files, you can add directories using\n\ 1647 `set solib-search-path'."),
1659 Set the search path for loading non-absolute shared library symbol files."),
1661 Show the search path for loading non-absolute shared library symbol files."),
1663 This takes precedence over the environment variables \ 1664 PATH and LD_LIBRARY_PATH."),
struct gdbarch * target_gdbarch(void)
#define IS_TARGET_ABSOLUTE_PATH(kind, p)
int in_solib_dynsym_resolve_code(CORE_ADDR pc)
void no_shared_libraries(const char *ignored, int from_tty)
void handle_solib_event(void)
void remove_solib_event_breakpoints(void)
int source_full_path_of(const char *, char **)
#define HAS_TARGET_DRIVE_SPEC(kind, p)
struct target_section * sections
struct observer * observer_attach_free_objfile(observer_free_objfile_ftype *f)
void field_core_addr(const char *fldname, struct gdbarch *gdbarch, CORE_ADDR address)
gdb_bfd_ref_ptr solib_bfd_fopen(char *pathname, int fd)
static const struct target_so_ops * solib_ops(struct gdbarch *gdbarch)
void field_string(const char *fldname, const char *string)
CORE_ADDR gdb_bfd_lookup_symbol_from_symtab(bfd *abfd, int(*match_sym)(const asymbol *, const void *), const void *data)
static int solib_used(const struct so_list *const known)
void set_solib_ops(struct gdbarch *gdbarch, const struct target_so_ops *new_ops)
void warning(const char *fmt,...)
int objfile_has_symbols(struct objfile *objfile)
#define SET_MSYMBOL_VALUE_ADDRESS(symbol, new_value)
int gdbarch_ptr_bit(struct gdbarch *gdbarch)
void(* update_breakpoints)(void)
int build_section_table(struct bfd *some_bfd, struct target_section **start, struct target_section **end)
void field_skip(const char *fldname)
enum domain_enum_tag domain_enum
#define IS_TARGET_DIR_SEPARATOR(kind, c)
struct cmd_list_element * add_info(const char *name, cmd_const_cfunc_ftype *fun, const char *doc)
void(* relocate_section_addresses)(struct so_list *so, struct target_section *)
void * memset(T *s, int c, size_t n)=delete
void(* solib_create_inferior_hook)(int from_tty)
struct ui_out * interp_ui_out(struct interp *interp)
void table_header(int width, ui_align align, const std::string &col_name, const std::string &col_hdr)
struct so_list *(* current_sos)(void)
static void sharedlibrary_command(const char *args, int from_tty)
#define VEC_safe_push(T, V, O)
struct gdbarch_data * gdbarch_data_register_pre_init(gdbarch_data_pre_init_ftype *pre_init)
#define SO_NAME_MAX_PATH_SIZE
void _initialize_solib(void)
static void gdb_sysroot_changed(const char *ignored, int from_tty, struct cmd_list_element *e)
int(* keep_data_in_core)(CORE_ADDR vaddr, unsigned long size)
void free_section_addr_info(struct section_addr_info *sap)
int(* find_and_open_solib)(const char *soname, unsigned o_flags, char **temp_pathname)
void text(const char *string)
static int solib_map_sections(struct so_list *so)
void gdbarch_elf_make_msymbol_special(struct gdbarch *gdbarch, asymbol *sym, struct minimal_symbol *msym)
gdb_bfd_ref_ptr(* bfd_open)(char *pathname)
struct target_section * sections_end
#define TARGET_SYSROOT_PREFIX
static char * solib_find_1(const char *in_pathname, int *fd, int is_solib)
const char file_system_kind_dos_based[]
mach_port_t kern_return_t mach_port_t msgports mach_port_t kern_return_t pid_t pid mach_port_t kern_return_t mach_port_t task mach_port_t kern_return_t int flags
void null_cleanup(void *arg)
void(* clear_solib)(void)
#define MSYMBOL_VALUE_RAW_ADDRESS(symbol)
struct so_list * master_so_list(void)
struct cmd_list_element * setlist
int(* in_dynsym_resolve_code)(CORE_ADDR pc)
struct objfile * symbol_file_add_from_bfd(bfd *abfd, const char *name, symfile_add_flags add_flags, struct section_addr_info *addrs, objfile_flags flags, struct objfile *parent)
void breakpoint_re_set(void)
gdb_bfd_ref_ptr gdb_bfd_open(const char *name, const char *target, int fd)
#define CATCH(EXCEPTION, MASK)
int solib_contains_address_p(const struct so_list *const solib, CORE_ADDR address)
#define OPF_TRY_CWD_FIRST
const char * target_lbasename(const char *kind, const char *name)
std::unique_ptr< T, xfree_deleter< T > > unique_xmalloc_ptr
void gdb_bfd_unref(struct bfd *abfd)
void solib_add(const char *pattern, int from_tty, int readsyms)
void observer_notify_solib_unloaded(struct so_list *solib)
void fprintf_filtered(struct ui_file *stream, const char *format,...)
int openp(const char *, int, const char *, int, char **)
static void reload_shared_libraries(const char *ignored, int from_tty, struct cmd_list_element *e)
#define DOS_BASED_FILE_SYSTEM
struct block_symbol(* lookup_lib_global_symbol)(struct objfile *objfile, const char *name, const domain_enum domain)
void remove_target_sections(void *owner)
struct cmd_list_element * showlist
#define target_filesystem_is_local()
char so_original_name[SO_NAME_MAX_PATH_SIZE]
void free_so(struct so_list *so)
struct cleanup * make_cleanup(make_cleanup_ftype *function, void *arg)
void clear_program_space_solib_cache(struct program_space *pspace)
void(* handle_event)(void)
char * solib_name_from_address(struct program_space *pspace, CORE_ADDR address)
static struct gdbarch_data * solib_data
char so_name[SO_NAME_MAX_PATH_SIZE]
void(* clear_so)(struct so_list *so)
int(* same)(struct so_list *gdb, struct so_list *inferior)
void exception_fprintf(struct ui_file *file, struct gdb_exception e, const char *prefix,...)
symfile_add_flags symfile_flags
static int startswith(const char *string, const char *pattern)
void disable_breakpoints_in_shlibs(void)
#define target_has_execution
static char * solib_search_path
void printf_unfiltered(const char *format,...)
CORE_ADDR gdb_bfd_lookup_symbol(bfd *abfd, int(*match_sym)(const asymbol *, const void *), const void *data)
unsigned solib_add_generation
struct bfd_section * the_bfd_section
const char * objfile_name(const struct objfile *objfile)
struct program_space * pspace
static void ours_for_output()
struct cmd_list_element * add_alias_cmd(const char *name, cmd_list_element *old, enum command_class theclass, int abbrev_flag, struct cmd_list_element **list)
void update_solib_list(int from_tty)
static void remove_user_added_objfile(struct objfile *objfile)
void objfile_purge_solibs(void)
int(* open_symbol_file_object)(int from_ttyp)
const char * effective_target_file_system_kind(void)
static void show_solib_search_path(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
void void void void void void void void void perror_with_name(const char *string) ATTRIBUTE_NORETURN
char * solib_find(const char *in_pathname, int *fd)
static CORE_ADDR bfd_lookup_symbol_from_dyn_symtab(bfd *abfd, int(*match_sym)(const asymbol *, const void *), const void *data)
void(* free_so)(struct so_list *so)
void add_target_sections(void *owner, struct target_section *sections, struct target_section *sections_end)
void solib_create_inferior_hook(int from_tty)
int libpthread_name_p(const char *name)
void add_setshow_boolean_cmd(const char *name, enum command_class theclass, int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
char * exec_file_find(const char *in_pathname, int *fd)
#define OPF_RETURN_REALPATH
int print_symbol_loading_p(int from_tty, int exec, int full)
const char * gdbarch_solib_symbols_extension(struct gdbarch *gdbarch)
struct section_addr_info * build_section_addr_info_from_section_table(const struct target_section *start, const struct target_section *end)
int gdbarch_elf_make_msymbol_special_p(struct gdbarch *gdbarch)
struct target_so_ops * current_target_so_ops
void message(const char *format,...) ATTRIBUTE_PRINTF(2
struct block_symbol solib_global_lookup(struct objfile *objfile, const char *name, const domain_enum domain)
int gdb_open_cloexec(const char *filename, int flags, unsigned long mode)
int ptid_equal(const ptid_t &ptid1, const ptid_t &ptid2)
struct inferior * current_inferior(void)
struct cmd_list_element * add_info_alias(const char *name, const char *oldname, int abbrev_flag)
EXTERN_C char * re_comp(const char *)
struct program_space * current_program_space
char * savestring(const char *ptr, size_t len)
static void * solib_init(struct obstack *obstack)
struct interp * top_level_interpreter(void)
void add_setshow_optional_filename_cmd(const char *name, enum command_class theclass, char **var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
void update_solib_breakpoints(void)
void observer_notify_solib_loaded(struct so_list *solib)
const struct bfd_arch_info * gdbarch_bfd_arch_info(struct gdbarch *gdbarch)
int solib_read_symbols(struct so_list *so, symfile_add_flags flags)
#define OBSTACK_ZALLOC(OBSTACK, TYPE)
gdb_bfd_ref_ptr solib_bfd_open(char *pathname)
void reinit_frame_cache(void)
static void reload_shared_libraries_1(int from_tty)
#define ALL_OBJFILES(obj)
struct cmd_list_element * add_com(const char *name, enum command_class theclass, cmd_const_cfunc_ftype *fun, const char *doc)
static void show_auto_solib_add(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
static int libpthread_solib_p(struct so_list *so)
int is_target_filename(const char *name)
void error(const char *fmt,...)
static void info_sharedlibrary_command(const char *pattern, int from_tty)
int solib_keep_data_in_core(CORE_ADDR vaddr, unsigned long size)
void do_cleanups(struct cleanup *old_chain)
static void clear_so(struct so_list *so)
int gdb_bfd_has_target_filename(struct bfd *abfd)