X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Fsolib.c;h=d7158979ecb9f5112e2f65c6faf9fc437b1111ff;hb=e49d43ff73a309548dd2b576bb7b602f62be66d6;hp=ed1bc253ecb80236e62a96b8c5bcf775d8ce630c;hpb=a3be80c3c54e9e2c0d8e9a1ff77c931cd8ebeb60;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/solib.c b/gdb/solib.c index ed1bc253ec..d7158979ec 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -65,7 +65,8 @@ solib_init (struct obstack *obstack) static const struct target_so_ops * solib_ops (struct gdbarch *gdbarch) { - const struct target_so_ops **ops = gdbarch_data (gdbarch, solib_data); + const struct target_so_ops **ops + = (const struct target_so_ops **) gdbarch_data (gdbarch, solib_data); return *ops; } @@ -75,7 +76,8 @@ solib_ops (struct gdbarch *gdbarch) void set_solib_ops (struct gdbarch *gdbarch, const struct target_so_ops *new_ops) { - const struct target_so_ops **ops = gdbarch_data (gdbarch, solib_data); + const struct target_so_ops **ops + = (const struct target_so_ops **) gdbarch_data (gdbarch, solib_data); *ops = new_ops; } @@ -158,6 +160,7 @@ solib_find_1 (char *in_pathname, int *fd, int is_solib) const char *fskind = effective_target_file_system_kind (); struct cleanup *old_chain = make_cleanup (null_cleanup, NULL); char *sysroot = gdb_sysroot; + int prefix_len, orig_prefix_len; /* If the absolute prefix starts with "target:" but the filesystem accessed by the target_fileio_* methods is the local filesystem @@ -168,17 +171,16 @@ solib_find_1 (char *in_pathname, int *fd, int is_solib) if (is_target_filename (sysroot) && target_filesystem_is_local ()) sysroot += strlen (TARGET_SYSROOT_PREFIX); - if (*sysroot == '\0') - sysroot = NULL; - else - { - int prefix_len = strlen (sysroot); + /* Strip any trailing slashes from the absolute prefix. */ + prefix_len = orig_prefix_len = strlen (sysroot); - /* Remove trailing slashes from absolute prefix. */ - while (prefix_len > 0 - && IS_DIR_SEPARATOR (sysroot[prefix_len - 1])) - prefix_len--; + while (prefix_len > 0 && IS_DIR_SEPARATOR (sysroot[prefix_len - 1])) + prefix_len--; + if (prefix_len == 0) + sysroot = NULL; + else if (prefix_len != orig_prefix_len) + { sysroot = savestring (sysroot, prefix_len); make_cleanup (xfree, sysroot); } @@ -192,7 +194,7 @@ solib_find_1 (char *in_pathname, int *fd, int is_solib) char *p; /* Avoid clobbering our input. */ - p = alloca (strlen (in_pathname) + 1); + p = (char *) alloca (strlen (in_pathname) + 1); strcpy (p, in_pathname); in_pathname = p; @@ -396,7 +398,7 @@ exec_file_find (char *in_pathname, int *fd) { char *new_pathname; - new_pathname = alloca (strlen (in_pathname) + 5); + new_pathname = (char *) alloca (strlen (in_pathname) + 5); strcpy (new_pathname, in_pathname); strcat (new_pathname, ".exe"); @@ -434,8 +436,9 @@ solib_find (char *in_pathname, int *fd) { char *new_pathname; - new_pathname = alloca (p - in_pathname + 1 - + strlen (solib_symbols_extension) + 1); + new_pathname + = (char *) alloca (p - in_pathname + 1 + + strlen (solib_symbols_extension) + 1); memcpy (new_pathname, in_pathname, p - in_pathname + 1); strcpy (new_pathname + (p - in_pathname) + 1, solib_symbols_extension); @@ -693,16 +696,16 @@ solib_read_symbols (struct so_list *so, int flags) && so->objfile->addr_low == so->addr_low) break; } - if (so->objfile != NULL) - break; - - sap = build_section_addr_info_from_section_table (so->sections, - so->sections_end); - so->objfile = symbol_file_add_from_bfd (so->abfd, so->so_name, - flags, sap, OBJF_SHARED, - NULL); - so->objfile->addr_low = so->addr_low; - free_section_addr_info (sap); + if (so->objfile == NULL) + { + sap = build_section_addr_info_from_section_table (so->sections, + so->sections_end); + so->objfile = symbol_file_add_from_bfd (so->abfd, so->so_name, + flags, sap, OBJF_SHARED, + NULL); + so->objfile->addr_low = so->addr_low; + free_section_addr_info (sap); + } so->symbols_loaded = 1; } @@ -1511,16 +1514,16 @@ show_auto_solib_add (struct ui_file *file, int from_tty, /* Handler for library-specific lookup of global symbol NAME in OBJFILE. Call the library-specific handler if it is installed for the current target. */ -struct symbol * +struct block_symbol solib_global_lookup (struct objfile *objfile, const char *name, const domain_enum domain) { - const struct target_so_ops *ops = solib_ops (get_objfile_arch (objfile)); + const struct target_so_ops *ops = solib_ops (target_gdbarch ()); if (ops->lookup_lib_global_symbol != NULL) return ops->lookup_lib_global_symbol (objfile, name, domain); - return NULL; + return (struct block_symbol) {NULL, NULL}; } /* Lookup the value for a specific symbol from dynamic symbol table. Look @@ -1530,8 +1533,9 @@ solib_global_lookup (struct objfile *objfile, CORE_ADDR gdb_bfd_lookup_symbol_from_symtab (bfd *abfd, - int (*match_sym) (asymbol *, void *), - void *data) + int (*match_sym) (const asymbol *, + const void *), + const void *data) { long storage_needed = bfd_get_symtab_upper_bound (abfd); CORE_ADDR symaddr = 0; @@ -1589,8 +1593,9 @@ gdb_bfd_lookup_symbol_from_symtab (bfd *abfd, static CORE_ADDR bfd_lookup_symbol_from_dyn_symtab (bfd *abfd, - int (*match_sym) (asymbol *, void *), - void *data) + int (*match_sym) (const asymbol *, + const void *), + const void *data) { long storage_needed = bfd_get_dynamic_symtab_upper_bound (abfd); CORE_ADDR symaddr = 0; @@ -1627,8 +1632,8 @@ bfd_lookup_symbol_from_dyn_symtab (bfd *abfd, CORE_ADDR gdb_bfd_lookup_symbol (bfd *abfd, - int (*match_sym) (asymbol *, void *), - void *data) + int (*match_sym) (const asymbol *, const void *), + const void *data) { CORE_ADDR symaddr = gdb_bfd_lookup_symbol_from_symtab (abfd, match_sym, data);