From: Pedro Alves Date: Mon, 28 Mar 2016 23:56:54 +0000 (+0100) Subject: Use symfile_add_flags in solib_add X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5fc9325f09979dbab0961eb4ad13748f5dbece81;p=thirdparty%2Fbinutils-gdb.git Use symfile_add_flags in solib_add The main reason here is being able to tell solib_add to defer breakpoint re-set. (Not used in this patch yet). --- diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 44a1fd10dae..fbced2b9032 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -458,7 +458,14 @@ post_create_inferior (struct target_ops *target, int from_tty) /* If the solist is global across processes, there's no need to refetch it here. */ if (!gdbarch_has_global_solist (target_gdbarch ())) - solib_add (NULL, 0, target, auto_solib_add); + { + symfile_add_flags add_flags = 0; + + if (!auto_solib_add) + add_flags |= SYMFILE_NO_READ; + + solib_add (NULL, add_flags, target); + } } } diff --git a/gdb/remote.c b/gdb/remote.c index ec8b4982e97..fbdb510f5bd 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -4098,7 +4098,16 @@ remote_start_remote (int from_tty, struct target_ops *target, int extended_p) /* On OSs where the list of libraries is global to all processes, we fetch them early. */ if (gdbarch_has_global_solist (target_gdbarch ())) - solib_add (NULL, from_tty, target, auto_solib_add); + { + symfile_add_flags add_flags = 0; + + if (from_tty) + add_flags |= SYMFILE_VERBOSE; + if (!auto_solib_add) + add_flags |= SYMFILE_NO_READ; + + solib_add (NULL, add_flags, target); + } if (target_is_non_stop_p ()) { diff --git a/gdb/solib-frv.c b/gdb/solib-frv.c index 56ccb88f93d..bc1c836d707 100644 --- a/gdb/solib-frv.c +++ b/gdb/solib-frv.c @@ -1145,7 +1145,7 @@ frv_fetch_objfile_link_map (struct objfile *objfile) /* Cause frv_current_sos() to be run if it hasn't been already. */ if (main_lm_addr == 0) - solib_add (0, 0, 0, 1); + solib_add (0, 0, 0); /* frv_current_sos() will set main_lm_addr for the main executable. */ if (objfile == symfile_objfile) diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c index 2bb9dba87c5..40287d28b24 100644 --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c @@ -1614,7 +1614,14 @@ svr4_fetch_objfile_link_map (struct objfile *objfile) /* Cause svr4_current_sos() to be run if it hasn't been already. */ if (info->main_lm_addr == 0) - solib_add (NULL, 0, ¤t_target, auto_solib_add); + { + symfile_add_flags add_flags = 0; + + if (!auto_solib_add) + add_flags |= SYMFILE_NO_READ; + + solib_add (NULL, add_flags, ¤t_target); + } /* svr4_current_sos() will set main_lm_addr for the main executable. */ if (objfile == symfile_objfile) @@ -2247,6 +2254,12 @@ enable_break (struct svr4_info *info, int from_tty) asection *interp_sect; char *interp_name; CORE_ADDR sym_addr; + symfile_add_flags add_flags = 0; + + if (from_tty) + add_flags |= SYMFILE_VERBOSE; + if (!auto_solib_add) + add_flags |= SYMFILE_NO_READ; info->interp_text_sect_low = info->interp_text_sect_high = 0; info->interp_plt_sect_low = info->interp_plt_sect_high = 0; @@ -2256,7 +2269,7 @@ enable_break (struct svr4_info *info, int from_tty) mean r_brk has already been relocated. Assume the dynamic linker is the object containing r_brk. */ - solib_add (NULL, from_tty, ¤t_target, auto_solib_add); + solib_add (NULL, add_flags, ¤t_target); sym_addr = 0; if (info->debug_base && solib_svr4_r_map (info) != 0) sym_addr = solib_svr4_r_brk (info); @@ -2434,7 +2447,7 @@ enable_break (struct svr4_info *info, int from_tty) info->debug_loader_name = xstrdup (interp_name); info->debug_loader_offset_p = 1; info->debug_loader_offset = load_addr; - solib_add (NULL, from_tty, ¤t_target, auto_solib_add); + solib_add (NULL, add_flags, ¤t_target); } /* Record the relocated start and end address of the dynamic linker diff --git a/gdb/solib.c b/gdb/solib.c index 22355058b3e..8bdf04d607e 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -965,10 +965,11 @@ libpthread_solib_p (struct so_list *so) FROM_TTY and TARGET are as described for update_solib_list, above. */ void -solib_add (const char *pattern, int from_tty, - struct target_ops *target, int readsyms) +solib_add (const char *pattern, symfile_add_flags add_flags, + struct target_ops *target) { struct so_list *gdb; + int from_tty = (add_flags & SYMFILE_VERBOSE) != 0; if (print_symbol_loading_p (from_tty, 0, 0)) { @@ -999,19 +1000,20 @@ solib_add (const char *pattern, int from_tty, { int any_matches = 0; int loaded_any_symbols = 0; - const int flags = - SYMFILE_DEFER_BP_RESET | (from_tty ? SYMFILE_VERBOSE : 0); + symfile_add_flags flags = add_flags | SYMFILE_DEFER_BP_RESET; for (gdb = so_list_head; gdb; gdb = gdb->next) 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)); + only if SYMFILE_NO_READ is not 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 + = ((add_flags & SYMFILE_NO_READ) == 0 + || libpthread_solib_p (gdb)); any_matches = 1; if (add_this_solib) @@ -1029,7 +1031,8 @@ solib_add (const char *pattern, int from_tty, } } - if (loaded_any_symbols) + if ((add_flags & SYMFILE_DEFER_BP_RESET) == 0 + && loaded_any_symbols) breakpoint_re_set (); if (from_tty && pattern && ! any_matches) @@ -1292,8 +1295,14 @@ in_solib_dynsym_resolve_code (CORE_ADDR pc) static void sharedlibrary_command (char *args, int from_tty) { + symfile_add_flags add_flags = 0; + dont_repeat (); - solib_add (args, from_tty, (struct target_ops *) 0, 1); + + if (from_tty) + add_flags |= SYMFILE_VERBOSE; + + solib_add (args, add_flags, (struct target_ops *) 0); } /* Implements the command "nosharedlibrary", which discards symbols @@ -1340,7 +1349,12 @@ handle_solib_event (void) be adding them automatically. Switch terminal for any messages produced by breakpoint_re_set. */ target_terminal_ours_for_output (); - solib_add (NULL, 0, ¤t_target, auto_solib_add); + + symfile_add_flags add_flags = 0; + if (!auto_solib_add) + add_flags |= SYMFILE_NO_READ; + solib_add (NULL, add_flags, ¤t_target); + target_terminal_inferior (); } @@ -1423,6 +1437,10 @@ reload_shared_libraries (char *ignored, int from_tty, struct cmd_list_element *e) { const struct target_so_ops *ops; + symfile_add_flags add_flags = 0; + + if (!auto_solib_add) + add_flags |= SYMFILE_NO_READ; reload_shared_libraries_1 (from_tty); @@ -1458,7 +1476,7 @@ reload_shared_libraries (char *ignored, int from_tty, removed. Call it only after the solib target has been initialized by solib_create_inferior_hook. */ - solib_add (NULL, 0, NULL, auto_solib_add); + solib_add (NULL, add_flags, NULL); breakpoint_re_set (); diff --git a/gdb/solib.h b/gdb/solib.h index 00fd6cb4bfb..8231c55e29e 100644 --- a/gdb/solib.h +++ b/gdb/solib.h @@ -20,6 +20,8 @@ #ifndef SOLIB_H #define SOLIB_H +#include "symfile.h" + /* Forward decl's for prototypes */ struct so_list; struct target_ops; @@ -33,7 +35,7 @@ extern void clear_solib (void); /* Called to add symbols from a shared library to gdb's symbol table. */ -extern void solib_add (const char *, int, struct target_ops *, int); +extern void solib_add (const char *, symfile_add_flags, struct target_ops *); extern int solib_read_symbols (struct so_list *, int); /* Function to be called when the inferior starts up, to discover the diff --git a/gdb/symfile.h b/gdb/symfile.h index a11c48aa4fa..248ecf47e03 100644 --- a/gdb/symfile.h +++ b/gdb/symfile.h @@ -23,6 +23,7 @@ /* This file requires that you first include "bfd.h". */ #include "symtab.h" #include "probe.h" +#include "common/enum-flags.h" /* Opaque declarations. */ struct target_section; @@ -448,7 +449,7 @@ extern void add_filename_language (const char *ext, enum language lang); /* This enum encodes bit-flags passed as ADD_FLAGS parameter to symbol_file_add, etc. */ -enum symfile_add_flags +enum symfile_add_flag { /* Be chatty about what you are doing. */ SYMFILE_VERBOSE = 1 << 1, @@ -464,6 +465,7 @@ enum symfile_add_flags symbols are read when the objfile is created. */ SYMFILE_NO_READ = 1 << 4 }; +DEF_ENUM_FLAGS_TYPE (enum symfile_add_flag, symfile_add_flags); extern struct objfile *symbol_file_add (const char *, int, struct section_addr_info *, int);