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
static gdb::unique_xmalloc_ptr<char>
solib_find_1 (const char *in_pathname, int *fd, bool is_solib)
{
- const target_so_ops *ops = gdbarch_so_ops (current_inferior ()->arch ());
+ const solib_ops *ops = gdbarch_so_ops (current_inferior ()->arch ());
int found_file = -1;
gdb::unique_xmalloc_ptr<char> temp_pathname;
const char *fskind = effective_target_file_system_kind ();
}
/* 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
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 ();
}
}
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
/* 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)
{
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;
/* 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 (current_inferior ()->arch ());
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;
}
/* 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 ());
static int
solib_map_sections (solib &so)
{
- const target_so_ops *ops = gdbarch_so_ops (current_inferior ()->arch ());
+ const solib_ops *ops = gdbarch_so_ops (current_inferior ()->arch ());
gdb::unique_xmalloc_ptr<char> filename (tilde_expand (so.so_name.c_str ()));
gdb_bfd_ref_ptr abfd (ops->bfd_open (filename.get ()));
}
if (abfd == nullptr || mismatch)
{
- scoped_fd fd = debuginfod_exec_query ((const unsigned char*)
- build_id_hexstr.get (),
- 0, so.so_name.c_str (),
- &filename);
+ scoped_fd fd = debuginfod_exec_query (
+ (const unsigned char *) build_id_hexstr.get (), 0,
+ so.so_name.c_str (), &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 ()));
}
}
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.get ())) >= SO_NAME_MAX_PATH_SIZE)
- error (_("Shared library file name is too long."));
+ error (_ ("Shared library file name is too long."));
so.so_name = bfd_get_filename (so.abfd.get ());
so.sections = build_section_table (so.abfd.get ());
void
solib::clear ()
{
- const target_so_ops *ops = gdbarch_so_ops (current_inferior ()->arch ());
+ const solib_ops *ops = gdbarch_so_ops (current_inferior ()->arch ());
this->sections.clear ();
this->abfd = nullptr;
}
else
{
-
flags |= current_inferior ()->symfile_flags;
try
so.objfile = nullptr;
for (objfile *objfile : current_program_space->objfiles ())
{
- if (filename_cmp (objfile_name (objfile),
- so.so_name.c_str ()) == 0
+ if (filename_cmp (objfile_name (objfile), so.so_name.c_str ())
+ == 0
&& objfile->addr_low == so.addr_low)
{
so.objfile = objfile;
section_addr_info sap
= build_section_addr_info_from_section_table (so.sections);
gdb_bfd_ref_ptr tmp_bfd = so.abfd;
- so.objfile = symbol_file_add_from_bfd (tmp_bfd,
- so.so_name.c_str (),
- flags, &sap,
- OBJF_SHARED, nullptr);
+ so.objfile
+ = symbol_file_add_from_bfd (tmp_bfd, so.so_name.c_str (),
+ flags, &sap, OBJF_SHARED, nullptr);
so.objfile->addr_low = so.addr_low;
}
}
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.c_str ());
}
void
update_solib_list (int from_tty)
{
- const target_so_ops *ops = gdbarch_so_ops (current_inferior ()->arch ());
+ const solib_ops *ops = gdbarch_so_ops (current_inferior ()->arch ());
/* We can reach here due to changing solib-search-path or the
sysroot, before having any inferior. */
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
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\"?"),
}
}
-
/* Return non-zero if NAME is the libpthread shared library.
Uses a fairly simplistic heuristic approach where we check
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. */
{
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++;
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);
symfile_add_flags add_flags = SYMFILE_DEFER_BP_RESET;
if (from_tty)
- add_flags |= SYMFILE_VERBOSE;
+ add_flags |= SYMFILE_VERBOSE;
for (solib &gdb : current_program_space->solibs ())
- if (! pattern || re_exec (gdb.so_name.c_str ()))
+ if (!pattern || re_exec (gdb.so_name.c_str ()))
{
/* 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)
/* 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.c_str ());
}
else if (solib_read_symbols (gdb, add_flags))
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)
{
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. */
{
if (!so.so_name.empty ())
{
- if (pattern && ! re_exec (so.so_name.c_str ()))
+ if (pattern && !re_exec (so.so_name.c_str ()))
continue;
++nr_libs;
}
if (so.so_name.empty ())
continue;
- if (pattern && ! re_exec (so.so_name.c_str ()))
+ if (pattern && !re_exec (so.so_name.c_str ()))
continue;
ui_out_emit_tuple tuple_emitter (uiout, "lib");
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 (*)");
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"));
}
}
bool
solib_keep_data_in_core (CORE_ADDR vaddr, unsigned long size)
{
- const target_so_ops *ops = gdbarch_so_ops (current_inferior ()->arch ());
+ const solib_ops *ops = gdbarch_so_ops (current_inferior ()->arch ());
if (ops->keep_data_in_core)
return ops->keep_data_in_core (vaddr, size) != 0;
void
clear_solib (void)
{
- const target_so_ops *ops = gdbarch_so_ops (current_inferior ()->arch ());
+ const solib_ops *ops = gdbarch_so_ops (current_inferior ()->arch ());
disable_breakpoints_in_shlibs ();
- current_program_space->so_list.clear_and_dispose ([] (solib *so)
- {
- notify_solib_unloaded (current_program_space, *so);
- current_program_space->remove_target_sections (so);
- delete so;
- });
-
+ current_program_space->so_list.clear_and_dispose ([] (solib *so) {
+ notify_solib_unloaded (current_program_space, *so);
+ current_program_space->remove_target_sections (so);
+ delete so;
+ });
if (ops->clear_solib != nullptr)
ops->clear_solib (current_program_space);
void
solib_create_inferior_hook (int from_tty)
{
- const target_so_ops *ops = gdbarch_so_ops (current_inferior ()->arch ());
+ const solib_ops *ops = gdbarch_so_ops (current_inferior ()->arch ());
ops->solib_create_inferior_hook (from_tty);
}
bool
in_solib_dynsym_resolve_code (CORE_ADDR pc)
{
- const target_so_ops *ops = gdbarch_so_ops (current_inferior ()->arch ());
+ const solib_ops *ops = gdbarch_so_ops (current_inferior ()->arch ());
return ops->in_dynsym_resolve_code (pc) != 0;
}
void
update_solib_breakpoints (void)
{
- const target_so_ops *ops = gdbarch_so_ops (current_inferior ()->arch ());
+ const solib_ops *ops = gdbarch_so_ops (current_inferior ()->arch ());
if (ops->update_breakpoints != NULL)
ops->update_breakpoints ();
void
handle_solib_event (void)
{
- const target_so_ops *ops = gdbarch_so_ops (current_inferior ()->arch ());
+ const solib_ops *ops = gdbarch_so_ops (current_inferior ()->arch ());
if (ops->handle_event != NULL)
ops->handle_event ();
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 (solib &so : current_program_space->solibs ())
{
if (from_tty)
add_flags |= SYMFILE_VERBOSE;
- gdb::unique_xmalloc_ptr<char> filename
- (tilde_expand (so.so_original_name.c_str ()));
+ gdb::unique_xmalloc_ptr<char> filename (
+ tilde_expand (so.so_original_name.c_str ()));
gdb_bfd_ref_ptr abfd (solib_bfd_open (filename.get ()));
if (abfd != NULL)
found_pathname = bfd_get_filename (abfd.get ());
|| (found_pathname != NULL
&& filename_cmp (found_pathname, so.so_name.c_str ()) != 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);
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);
}
}
}
{
reload_shared_libraries_1 (from_tty);
- const target_so_ops *ops = gdbarch_so_ops (current_inferior ()->arch ());
+ const solib_ops *ops = gdbarch_so_ops (current_inferior ()->arch ());
/* Creating inferior hooks here has two purposes. First, if we reload
shared libraries then the address of solib breakpoint we've computed
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;
}
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
function. Return 0 if symbol is not found. */
CORE_ADDR
-gdb_bfd_lookup_symbol_from_symtab
- (bfd *abfd, gdb::function_view<bool (const asymbol *)> match_sym)
+gdb_bfd_lookup_symbol_from_symtab (
+ bfd *abfd, gdb::function_view<bool (const asymbol *)> match_sym)
{
long storage_needed = bfd_get_symtab_upper_bound (abfd);
CORE_ADDR symaddr = 0;
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))
{
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);
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;
/* 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 (current_inferior ()->arch ())->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 (current_inferior ()->arch ())
+ ->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;
}
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 {};
if symbol is not found. */
static CORE_ADDR
-bfd_lookup_symbol_from_dyn_symtab
- (bfd *abfd, gdb::function_view<bool (const asymbol *)> match_sym)
+bfd_lookup_symbol_from_dyn_symtab (
+ bfd *abfd, gdb::function_view<bool (const asymbol *)> match_sym)
{
long storage_needed = bfd_get_dynamic_symtab_upper_bound (abfd);
CORE_ADDR symaddr = 0;
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++)
{
found. */
CORE_ADDR
-gdb_bfd_lookup_symbol
- (bfd *abfd, gdb::function_view<bool (const asymbol *)> match_sym)
+gdb_bfd_lookup_symbol (bfd *abfd,
+ gdb::function_view<bool (const asymbol *)> match_sym)
{
CORE_ADDR symaddr = gdb_bfd_lookup_symbol_from_symtab (abfd, match_sym);
}
void _initialize_solib ();
+
void
_initialize_solib ()
{
- gdb::observers::free_objfile.attach (remove_user_added_objfile,
- "solib");
- gdb::observers::inferior_execd.attach ([] (inferior *exec_inf,
- inferior *follow_inf)
- {
- solib_create_inferior_hook (0);
- }, "solib");
-
- add_com ("sharedlibrary", class_files, sharedlibrary_command,
- _("Load shared object library symbols for files matching REGEXP."));
+ gdb::observers::free_objfile.attach (remove_user_added_objfile, "solib");
+ gdb::observers::inferior_execd.attach (
+ [] (inferior *exec_inf, inferior *follow_inf) {
+ solib_create_inferior_hook (0);
+ },
+ "solib");
+
+ 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);
&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);
}