diff options
Diffstat (limited to 'gdb/solib.c')
-rw-r--r-- | gdb/solib.c | 369 |
1 files changed, 182 insertions, 187 deletions
diff --git a/gdb/solib.c b/gdb/solib.c index 60bdf46..0daef48 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -38,7 +38,7 @@ #include "completer.h" #include "elf/external.h" #include "elf/common.h" -#include "filenames.h" /* for DOSish file names */ +#include "filenames.h" /* for DOSish file names */ #include "exec.h" #include "solist.h" #include "observable.h" @@ -63,20 +63,22 @@ bool debug_solib; symbol files. This takes precedence over the environment variables PATH and LD_LIBRARY_PATH. */ static std::string solib_search_path; + static void show_solib_search_path (struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value) { - gdb_printf (file, _("The search path for loading non-absolute " - "shared library symbol files is %s.\n"), + gdb_printf (file, + _ ("The search path for loading non-absolute " + "shared library symbol files is %s.\n"), value); } /* Same as HAVE_DOS_BASED_FILE_SYSTEM, but useable as an rvalue. */ #if (HAVE_DOS_BASED_FILE_SYSTEM) -# define DOS_BASED_FILE_SYSTEM 1 +#define DOS_BASED_FILE_SYSTEM 1 #else -# define DOS_BASED_FILE_SYSTEM 0 +#define DOS_BASED_FILE_SYSTEM 0 #endif /* Return the full pathname of a binary file (the main executable or a @@ -221,29 +223,27 @@ solib_find_1 (const char *in_pathname, int *fd, bool is_solib) } /* Now see if we can open it. */ - found_file = gdb_open_cloexec (temp_pathname.get (), - O_RDONLY | O_BINARY, 0).release (); + found_file = gdb_open_cloexec (temp_pathname.get (), O_RDONLY | O_BINARY, 0) + .release (); /* If the search in gdb_sysroot failed, and the path name has a drive spec (e.g, c:/foo), try stripping ':' from the drive spec, and retrying in the sysroot: c:/foo/bar.dll ==> /sysroot/c/foo/bar.dll. */ - if (found_file < 0 - && sysroot != NULL + if (found_file < 0 && sysroot != NULL && HAS_TARGET_DRIVE_SPEC (fskind, in_pathname)) { bool need_dir_separator = !IS_DIR_SEPARATOR (in_pathname[2]); char drive[2] = { in_pathname[0], '\0' }; - temp_pathname.reset (concat (sysroot, - SLASH_STRING, - drive, + temp_pathname.reset (concat (sysroot, SLASH_STRING, drive, need_dir_separator ? SLASH_STRING : "", in_pathname + 2, (char *) NULL)); - found_file = gdb_open_cloexec (temp_pathname.get (), - O_RDONLY | O_BINARY, 0).release (); + found_file + = gdb_open_cloexec (temp_pathname.get (), O_RDONLY | O_BINARY, 0) + .release (); if (found_file < 0) { /* If the search in gdb_sysroot still failed, try fully @@ -256,8 +256,9 @@ solib_find_1 (const char *in_pathname, int *fd, bool is_solib) need_dir_separator ? SLASH_STRING : "", in_pathname + 2, (char *) NULL)); - found_file = gdb_open_cloexec (temp_pathname.get (), - O_RDONLY | O_BINARY, 0).release (); + found_file + = gdb_open_cloexec (temp_pathname.get (), O_RDONLY | O_BINARY, 0) + .release (); } } @@ -288,8 +289,8 @@ solib_find_1 (const char *in_pathname, int *fd, bool is_solib) solib_search_path (if any). */ if (is_solib && found_file < 0 && !solib_search_path.empty ()) found_file = openp (solib_search_path.c_str (), - OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH, - in_pathname, O_RDONLY | O_BINARY, &temp_pathname); + OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH, in_pathname, + O_RDONLY | O_BINARY, &temp_pathname); /* If not found, and we're looking for a solib, next search the solib_search_path (if any) for the basename only (ignoring the @@ -316,10 +317,10 @@ solib_find_1 (const char *in_pathname, int *fd, bool is_solib) /* If not found, and we're looking for a solib, next search the inferior's $LD_LIBRARY_PATH environment variable. */ if (is_solib && found_file < 0 && sysroot == NULL) - found_file = openp (current_inferior ()->environment.get - ("LD_LIBRARY_PATH"), - OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH, in_pathname, - O_RDONLY | O_BINARY, &temp_pathname); + found_file + = openp (current_inferior ()->environment.get ("LD_LIBRARY_PATH"), + OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH, in_pathname, + O_RDONLY | O_BINARY, &temp_pathname); if (fd == NULL) { @@ -436,8 +437,8 @@ solib_bfd_fopen (const char *pathname, int fd) if (abfd == NULL) { /* Arrange to free PATHNAME when the error is thrown. */ - error (_("Could not open `%s' as an executable file: %s"), - pathname, bfd_errmsg (bfd_get_error ())); + error (_ ("Could not open `%s' as an executable file: %s"), pathname, + bfd_errmsg (bfd_get_error ())); } return abfd; @@ -469,16 +470,16 @@ solib_bfd_open (const char *pathname) /* Check bfd format. */ if (!bfd_check_format (abfd.get (), bfd_object)) - error (_("`%s': not in executable format: %s"), + error (_ ("`%s': not in executable format: %s"), bfd_get_filename (abfd.get ()), bfd_errmsg (bfd_get_error ())); /* Check bfd arch. */ b = gdbarch_bfd_arch_info (target_gdbarch ()); if (!b->compatible (b, bfd_get_arch_info (abfd.get ()))) - error (_("`%s': Shared library architecture %s is not compatible " - "with target architecture %s."), bfd_get_filename (abfd.get ()), - bfd_get_arch_info (abfd.get ())->printable_name, - b->printable_name); + error (_ ("`%s': Shared library architecture %s is not compatible " + "with target architecture %s."), + bfd_get_filename (abfd.get ()), + bfd_get_arch_info (abfd.get ())->printable_name, b->printable_name); return abfd; } @@ -491,20 +492,20 @@ typedef std::unordered_map<std::string, std::string> soname_build_id_map; /* Key used to associate a soname_build_id_map to a core file bfd. */ static const struct registry<bfd>::key<soname_build_id_map> - cbfd_soname_build_id_data_key; + cbfd_soname_build_id_data_key; /* See solib.h. */ void -set_cbfd_soname_build_id (gdb_bfd_ref_ptr abfd, - const char *soname, +set_cbfd_soname_build_id (gdb_bfd_ref_ptr abfd, const char *soname, const bfd_build_id *build_id) { gdb_assert (abfd.get () != nullptr); gdb_assert (soname != nullptr); gdb_assert (build_id != nullptr); - soname_build_id_map *mapptr = cbfd_soname_build_id_data_key.get (abfd.get ()); + soname_build_id_map *mapptr + = cbfd_soname_build_id_data_key.get (abfd.get ()); if (mapptr == nullptr) mapptr = cbfd_soname_build_id_data_key.emplace (abfd.get ()); @@ -571,15 +572,16 @@ solib_map_sections (struct so_list *so) } if (abfd == nullptr || mismatch) { - scoped_fd fd = debuginfod_exec_query ((const unsigned char*) - build_id_hexstr.get (), - 0, so->so_name, &filename); + scoped_fd fd = debuginfod_exec_query ( + (const unsigned char *) build_id_hexstr.get (), 0, so->so_name, + &filename); if (fd.get () >= 0) abfd = ops->bfd_open (filename.get ()); else if (mismatch) - warning (_("Build-id of %ps does not match core file."), - styled_string (file_name_style.style (), filename.get ())); + warning (_ ("Build-id of %ps does not match core file."), + styled_string (file_name_style.style (), + filename.get ())); } } @@ -596,7 +598,7 @@ solib_map_sections (struct so_list *so) that objfile's path, and the target is different from the host, GDB/MI will not provide the correct host-side path. */ if (strlen (bfd_get_filename (so->abfd)) >= SO_NAME_MAX_PATH_SIZE) - error (_("Shared library file name is too long.")); + error (_ ("Shared library file name is too long.")); strcpy (so->so_name, bfd_get_filename (so->abfd)); if (so->sections == nullptr) @@ -687,7 +689,6 @@ free_so (struct so_list *so) xfree (so); } - /* Read in symbols for shared object SO. If SYMFILE_VERBOSE is set in FLAGS, be chatty about it. Return true if any symbols were actually loaded. */ @@ -705,7 +706,6 @@ solib_read_symbols (struct so_list *so, symfile_add_flags flags) } else { - flags |= current_inferior ()->symfile_flags; try @@ -725,11 +725,11 @@ solib_read_symbols (struct so_list *so, symfile_add_flags flags) { section_addr_info sap = build_section_addr_info_from_section_table (*so->sections); - gdb_bfd_ref_ptr tmp_bfd - (gdb_bfd_ref_ptr::new_reference (so->abfd)); - so->objfile = symbol_file_add_from_bfd (tmp_bfd, so->so_name, - flags, &sap, - OBJF_SHARED, NULL); + gdb_bfd_ref_ptr tmp_bfd ( + gdb_bfd_ref_ptr::new_reference (so->abfd)); + so->objfile + = symbol_file_add_from_bfd (tmp_bfd, so->so_name, flags, &sap, + OBJF_SHARED, NULL); so->objfile->addr_low = so->addr_low; } @@ -737,8 +737,9 @@ solib_read_symbols (struct so_list *so, symfile_add_flags flags) } catch (const gdb_exception_error &e) { - exception_fprintf (gdb_stderr, e, _("Error while reading shared" - " library symbols for %s:\n"), + exception_fprintf (gdb_stderr, e, + _ ("Error while reading shared" + " library symbols for %s:\n"), so->so_name); } @@ -766,7 +767,7 @@ void update_solib_list (int from_tty) { const struct target_so_ops *ops = gdbarch_so_ops (target_gdbarch ()); - struct so_list *inferior = ops->current_sos(); + struct so_list *inferior = ops->current_sos (); struct so_list *gdb, **gdb_link; /* We can reach here due to changing solib-search-path or the @@ -836,8 +837,8 @@ update_solib_list (int from_tty) } else { - if (! filename_cmp (gdb->so_original_name, i->so_original_name)) - break; + if (!filename_cmp (gdb->so_original_name, i->so_original_name)) + break; } i_link = &i->next; @@ -867,7 +868,7 @@ update_solib_list (int from_tty) *gdb_link = gdb->next; /* Unless the user loaded it explicitly, free SO's objfile. */ - if (gdb->objfile && ! (gdb->objfile->flags & OBJF_USERLOADED) + if (gdb->objfile && !(gdb->objfile->flags & OBJF_USERLOADED) && !solib_used (gdb)) gdb->objfile->unlink (); @@ -896,7 +897,6 @@ update_solib_list (int from_tty) /* Fill in the rest of each of the `struct so_list' nodes. */ for (i = inferior; i; i = i->next) { - i->pspace = current_program_space; current_program_space->added_solibs.push_back (i); @@ -914,8 +914,8 @@ update_solib_list (int from_tty) catch (const gdb_exception_error &e) { exception_fprintf (gdb_stderr, e, - _("Error while mapping shared " - "library sections:\n")); + _ ("Error while mapping shared " + "library sections:\n")); } /* Notify any observer that the shared object has been @@ -931,12 +931,12 @@ update_solib_list (int from_tty) stand out well. */ if (not_found == 1) - warning (_("Could not load shared library symbols for %s.\n" - "Do you need \"set solib-search-path\" " - "or \"set sysroot\"?"), + warning (_ ("Could not load shared library symbols for %s.\n" + "Do you need \"set solib-search-path\" " + "or \"set sysroot\"?"), not_found_filename); else if (not_found > 1) - warning (_("\ + warning (_ ("\ Could not load shared library symbols for %d libraries, e.g. %s.\n\ Use the \"info sharedlibrary\" command to see the complete listing.\n\ Do you need \"set solib-search-path\" or \"set sysroot\"?"), @@ -944,7 +944,6 @@ Do you need \"set solib-search-path\" or \"set sysroot\"?"), } } - /* Return non-zero if NAME is the libpthread shared library. Uses a fairly simplistic heuristic approach where we check @@ -959,7 +958,7 @@ bool libpthread_name_p (const char *name) { return (strstr (name, "/libpthread") != NULL - || strstr (name, "/libc.") != NULL ); + || strstr (name, "/libc.") != NULL); } /* Return non-zero if SO is the libpthread shared library. */ @@ -986,11 +985,11 @@ solib_add (const char *pattern, int from_tty, int readsyms) { if (pattern != NULL) { - gdb_printf (_("Loading symbols for shared libraries: %s\n"), + gdb_printf (_ ("Loading symbols for shared libraries: %s\n"), pattern); } else - gdb_printf (_("Loading symbols for shared libraries.\n")); + gdb_printf (_ ("Loading symbols for shared libraries.\n")); } current_program_space->solib_add_generation++; @@ -1000,7 +999,7 @@ solib_add (const char *pattern, int from_tty, int readsyms) char *re_err = re_comp (pattern); if (re_err) - error (_("Invalid regexp: %s"), re_err); + error (_ ("Invalid regexp: %s"), re_err); } update_solib_list (from_tty); @@ -1014,18 +1013,17 @@ solib_add (const char *pattern, int from_tty, int readsyms) symfile_add_flags add_flags = SYMFILE_DEFER_BP_RESET; if (from_tty) - add_flags |= SYMFILE_VERBOSE; + add_flags |= SYMFILE_VERBOSE; for (struct so_list *gdb : current_program_space->solibs ()) - if (! pattern || re_exec (gdb->so_name)) + if (!pattern || re_exec (gdb->so_name)) { /* Normally, we would read the symbols from that library only if READSYMS is set. However, we're making a small exception for the pthread library, because we sometimes need the library symbols to be loaded in order to provide thread support (x86-linux for instance). */ - const int add_this_solib = - (readsyms || libpthread_solib_p (gdb)); + const int add_this_solib = (readsyms || libpthread_solib_p (gdb)); any_matches = true; if (add_this_solib) @@ -1035,7 +1033,7 @@ solib_add (const char *pattern, int from_tty, int readsyms) /* If no pattern was given, be quiet for shared libraries we have already loaded. */ if (pattern && (from_tty || info_verbose)) - gdb_printf (_("Symbols already loaded for %s\n"), + gdb_printf (_ ("Symbols already loaded for %s\n"), gdb->so_name); } else if (solib_read_symbols (gdb, add_flags)) @@ -1046,9 +1044,9 @@ solib_add (const char *pattern, int from_tty, int readsyms) if (loaded_any_symbols) breakpoint_re_set (); - if (from_tty && pattern && ! any_matches) - gdb_printf - ("No loaded shared libraries match the pattern `%s'.\n", pattern); + if (from_tty && pattern && !any_matches) + gdb_printf ("No loaded shared libraries match the pattern `%s'.\n", + pattern); if (loaded_any_symbols) { @@ -1078,7 +1076,7 @@ info_sharedlibrary_command (const char *pattern, int from_tty) char *re_err = re_comp (pattern); if (re_err) - error (_("Invalid regexp: %s"), re_err); + error (_ ("Invalid regexp: %s"), re_err); } /* "0x", a little whitespace, and two hex digits per byte of pointers. */ @@ -1094,7 +1092,7 @@ info_sharedlibrary_command (const char *pattern, int from_tty) { if (so->so_name[0]) { - if (pattern && ! re_exec (so->so_name)) + if (pattern && !re_exec (so->so_name)) continue; ++nr_libs; } @@ -1113,9 +1111,9 @@ info_sharedlibrary_command (const char *pattern, int from_tty) for (struct so_list *so : current_program_space->solibs ()) { - if (! so->so_name[0]) + if (!so->so_name[0]) continue; - if (pattern && ! re_exec (so->so_name)) + if (pattern && !re_exec (so->so_name)) continue; ui_out_emit_tuple tuple_emitter (uiout, "lib"); @@ -1131,9 +1129,8 @@ info_sharedlibrary_command (const char *pattern, int from_tty) uiout->field_skip ("to"); } - if (! top_level_interpreter ()->interp_ui_out ()->is_mi_like_p () - && so->symbols_loaded - && !objfile_has_symbols (so->objfile)) + if (!top_level_interpreter ()->interp_ui_out ()->is_mi_like_p () + && so->symbols_loaded && !objfile_has_symbols (so->objfile)) { so_missing_debug_info = true; uiout->field_string ("syms-read", "Yes (*)"); @@ -1150,23 +1147,22 @@ info_sharedlibrary_command (const char *pattern, int from_tty) if (nr_libs == 0) { if (pattern) - uiout->message (_("No shared libraries matched.\n")); + uiout->message (_ ("No shared libraries matched.\n")); else - uiout->message (_("No shared libraries loaded at this time.\n")); + uiout->message (_ ("No shared libraries loaded at this time.\n")); } else { if (so_missing_debug_info) - uiout->message (_("(*): Shared library is missing " - "debugging information.\n")); + uiout->message (_ ("(*): Shared library is missing " + "debugging information.\n")); } } /* See solib.h. */ bool -solib_contains_address_p (const struct so_list *const solib, - CORE_ADDR address) +solib_contains_address_p (const struct so_list *const solib, CORE_ADDR address) { if (solib->sections == nullptr) return false; @@ -1323,7 +1319,7 @@ static void reload_shared_libraries_1 (int from_tty) { if (print_symbol_loading_p (from_tty, 0, 0)) - gdb_printf (_("Loading symbols for shared libraries.\n")); + gdb_printf (_ ("Loading symbols for shared libraries.\n")); for (struct so_list *so : current_program_space->solibs ()) { @@ -1334,8 +1330,8 @@ reload_shared_libraries_1 (int from_tty) if (from_tty) add_flags |= SYMFILE_VERBOSE; - gdb::unique_xmalloc_ptr<char> filename - (tilde_expand (so->so_original_name)); + gdb::unique_xmalloc_ptr<char> filename ( + tilde_expand (so->so_original_name)); gdb_bfd_ref_ptr abfd (solib_bfd_open (filename.get ())); if (abfd != NULL) found_pathname = bfd_get_filename (abfd.get ()); @@ -1346,7 +1342,7 @@ reload_shared_libraries_1 (int from_tty) || (found_pathname != NULL && filename_cmp (found_pathname, so->so_name) != 0)) { - if (so->objfile && ! (so->objfile->flags & OBJF_USERLOADED) + if (so->objfile && !(so->objfile->flags & OBJF_USERLOADED) && !solib_used (so)) so->objfile->unlink (); current_program_space->remove_target_sections (so); @@ -1356,8 +1352,7 @@ reload_shared_libraries_1 (int from_tty) /* If this shared library is now associated with a new symbol file, open it. */ if (found_pathname != NULL - && (!was_loaded - || filename_cmp (found_pathname, so->so_name) != 0)) + && (!was_loaded || filename_cmp (found_pathname, so->so_name) != 0)) { bool got_error = false; @@ -1369,14 +1364,14 @@ reload_shared_libraries_1 (int from_tty) catch (const gdb_exception_error &e) { exception_fprintf (gdb_stderr, e, - _("Error while mapping " - "shared library sections:\n")); + _ ("Error while mapping " + "shared library sections:\n")); got_error = true; } - if (!got_error - && (auto_solib_add || was_loaded || libpthread_solib_p (so))) - solib_read_symbols (so, add_flags); + if (!got_error + && (auto_solib_add || was_loaded || libpthread_solib_p (so))) + solib_read_symbols (so, add_flags); } } } @@ -1452,9 +1447,9 @@ gdb_sysroot_changed (const char *ignored, int from_tty, if (!warning_issued) { - warning (_("\"%s\" is deprecated, use \"%s\" instead."), - old_prefix, new_prefix); - warning (_("sysroot set to \"%s\"."), gdb_sysroot.c_str ()); + warning (_ ("\"%s\" is deprecated, use \"%s\" instead."), old_prefix, + new_prefix); + warning (_ ("sysroot set to \"%s\"."), gdb_sysroot.c_str ()); warning_issued = true; } @@ -1467,11 +1462,10 @@ static void show_auto_solib_add (struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value) { - gdb_printf (file, _("Autoloading of shared library symbols is %s.\n"), + gdb_printf (file, _ ("Autoloading of shared library symbols is %s.\n"), value); } - /* Lookup the value for a specific symbol from dynamic symbol table. Look up symbol from ABFD. MATCH_SYM is a callback function to determine whether to pick up a symbol. DATA is the input of this callback @@ -1492,12 +1486,12 @@ gdb_bfd_lookup_symbol_from_symtab (bfd *abfd, gdb::def_vector<asymbol *> storage (storage_needed / sizeof (asymbol *)); asymbol **symbol_table = storage.data (); - unsigned int number_of_symbols = - bfd_canonicalize_symtab (abfd, symbol_table); + unsigned int number_of_symbols + = bfd_canonicalize_symtab (abfd, symbol_table); for (i = 0; i < number_of_symbols; i++) { - asymbol *sym = *symbol_table++; + asymbol *sym = *symbol_table++; if (match_sym (sym, data)) { @@ -1513,7 +1507,9 @@ gdb_bfd_lookup_symbol_from_symtab (bfd *abfd, if (bfd_get_flavour (abfd) == bfd_target_elf_flavour && gdbarch_elf_make_msymbol_special_p (gdbarch)) { - struct minimal_symbol msym {}; + struct minimal_symbol msym + { + }; msym.set_value_address (symaddr); gdbarch_elf_make_msymbol_special (gdbarch, sym, &msym); @@ -1560,8 +1556,8 @@ gdb_bfd_scan_elf_dyntag (const int desired_dyntag, bfd *abfd, CORE_ADDR *ptr, return 0; bool found = false; - for (const target_section &target_section - : current_program_space->target_sections ()) + for (const target_section &target_section : + current_program_space->target_sections ()) if (sect == target_section.the_bfd_section) { dyn_addr = target_section.addr; @@ -1582,52 +1578,49 @@ gdb_bfd_scan_elf_dyntag (const int desired_dyntag, bfd *abfd, CORE_ADDR *ptr, from memory later. */ sect_size = bfd_section_size (sect); buf = bufstart = (gdb_byte *) alloca (sect_size); - if (!bfd_get_section_contents (abfd, sect, - buf, 0, sect_size)) + if (!bfd_get_section_contents (abfd, sect, buf, 0, sect_size)) return 0; /* Iterate over BUF and scan for DYNTAG. If found, set PTR and return. */ step = (arch_size == 32) ? sizeof (Elf32_External_Dyn) : sizeof (Elf64_External_Dyn); - for (bufend = buf + sect_size; - buf < bufend; - buf += step) - { - if (arch_size == 32) - { - x_dynp_32 = (Elf32_External_Dyn *) buf; - current_dyntag = bfd_h_get_32 (abfd, (bfd_byte *) x_dynp_32->d_tag); - dyn_ptr = bfd_h_get_32 (abfd, (bfd_byte *) x_dynp_32->d_un.d_ptr); - } - else - { - x_dynp_64 = (Elf64_External_Dyn *) buf; - current_dyntag = bfd_h_get_64 (abfd, (bfd_byte *) x_dynp_64->d_tag); - dyn_ptr = bfd_h_get_64 (abfd, (bfd_byte *) x_dynp_64->d_un.d_ptr); - } - if (current_dyntag == DT_NULL) - return 0; - if (current_dyntag == desired_dyntag) - { - /* If requested, try to read the runtime value of this .dynamic + for (bufend = buf + sect_size; buf < bufend; buf += step) + { + if (arch_size == 32) + { + x_dynp_32 = (Elf32_External_Dyn *) buf; + current_dyntag = bfd_h_get_32 (abfd, (bfd_byte *) x_dynp_32->d_tag); + dyn_ptr = bfd_h_get_32 (abfd, (bfd_byte *) x_dynp_32->d_un.d_ptr); + } + else + { + x_dynp_64 = (Elf64_External_Dyn *) buf; + current_dyntag = bfd_h_get_64 (abfd, (bfd_byte *) x_dynp_64->d_tag); + dyn_ptr = bfd_h_get_64 (abfd, (bfd_byte *) x_dynp_64->d_un.d_ptr); + } + if (current_dyntag == DT_NULL) + return 0; + if (current_dyntag == desired_dyntag) + { + /* If requested, try to read the runtime value of this .dynamic entry. */ - if (ptr) - { - struct type *ptr_type; - gdb_byte ptr_buf[8]; - CORE_ADDR ptr_addr_1; - - ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr; - ptr_addr_1 = dyn_addr + (buf - bufstart) + arch_size / 8; - if (target_read_memory (ptr_addr_1, ptr_buf, arch_size / 8) == 0) - dyn_ptr = extract_typed_address (ptr_buf, ptr_type); - *ptr = dyn_ptr; - if (ptr_addr) - *ptr_addr = dyn_addr + (buf - bufstart); - } - return 1; - } - } + if (ptr) + { + struct type *ptr_type; + gdb_byte ptr_buf[8]; + CORE_ADDR ptr_addr_1; + + ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr; + ptr_addr_1 = dyn_addr + (buf - bufstart) + arch_size / 8; + if (target_read_memory (ptr_addr_1, ptr_buf, arch_size / 8) == 0) + dyn_ptr = extract_typed_address (ptr_buf, ptr_type); + *ptr = dyn_ptr; + if (ptr_addr) + *ptr_addr = dyn_addr + (buf - bufstart); + } + return 1; + } + } return 0; } @@ -1651,7 +1644,8 @@ gdb_bfd_read_elf_soname (const char *filename) if (!gdb_bfd_scan_elf_dyntag (DT_SONAME, abfd.get (), &idx, nullptr)) return {}; - struct bfd_section *dynstr = bfd_get_section_by_name (abfd.get (), ".dynstr"); + struct bfd_section *dynstr + = bfd_get_section_by_name (abfd.get (), ".dynstr"); int sect_size = bfd_section_size (dynstr); if (dynstr == nullptr || sect_size <= idx) return {}; @@ -1688,8 +1682,8 @@ bfd_lookup_symbol_from_dyn_symtab (bfd *abfd, unsigned int i; gdb::def_vector<asymbol *> storage (storage_needed / sizeof (asymbol *)); asymbol **symbol_table = storage.data (); - unsigned int number_of_symbols = - bfd_canonicalize_dynamic_symtab (abfd, symbol_table); + unsigned int number_of_symbols + = bfd_canonicalize_dynamic_symtab (abfd, symbol_table); for (i = 0; i < number_of_symbols; i++) { @@ -1717,7 +1711,8 @@ gdb_bfd_lookup_symbol (bfd *abfd, int (*match_sym) (const asymbol *, const void *), const void *data) { - CORE_ADDR symaddr = gdb_bfd_lookup_symbol_from_symtab (abfd, match_sym, data); + CORE_ADDR symaddr + = gdb_bfd_lookup_symbol_from_symtab (abfd, match_sym, data); /* On FreeBSD, the dynamic linker is stripped by default. So we'll have to check the dynamic string table too. */ @@ -1744,49 +1739,49 @@ remove_user_added_objfile (struct objfile *objfile) } void _initialize_solib (); + void _initialize_solib () { - gdb::observers::free_objfile.attach (remove_user_added_objfile, - "solib"); - gdb::observers::inferior_execd.attach ([] (inferior *inf) - { - solib_create_inferior_hook (0); - }, "solib"); + gdb::observers::free_objfile.attach (remove_user_added_objfile, "solib"); + gdb::observers::inferior_execd.attach ( + [] (inferior *inf) { solib_create_inferior_hook (0); }, "solib"); - add_com ("sharedlibrary", class_files, sharedlibrary_command, - _("Load shared object library symbols for files matching REGEXP.")); + add_com ( + "sharedlibrary", class_files, sharedlibrary_command, + _ ("Load shared object library symbols for files matching REGEXP.")); cmd_list_element *info_sharedlibrary_cmd = add_info ("sharedlibrary", info_sharedlibrary_command, - _("Status of loaded shared object libraries.")); + _ ("Status of loaded shared object libraries.")); add_info_alias ("dll", info_sharedlibrary_cmd, 1); add_com ("nosharedlibrary", class_files, no_shared_libraries, - _("Unload all shared object library symbols.")); - - add_setshow_boolean_cmd ("auto-solib-add", class_support, - &auto_solib_add, _("\ -Set autoloading of shared library symbols."), _("\ -Show autoloading of shared library symbols."), _("\ + _ ("Unload all shared object library symbols.")); + + add_setshow_boolean_cmd ("auto-solib-add", class_support, &auto_solib_add, + _ ("\ +Set autoloading of shared library symbols."), + _ ("\ +Show autoloading of shared library symbols."), + _ ("\ If \"on\", symbols from all shared object libraries will be loaded\n\ automatically when the inferior begins execution, when the dynamic linker\n\ informs gdb that a new library has been loaded, or when attaching to the\n\ inferior. Otherwise, symbols must be loaded manually, using \ `sharedlibrary'."), - NULL, - show_auto_solib_add, - &setlist, &showlist); + NULL, show_auto_solib_add, &setlist, &showlist); set_show_commands sysroot_cmds = add_setshow_optional_filename_cmd ("sysroot", class_support, - &gdb_sysroot, _("\ -Set an alternate system root."), _("\ -Show the current system root."), _("\ + &gdb_sysroot, _ ("\ +Set an alternate system root."), + _ ("\ +Show the current system root."), + _ ("\ The system root is used to load absolute shared library symbol files.\n\ For other (relative) files, you can add directories using\n\ `set solib-search-path'."), - gdb_sysroot_changed, - NULL, - &setlist, &showlist); + gdb_sysroot_changed, NULL, &setlist, + &showlist); add_alias_cmd ("solib-absolute-prefix", sysroot_cmds.set, class_support, 0, &setlist); @@ -1794,22 +1789,22 @@ For other (relative) files, you can add directories using\n\ &showlist); add_setshow_optional_filename_cmd ("solib-search-path", class_support, - &solib_search_path, _("\ + &solib_search_path, _ ("\ Set the search path for loading non-absolute shared library symbol files."), - _("\ + _ ("\ Show the search path for loading non-absolute shared library symbol files."), - _("\ + _ ("\ This takes precedence over the environment variables \ PATH and LD_LIBRARY_PATH."), reload_shared_libraries, - show_solib_search_path, - &setlist, &showlist); - - add_setshow_boolean_cmd ("solib", class_maintenance, - &debug_solib, _("\ -Set solib debugging."), _("\ -Show solib debugging."), _("\ + show_solib_search_path, &setlist, + &showlist); + + add_setshow_boolean_cmd ("solib", class_maintenance, &debug_solib, _ ("\ +Set solib debugging."), + _ ("\ +Show solib debugging."), + _ ("\ When true, solib-related debugging output is enabled."), - nullptr, nullptr, - &setdebuglist, &showdebuglist); + nullptr, nullptr, &setdebuglist, &showdebuglist); } |