]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Use symfile_add_flags in solib_add
authorPedro Alves <palves@redhat.com>
Mon, 28 Mar 2016 23:56:54 +0000 (00:56 +0100)
committerPedro Alves <palves@redhat.com>
Mon, 19 Sep 2016 14:44:42 +0000 (15:44 +0100)
The main reason here is being able to tell solib_add to defer
breakpoint re-set.  (Not used in this patch yet).

gdb/infcmd.c
gdb/remote.c
gdb/solib-frv.c
gdb/solib-svr4.c
gdb/solib.c
gdb/solib.h
gdb/symfile.h

index 44a1fd10daeebcfdcb4244d2d64d192e26fc0c72..fbced2b903239344e6e8e3f2371e7236fd83ac06 100644 (file)
@@ -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);
+           }
        }
     }
 
index ec8b4982e978e10aca747a7161d25c100ed588d5..fbdb510f5bd509f27dbc8d84e188532020813485 100644 (file)
@@ -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 ())
     {
index 56ccb88f93d3f4188eb340046b4d91a65a442c26..bc1c836d7075b2b3abcafe414a0d573ec0ad2fce 100644 (file)
@@ -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)
index 2bb9dba87c51d1a1b63d689bc4510bb715591f7d..40287d28b243b578a1db6f31421fb1f14edc40c7 100644 (file)
@@ -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, &current_target, auto_solib_add);
+    {
+      symfile_add_flags add_flags = 0;
+
+      if (!auto_solib_add)
+       add_flags |= SYMFILE_NO_READ;
+
+      solib_add (NULL, add_flags, &current_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, &current_target, auto_solib_add);
+  solib_add (NULL, add_flags, &current_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, &current_target, auto_solib_add);
+         solib_add (NULL, add_flags, &current_target);
        }
 
       /* Record the relocated start and end address of the dynamic linker
index 22355058b3e8d001d2cdcbb275b65a9b676bd43a..8bdf04d607ef8b8395a7242becc799f0c5c26323 100644 (file)
@@ -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, &current_target, auto_solib_add);
+
+  symfile_add_flags add_flags = 0;
+  if (!auto_solib_add)
+    add_flags |= SYMFILE_NO_READ;
+  solib_add (NULL, add_flags, &current_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 ();
 
index 00fd6cb4bfb5f76eb378ff9a1ebe05936ddb812e..8231c55e29ee985a38a7ded3f4ca21057eb71155 100644 (file)
@@ -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
index a11c48aa4fa0373dc38bb52763210e63b709f74f..248ecf47e03620f330155c89ff63a4f4cf7ea3d3 100644 (file)
@@ -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);