2c2fa1
http://sourceware.org/ml/gdb-cvs/2013-06/msg00018.html
2c2fa1
2c2fa1
### src/gdb/ChangeLog	2013/06/04 13:10:53	1.15684
2c2fa1
### src/gdb/ChangeLog	2013/06/04 13:17:05	1.15685
2c2fa1
## -1,5 +1,58 @@
2c2fa1
 2013-06-04  Gary Benson  <gbenson@redhat.com>
2c2fa1
 
2c2fa1
+	* breakpoint.h (handle_solib_event): Moved function declaration
2c2fa1
+	to solib.h.
2c2fa1
+	* breakpoint.c (handle_solib_event): Moved function to solib.c.
2c2fa1
+	(bpstat_stop_status): Pass new argument to handle_solib_event.
2c2fa1
+	* solib.h (update_solib_breakpoints): New function declaration.
2c2fa1
+	(handle_solib_event): Moved function declaration from
2c2fa1
+	breakpoint.h.
2c2fa1
+	* solib.c (update_solib_breakpoints): New function.
2c2fa1
+	(handle_solib_event): Moved function from breakpoint.c.
2c2fa1
+	Updated to call solib_ops->handle_event if not NULL.
2c2fa1
+	* solist.h (target_so_ops): New fields "update_breakpoints" and
2c2fa1
+	"handle_event".
2c2fa1
+	* infrun.c (set_stop_on_solib_events): New function.
2c2fa1
+	(_initialize_infrun): Use the above for "set
2c2fa1
+	stop-on-solib-events".
2c2fa1
+	(handle_inferior_event): Pass new argument to handle_solib_event.
2c2fa1
+	* solib-svr4.c (probe.h): New include.
2c2fa1
+	(svr4_free_library_list): New forward declaration.
2c2fa1
+	(probe_action): New enum.
2c2fa1
+	(probe_info): New struct.
2c2fa1
+	(probe_info): New static variable.
2c2fa1
+	(NUM_PROBES): New definition.
2c2fa1
+	(svr4_info): New fields "using_xfer", "probes_table" and
2c2fa1
+	"solib_list".
2c2fa1
+	(free_probes_table): New function.
2c2fa1
+	(free_solib_list): New function.
2c2fa1
+	(svr4_pspace_data_cleanup): Free probes table and solib list.
2c2fa1
+	(svr4_copy_library_list): New function.
2c2fa1
+	(svr4_current_sos_via_xfer_libraries): New parameter "annex".
2c2fa1
+	(svr4_read_so_list): New parameter "prev_lm".
2c2fa1
+	(svr4_current_sos_direct): Renamed from "svr4_current_sos".
2c2fa1
+	(svr4_current_sos): New function.
2c2fa1
+	(probe_and_action): New struct.
2c2fa1
+	(hash_probe_and_action): New function.
2c2fa1
+	(equal_probe_and_action): Likewise.
2c2fa1
+	(register_solib_event_probe): Likewise.
2c2fa1
+	(solib_event_probe_at): Likewise.
2c2fa1
+	(solib_event_probe_action): Likewise.
2c2fa1
+	(solist_update_full): Likewise.
2c2fa1
+	(solist_update_incremental): Likewise.
2c2fa1
+	(disable_probes_interface_cleanup): Likewise.
2c2fa1
+	(svr4_handle_solib_event): Likewise.
2c2fa1
+	(svr4_update_solib_event_breakpoint): Likewise.
2c2fa1
+	(svr4_update_solib_event_breakpoints): Likewise.
2c2fa1
+	(svr4_create_solib_event_breakpoints): Likewise.
2c2fa1
+	(enable_break): Free probes table before creating breakpoints.
2c2fa1
+	Use svr4_create_solib_event_breakpoints to create breakpoints.
2c2fa1
+	(svr4_solib_create_inferior_hook): Free the solib list.
2c2fa1
+	(_initialize_svr4_solib): Initialise
2c2fa1
+	svr4_so_ops.handle_solib_event and svr4_so_ops.update_breakpoints.
2c2fa1
+
2c2fa1
+2013-06-04  Gary Benson  <gbenson@redhat.com>
2c2fa1
+
2c2fa1
 	* target.h (target_ops): New field
2c2fa1
 	"to_augmented_libraries_svr4_read".
2c2fa1
 	(target_augmented_libraries_svr4_read): New macro.
2c2fa1
Index: gdb-7.6/gdb/breakpoint.h
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.orig/gdb/breakpoint.h	2013-06-10 14:44:37.455812656 +0200
2c2fa1
+++ gdb-7.6/gdb/breakpoint.h	2013-06-10 14:44:37.709812579 +0200
2c2fa1
@@ -1552,8 +1552,6 @@ extern int user_breakpoint_p (struct bre
2c2fa1
 /* Attempt to determine architecture of location identified by SAL.  */
2c2fa1
 extern struct gdbarch *get_sal_arch (struct symtab_and_line sal);
2c2fa1
 
2c2fa1
-extern void handle_solib_event (void);
2c2fa1
-
2c2fa1
 extern void breakpoint_free_objfile (struct objfile *objfile);
2c2fa1
 
2c2fa1
 extern void breakpoints_relocate (struct objfile *objfile,
2c2fa1
Index: gdb-7.6/gdb/infrun.c
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.orig/gdb/infrun.c	2013-06-10 14:44:37.427812664 +0200
2c2fa1
+++ gdb-7.6/gdb/infrun.c	2013-06-10 14:44:37.711812579 +0200
2c2fa1
@@ -370,6 +370,16 @@ static struct symbol *step_start_functio
2c2fa1
 /* Nonzero if we want to give control to the user when we're notified
2c2fa1
    of shared library events by the dynamic linker.  */
2c2fa1
 int stop_on_solib_events;
2c2fa1
+
2c2fa1
+/* Enable or disable optional shared library event breakpoints
2c2fa1
+   as appropriate when the above flag is changed.  */
2c2fa1
+
2c2fa1
+static void
2c2fa1
+set_stop_on_solib_events (char *args, int from_tty, struct cmd_list_element *c)
2c2fa1
+{
2c2fa1
+  update_solib_breakpoints ();
2c2fa1
+}
2c2fa1
+
2c2fa1
 static void
2c2fa1
 show_stop_on_solib_events (struct ui_file *file, int from_tty,
2c2fa1
 			   struct cmd_list_element *c, const char *value)
2c2fa1
@@ -7335,7 +7345,7 @@ Show stopping for shared library events.
2c2fa1
 If nonzero, gdb will give control to the user when the dynamic linker\n\
2c2fa1
 notifies gdb of shared library events.  The most common event of interest\n\
2c2fa1
 to the user would be loading/unloading of a new library."),
2c2fa1
-			    NULL,
2c2fa1
+			    set_stop_on_solib_events,
2c2fa1
 			    show_stop_on_solib_events,
2c2fa1
 			    &setlist, &showlist);
2c2fa1
 
2c2fa1
Index: gdb-7.6/gdb/solib-svr4.c
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.orig/gdb/solib-svr4.c	2013-06-10 14:44:37.392812675 +0200
2c2fa1
+++ gdb-7.6/gdb/solib-svr4.c	2013-06-10 14:44:37.712812578 +0200
2c2fa1
@@ -46,10 +46,12 @@
2c2fa1
 #include "auxv.h"
2c2fa1
 #include "exceptions.h"
2c2fa1
 #include "gdb_bfd.h"
2c2fa1
+#include "probe.h"
2c2fa1
 
2c2fa1
 static struct link_map_offsets *svr4_fetch_link_map_offsets (void);
2c2fa1
 static int svr4_have_link_map_offsets (void);
2c2fa1
 static void svr4_relocate_main_executable (void);
2c2fa1
+static void svr4_free_library_list (void *p_list);
2c2fa1
 
2c2fa1
 /* Link map info to include in an allocated so_list entry.  */
2c2fa1
 
2c2fa1
@@ -106,6 +108,55 @@ static const  char * const main_name_lis
2c2fa1
   NULL
2c2fa1
 };
2c2fa1
 
2c2fa1
+/* What to do when a probe stop occurs.  */
2c2fa1
+
2c2fa1
+enum probe_action
2c2fa1
+{
2c2fa1
+  /* Something went seriously wrong.  Stop using probes and
2c2fa1
+     revert to using the older interface.  */
2c2fa1
+  PROBES_INTERFACE_FAILED,
2c2fa1
+
2c2fa1
+  /* No action is required.  The shared object list is still
2c2fa1
+     valid.  */
2c2fa1
+  DO_NOTHING,
2c2fa1
+
2c2fa1
+  /* The shared object list should be reloaded entirely.  */
2c2fa1
+  FULL_RELOAD,
2c2fa1
+
2c2fa1
+  /* Attempt to incrementally update the shared object list. If
2c2fa1
+     the update fails or is not possible, fall back to reloading
2c2fa1
+     the list in full.  */
2c2fa1
+  UPDATE_OR_RELOAD,
2c2fa1
+};
2c2fa1
+
2c2fa1
+/* A probe's name and its associated action.  */
2c2fa1
+
2c2fa1
+struct probe_info
2c2fa1
+{
2c2fa1
+  /* The name of the probe.  */
2c2fa1
+  const char *name;
2c2fa1
+
2c2fa1
+  /* What to do when a probe stop occurs.  */
2c2fa1
+  enum probe_action action;
2c2fa1
+};
2c2fa1
+
2c2fa1
+/* A list of named probes and their associated actions.  If all
2c2fa1
+   probes are present in the dynamic linker then the probes-based
2c2fa1
+   interface will be used.  */
2c2fa1
+
2c2fa1
+static const struct probe_info probe_info[] =
2c2fa1
+{
2c2fa1
+  { "init_start", DO_NOTHING },
2c2fa1
+  { "init_complete", FULL_RELOAD },
2c2fa1
+  { "map_start", DO_NOTHING },
2c2fa1
+  { "map_failed", DO_NOTHING },
2c2fa1
+  { "reloc_complete", UPDATE_OR_RELOAD },
2c2fa1
+  { "unmap_start", DO_NOTHING },
2c2fa1
+  { "unmap_complete", FULL_RELOAD },
2c2fa1
+};
2c2fa1
+
2c2fa1
+#define NUM_PROBES ARRAY_SIZE (probe_info)
2c2fa1
+
2c2fa1
 /* Return non-zero if GDB_SO_NAME and INFERIOR_SO_NAME represent
2c2fa1
    the same shared library.  */
2c2fa1
 
2c2fa1
@@ -313,17 +364,58 @@ struct svr4_info
2c2fa1
   CORE_ADDR interp_text_sect_high;
2c2fa1
   CORE_ADDR interp_plt_sect_low;
2c2fa1
   CORE_ADDR interp_plt_sect_high;
2c2fa1
+
2c2fa1
+  /* Nonzero if the list of objects was last obtained from the target
2c2fa1
+     via qXfer:libraries-svr4:read.  */
2c2fa1
+  int using_xfer;
2c2fa1
+
2c2fa1
+  /* Table of struct probe_and_action instances, used by the
2c2fa1
+     probes-based interface to map breakpoint addresses to probes
2c2fa1
+     and their associated actions.  Lookup is performed using
2c2fa1
+     probe_and_action->probe->address.  */
2c2fa1
+  htab_t probes_table;
2c2fa1
+
2c2fa1
+  /* List of objects loaded into the inferior, used by the probes-
2c2fa1
+     based interface.  */
2c2fa1
+  struct so_list *solib_list;
2c2fa1
 };
2c2fa1
 
2c2fa1
 /* Per-program-space data key.  */
2c2fa1
 static const struct program_space_data *solib_svr4_pspace_data;
2c2fa1
 
2c2fa1
+/* Free the probes table.  */
2c2fa1
+
2c2fa1
+static void
2c2fa1
+free_probes_table (struct svr4_info *info)
2c2fa1
+{
2c2fa1
+  if (info->probes_table == NULL)
2c2fa1
+    return;
2c2fa1
+
2c2fa1
+  htab_delete (info->probes_table);
2c2fa1
+  info->probes_table = NULL;
2c2fa1
+}
2c2fa1
+
2c2fa1
+/* Free the solib list.  */
2c2fa1
+
2c2fa1
+static void
2c2fa1
+free_solib_list (struct svr4_info *info)
2c2fa1
+{
2c2fa1
+  svr4_free_library_list (&info->solib_list);
2c2fa1
+  info->solib_list = NULL;
2c2fa1
+}
2c2fa1
+
2c2fa1
 static void
2c2fa1
 svr4_pspace_data_cleanup (struct program_space *pspace, void *arg)
2c2fa1
 {
2c2fa1
   struct svr4_info *info;
2c2fa1
 
2c2fa1
   info = program_space_data (pspace, solib_svr4_pspace_data);
2c2fa1
+  if (info == NULL)
2c2fa1
+    return;
2c2fa1
+
2c2fa1
+  free_probes_table (info);
2c2fa1
+  free_solib_list (info);
2c2fa1
+
2c2fa1
   xfree (info);
2c2fa1
 }
2c2fa1
 
2c2fa1
@@ -982,6 +1074,34 @@ svr4_free_library_list (void *p_list)
2c2fa1
     }
2c2fa1
 }
2c2fa1
 
2c2fa1
+/* Copy library list.  */
2c2fa1
+
2c2fa1
+static struct so_list *
2c2fa1
+svr4_copy_library_list (struct so_list *src)
2c2fa1
+{
2c2fa1
+  struct so_list *dst = NULL;
2c2fa1
+  struct so_list **link = &dst;
2c2fa1
+
2c2fa1
+  while (src != NULL)
2c2fa1
+    {
2c2fa1
+      struct so_list *new;
2c2fa1
+
2c2fa1
+      new = xmalloc (sizeof (struct so_list));
2c2fa1
+      memcpy (new, src, sizeof (struct so_list));
2c2fa1
+
2c2fa1
+      new->lm_info = xmalloc (sizeof (struct lm_info));
2c2fa1
+      memcpy (new->lm_info, src->lm_info, sizeof (struct lm_info));
2c2fa1
+
2c2fa1
+      new->next = NULL;
2c2fa1
+      *link = new;
2c2fa1
+      link = &new->next;
2c2fa1
+
2c2fa1
+      src = src->next;
2c2fa1
+    }
2c2fa1
+
2c2fa1
+  return dst;
2c2fa1
+}
2c2fa1
+
2c2fa1
 #ifdef HAVE_LIBEXPAT
2c2fa1
 
2c2fa1
 #include "xml-support.h"
2c2fa1
@@ -1097,23 +1217,30 @@ svr4_parse_libraries (const char *docume
2c2fa1
   return 0;
2c2fa1
 }
2c2fa1
 
2c2fa1
-/* Attempt to get so_list from target via qXfer:libraries:read packet.
2c2fa1
+/* Attempt to get so_list from target via qXfer:libraries-svr4:read packet.
2c2fa1
 
2c2fa1
    Return 0 if packet not supported, *SO_LIST_RETURN is not modified in such
2c2fa1
    case.  Return 1 if *SO_LIST_RETURN contains the library list, it may be
2c2fa1
-   empty, caller is responsible for freeing all its entries.  */
2c2fa1
+   empty, caller is responsible for freeing all its entries.
2c2fa1
+
2c2fa1
+   Note that ANNEX must be NULL if the remote does not explicitly allow
2c2fa1
+   qXfer:libraries-svr4:read packets with non-empty annexes.  Support for
2c2fa1
+   this can be checked using target_augmented_libraries_svr4_read ().  */
2c2fa1
 
2c2fa1
 static int
2c2fa1
-svr4_current_sos_via_xfer_libraries (struct svr4_library_list *list)
2c2fa1
+svr4_current_sos_via_xfer_libraries (struct svr4_library_list *list,
2c2fa1
+				     const char *annex)
2c2fa1
 {
2c2fa1
   char *svr4_library_document;
2c2fa1
   int result;
2c2fa1
   struct cleanup *back_to;
2c2fa1
 
2c2fa1
+  gdb_assert (annex == NULL || target_augmented_libraries_svr4_read ());
2c2fa1
+
2c2fa1
   /* Fetch the list of shared libraries.  */
2c2fa1
   svr4_library_document = target_read_stralloc (&current_target,
2c2fa1
 						TARGET_OBJECT_LIBRARIES_SVR4,
2c2fa1
-						NULL);
2c2fa1
+						annex);
2c2fa1
   if (svr4_library_document == NULL)
2c2fa1
     return 0;
2c2fa1
 
2c2fa1
@@ -1127,7 +1254,8 @@ svr4_current_sos_via_xfer_libraries (str
2c2fa1
 #else
2c2fa1
 
2c2fa1
 static int
2c2fa1
-svr4_current_sos_via_xfer_libraries (struct svr4_library_list *list)
2c2fa1
+svr4_current_sos_via_xfer_libraries (struct svr4_library_list *list,
2c2fa1
+				     const char *annex)
2c2fa1
 {
2c2fa1
   return 0;
2c2fa1
 }
2c2fa1
@@ -1161,15 +1289,19 @@ svr4_default_sos (void)
2c2fa1
   return new;
2c2fa1
 }
2c2fa1
 
2c2fa1
-/* Read the whole inferior libraries chain starting at address LM.  Add the
2c2fa1
-   entries to the tail referenced by LINK_PTR_PTR.  Ignore the first entry if
2c2fa1
-   IGNORE_FIRST and set global MAIN_LM_ADDR according to it.  */
2c2fa1
+/* Read the whole inferior libraries chain starting at address LM.
2c2fa1
+   Expect the first entry in the chain's previous entry to be PREV_LM.
2c2fa1
+   Add the entries to the tail referenced by LINK_PTR_PTR.  Ignore the
2c2fa1
+   first entry if IGNORE_FIRST and set global MAIN_LM_ADDR according
2c2fa1
+   to it.  Returns nonzero upon success.  If zero is returned the
2c2fa1
+   entries stored to LINK_PTR_PTR are still valid although they may
2c2fa1
+   represent only part of the inferior library list.  */
2c2fa1
 
2c2fa1
-static void
2c2fa1
-svr4_read_so_list (CORE_ADDR lm, struct so_list ***link_ptr_ptr,
2c2fa1
-		   int ignore_first)
2c2fa1
+static int
2c2fa1
+svr4_read_so_list (CORE_ADDR lm, CORE_ADDR prev_lm,
2c2fa1
+		   struct so_list ***link_ptr_ptr, int ignore_first)
2c2fa1
 {
2c2fa1
-  CORE_ADDR prev_lm = 0, next_lm;
2c2fa1
+  CORE_ADDR next_lm;
2c2fa1
 
2c2fa1
   for (; lm != 0; prev_lm = lm, lm = next_lm)
2c2fa1
     {
2c2fa1
@@ -1185,7 +1317,7 @@ svr4_read_so_list (CORE_ADDR lm, struct
2c2fa1
       if (new->lm_info == NULL)
2c2fa1
 	{
2c2fa1
 	  do_cleanups (old_chain);
2c2fa1
-	  break;
2c2fa1
+	  return 0;
2c2fa1
 	}
2c2fa1
 
2c2fa1
       next_lm = new->lm_info->l_next;
2c2fa1
@@ -1196,7 +1328,7 @@ svr4_read_so_list (CORE_ADDR lm, struct
2c2fa1
 		   paddress (target_gdbarch (), prev_lm),
2c2fa1
 		   paddress (target_gdbarch (), new->lm_info->l_prev));
2c2fa1
 	  do_cleanups (old_chain);
2c2fa1
-	  break;
2c2fa1
+	  return 0;
2c2fa1
 	}
2c2fa1
 
2c2fa1
       /* For SVR4 versions, the first entry in the link map is for the
2c2fa1
@@ -1291,17 +1423,21 @@ svr4_read_so_list (CORE_ADDR lm, struct
2c2fa1
       **link_ptr_ptr = new;
2c2fa1
       *link_ptr_ptr = &new->next;
2c2fa1
     }
2c2fa1
+
2c2fa1
+  return 1;
2c2fa1
 }
2c2fa1
 
2c2fa1
-/* Implement the "current_sos" target_so_ops method.  */
2c2fa1
+/* Read the full list of currently loaded shared objects directly
2c2fa1
+   from the inferior, without referring to any libraries read and
2c2fa1
+   stored by the probes interface.  Handle special cases relating
2c2fa1
+   to the first elements of the list.  */
2c2fa1
 
2c2fa1
 static struct so_list *
2c2fa1
-svr4_current_sos (void)
2c2fa1
+svr4_current_sos_direct (struct svr4_info *info)
2c2fa1
 {
2c2fa1
   CORE_ADDR lm;
2c2fa1
   struct so_list *head = NULL;
2c2fa1
   struct so_list **link_ptr = &head;
2c2fa1
-  struct svr4_info *info;
2c2fa1
   struct cleanup *back_to;
2c2fa1
   int ignore_first;
2c2fa1
   struct svr4_library_list library_list;
2c2fa1
@@ -1314,19 +1450,16 @@ svr4_current_sos (void)
2c2fa1
      Unfortunately statically linked inferiors will also fall back through this
2c2fa1
      suboptimal code path.  */
2c2fa1
 
2c2fa1
-  if (svr4_current_sos_via_xfer_libraries (&library_list))
2c2fa1
+  info->using_xfer = svr4_current_sos_via_xfer_libraries (&library_list,
2c2fa1
+							  NULL);
2c2fa1
+  if (info->using_xfer)
2c2fa1
     {
2c2fa1
       if (library_list.main_lm)
2c2fa1
-	{
2c2fa1
-	  info = get_svr4_info ();
2c2fa1
-	  info->main_lm_addr = library_list.main_lm;
2c2fa1
-	}
2c2fa1
+	info->main_lm_addr = library_list.main_lm;
2c2fa1
 
2c2fa1
       return library_list.head ? library_list.head : svr4_default_sos ();
2c2fa1
     }
2c2fa1
 
2c2fa1
-  info = get_svr4_info ();
2c2fa1
-
2c2fa1
   /* Always locate the debug struct, in case it has moved.  */
2c2fa1
   info->debug_base = 0;
2c2fa1
   locate_base (info);
2c2fa1
@@ -1349,7 +1482,7 @@ svr4_current_sos (void)
2c2fa1
      `struct so_list' nodes.  */
2c2fa1
   lm = solib_svr4_r_map (info);
2c2fa1
   if (lm)
2c2fa1
-    svr4_read_so_list (lm, &link_ptr, ignore_first);
2c2fa1
+    svr4_read_so_list (lm, 0, &link_ptr, ignore_first);
2c2fa1
 
2c2fa1
   /* On Solaris, the dynamic linker is not in the normal list of
2c2fa1
      shared objects, so make sure we pick it up too.  Having
2c2fa1
@@ -1357,7 +1490,7 @@ svr4_current_sos (void)
2c2fa1
      for skipping dynamic linker resolver code.  */
2c2fa1
   lm = solib_svr4_r_ldsomap (info);
2c2fa1
   if (lm)
2c2fa1
-    svr4_read_so_list (lm, &link_ptr, 0);
2c2fa1
+    svr4_read_so_list (lm, 0, &link_ptr, 0);
2c2fa1
 
2c2fa1
   discard_cleanups (back_to);
2c2fa1
 
2c2fa1
@@ -1367,6 +1500,22 @@ svr4_current_sos (void)
2c2fa1
   return head;
2c2fa1
 }
2c2fa1
 
2c2fa1
+/* Implement the "current_sos" target_so_ops method.  */
2c2fa1
+
2c2fa1
+static struct so_list *
2c2fa1
+svr4_current_sos (void)
2c2fa1
+{
2c2fa1
+  struct svr4_info *info = get_svr4_info ();
2c2fa1
+
2c2fa1
+  /* If the solib list has been read and stored by the probes
2c2fa1
+     interface then we return a copy of the stored list.  */
2c2fa1
+  if (info->solib_list != NULL)
2c2fa1
+    return svr4_copy_library_list (info->solib_list);
2c2fa1
+
2c2fa1
+  /* Otherwise obtain the solib list directly from the inferior.  */
2c2fa1
+  return svr4_current_sos_direct (info);
2c2fa1
+}
2c2fa1
+
2c2fa1
 /* Get the address of the link_map for a given OBJFILE.  */
2c2fa1
 
2c2fa1
 CORE_ADDR
2c2fa1
@@ -1449,6 +1598,476 @@ exec_entry_point (struct bfd *abfd, stru
2c2fa1
   return gdbarch_addr_bits_remove (target_gdbarch (), addr);
2c2fa1
 }
2c2fa1
 
2c2fa1
+/* A probe and its associated action.  */
2c2fa1
+
2c2fa1
+struct probe_and_action
2c2fa1
+{
2c2fa1
+  /* The probe.  */
2c2fa1
+  struct probe *probe;
2c2fa1
+
2c2fa1
+  /* The action.  */
2c2fa1
+  enum probe_action action;
2c2fa1
+};
2c2fa1
+
2c2fa1
+/* Returns a hash code for the probe_and_action referenced by p.  */
2c2fa1
+
2c2fa1
+static hashval_t
2c2fa1
+hash_probe_and_action (const void *p)
2c2fa1
+{
2c2fa1
+  const struct probe_and_action *pa = p;
2c2fa1
+
2c2fa1
+  return (hashval_t) pa->probe->address;
2c2fa1
+}
2c2fa1
+
2c2fa1
+/* Returns non-zero if the probe_and_actions referenced by p1 and p2
2c2fa1
+   are equal.  */
2c2fa1
+
2c2fa1
+static int
2c2fa1
+equal_probe_and_action (const void *p1, const void *p2)
2c2fa1
+{
2c2fa1
+  const struct probe_and_action *pa1 = p1;
2c2fa1
+  const struct probe_and_action *pa2 = p2;
2c2fa1
+
2c2fa1
+  return pa1->probe->address == pa2->probe->address;
2c2fa1
+}
2c2fa1
+
2c2fa1
+/* Register a solib event probe and its associated action in the
2c2fa1
+   probes table.  */
2c2fa1
+
2c2fa1
+static void
2c2fa1
+register_solib_event_probe (struct probe *probe, enum probe_action action)
2c2fa1
+{
2c2fa1
+  struct svr4_info *info = get_svr4_info ();
2c2fa1
+  struct probe_and_action lookup, *pa;
2c2fa1
+  void **slot;
2c2fa1
+
2c2fa1
+  /* Create the probes table, if necessary.  */
2c2fa1
+  if (info->probes_table == NULL)
2c2fa1
+    info->probes_table = htab_create_alloc (1, hash_probe_and_action,
2c2fa1
+					    equal_probe_and_action,
2c2fa1
+					    xfree, xcalloc, xfree);
2c2fa1
+
2c2fa1
+  lookup.probe = probe;
2c2fa1
+  slot = htab_find_slot (info->probes_table, &lookup, INSERT);
2c2fa1
+  gdb_assert (*slot == HTAB_EMPTY_ENTRY);
2c2fa1
+
2c2fa1
+  pa = XCNEW (struct probe_and_action);
2c2fa1
+  pa->probe = probe;
2c2fa1
+  pa->action = action;
2c2fa1
+
2c2fa1
+  *slot = pa;
2c2fa1
+}
2c2fa1
+
2c2fa1
+/* Get the solib event probe at the specified location, and the
2c2fa1
+   action associated with it.  Returns NULL if no solib event probe
2c2fa1
+   was found.  */
2c2fa1
+
2c2fa1
+static struct probe_and_action *
2c2fa1
+solib_event_probe_at (struct svr4_info *info, CORE_ADDR address)
2c2fa1
+{
2c2fa1
+  struct probe lookup_probe;
2c2fa1
+  struct probe_and_action lookup;
2c2fa1
+  void **slot;
2c2fa1
+
2c2fa1
+  lookup_probe.address = address;
2c2fa1
+  lookup.probe = &lookup_probe;
2c2fa1
+  slot = htab_find_slot (info->probes_table, &lookup, NO_INSERT);
2c2fa1
+
2c2fa1
+  if (slot == NULL)
2c2fa1
+    return NULL;
2c2fa1
+
2c2fa1
+  return (struct probe_and_action *) *slot;
2c2fa1
+}
2c2fa1
+
2c2fa1
+/* Decide what action to take when the specified solib event probe is
2c2fa1
+   hit.  */
2c2fa1
+
2c2fa1
+static enum probe_action
2c2fa1
+solib_event_probe_action (struct probe_and_action *pa)
2c2fa1
+{
2c2fa1
+  enum probe_action action;
2c2fa1
+  unsigned probe_argc;
2c2fa1
+
2c2fa1
+  action = pa->action;
2c2fa1
+  if (action == DO_NOTHING || action == PROBES_INTERFACE_FAILED)
2c2fa1
+    return action;
2c2fa1
+
2c2fa1
+  gdb_assert (action == FULL_RELOAD || action == UPDATE_OR_RELOAD);
2c2fa1
+
2c2fa1
+  /* Check that an appropriate number of arguments has been supplied.
2c2fa1
+     We expect:
2c2fa1
+       arg0: Lmid_t lmid (mandatory)
2c2fa1
+       arg1: struct r_debug *debug_base (mandatory)
2c2fa1
+       arg2: struct link_map *new (optional, for incremental updates)  */
2c2fa1
+  probe_argc = get_probe_argument_count (pa->probe);
2c2fa1
+  if (probe_argc == 2)
2c2fa1
+    action = FULL_RELOAD;
2c2fa1
+  else if (probe_argc < 2)
2c2fa1
+    action = PROBES_INTERFACE_FAILED;
2c2fa1
+
2c2fa1
+  return action;
2c2fa1
+}
2c2fa1
+
2c2fa1
+/* Populate the shared object list by reading the entire list of
2c2fa1
+   shared objects from the inferior.  Handle special cases relating
2c2fa1
+   to the first elements of the list.  Returns nonzero on success.  */
2c2fa1
+
2c2fa1
+static int
2c2fa1
+solist_update_full (struct svr4_info *info)
2c2fa1
+{
2c2fa1
+  free_solib_list (info);
2c2fa1
+  info->solib_list = svr4_current_sos_direct (info);
2c2fa1
+
2c2fa1
+  return 1;
2c2fa1
+}
2c2fa1
+
2c2fa1
+/* Update the shared object list starting from the link-map entry
2c2fa1
+   passed by the linker in the probe's third argument.  Returns
2c2fa1
+   nonzero if the list was successfully updated, or zero to indicate
2c2fa1
+   failure.  */
2c2fa1
+
2c2fa1
+static int
2c2fa1
+solist_update_incremental (struct svr4_info *info, CORE_ADDR lm)
2c2fa1
+{
2c2fa1
+  struct so_list *tail;
2c2fa1
+  CORE_ADDR prev_lm;
2c2fa1
+
2c2fa1
+  /* svr4_current_sos_direct contains logic to handle a number of
2c2fa1
+     special cases relating to the first elements of the list.  To
2c2fa1
+     avoid duplicating this logic we defer to solist_update_full
2c2fa1
+     if the list is empty.  */
2c2fa1
+  if (info->solib_list == NULL)
2c2fa1
+    return 0;
2c2fa1
+
2c2fa1
+  /* Fall back to a full update if we are using a remote target
2c2fa1
+     that does not support incremental transfers.  */
2c2fa1
+  if (info->using_xfer && !target_augmented_libraries_svr4_read ())
2c2fa1
+    return 0;
2c2fa1
+
2c2fa1
+  /* Walk to the end of the list.  */
2c2fa1
+  for (tail = info->solib_list; tail->next != NULL; tail = tail->next)
2c2fa1
+    /* Nothing.  */;
2c2fa1
+  prev_lm = tail->lm_info->lm_addr;
2c2fa1
+
2c2fa1
+  /* Read the new objects.  */
2c2fa1
+  if (info->using_xfer)
2c2fa1
+    {
2c2fa1
+      struct svr4_library_list library_list;
2c2fa1
+      char annex[64];
2c2fa1
+
2c2fa1
+      xsnprintf (annex, sizeof (annex), "start=%s;prev=%s",
2c2fa1
+		 phex_nz (lm, sizeof (lm)),
2c2fa1
+		 phex_nz (prev_lm, sizeof (prev_lm)));
2c2fa1
+      if (!svr4_current_sos_via_xfer_libraries (&library_list, annex))
2c2fa1
+	return 0;
2c2fa1
+
2c2fa1
+      tail->next = library_list.head;
2c2fa1
+    }
2c2fa1
+  else
2c2fa1
+    {
2c2fa1
+      struct so_list **link = &tail->next;
2c2fa1
+
2c2fa1
+      /* IGNORE_FIRST may safely be set to zero here because the
2c2fa1
+	 above check and deferral to solist_update_full ensures
2c2fa1
+	 that this call to svr4_read_so_list will never see the
2c2fa1
+	 first element.  */
2c2fa1
+      if (!svr4_read_so_list (lm, prev_lm, &link, 0))
2c2fa1
+	return 0;
2c2fa1
+    }
2c2fa1
+
2c2fa1
+  return 1;
2c2fa1
+}
2c2fa1
+
2c2fa1
+/* Disable the probes-based linker interface and revert to the
2c2fa1
+   original interface.  We don't reset the breakpoints as the
2c2fa1
+   ones set up for the probes-based interface are adequate.  */
2c2fa1
+
2c2fa1
+static void
2c2fa1
+disable_probes_interface_cleanup (void *arg)
2c2fa1
+{
2c2fa1
+  struct svr4_info *info = get_svr4_info ();
2c2fa1
+
2c2fa1
+  warning (_("Probes-based dynamic linker interface failed.\n"
2c2fa1
+	     "Reverting to original interface.\n"));
2c2fa1
+
2c2fa1
+  free_probes_table (info);
2c2fa1
+  free_solib_list (info);
2c2fa1
+}
2c2fa1
+
2c2fa1
+/* Update the solib list as appropriate when using the
2c2fa1
+   probes-based linker interface.  Do nothing if using the
2c2fa1
+   standard interface.  */
2c2fa1
+
2c2fa1
+static void
2c2fa1
+svr4_handle_solib_event (void)
2c2fa1
+{
2c2fa1
+  struct svr4_info *info = get_svr4_info ();
2c2fa1
+  struct probe_and_action *pa;
2c2fa1
+  enum probe_action action;
2c2fa1
+  struct cleanup *old_chain, *usm_chain;
2c2fa1
+  struct value *val;
2c2fa1
+  CORE_ADDR pc, debug_base, lm = 0;
2c2fa1
+  int is_initial_ns;
2c2fa1
+
2c2fa1
+  /* Do nothing if not using the probes interface.  */
2c2fa1
+  if (info->probes_table == NULL)
2c2fa1
+    return;
2c2fa1
+
2c2fa1
+  /* If anything goes wrong we revert to the original linker
2c2fa1
+     interface.  */
2c2fa1
+  old_chain = make_cleanup (disable_probes_interface_cleanup, NULL);
2c2fa1
+
2c2fa1
+  pc = regcache_read_pc (get_current_regcache ());
2c2fa1
+  pa = solib_event_probe_at (info, pc);
2c2fa1
+  if (pa == NULL)
2c2fa1
+    {
2c2fa1
+      do_cleanups (old_chain);
2c2fa1
+      return;
2c2fa1
+    }
2c2fa1
+
2c2fa1
+  action = solib_event_probe_action (pa);
2c2fa1
+  if (action == PROBES_INTERFACE_FAILED)
2c2fa1
+    {
2c2fa1
+      do_cleanups (old_chain);
2c2fa1
+      return;
2c2fa1
+    }
2c2fa1
+
2c2fa1
+  if (action == DO_NOTHING)
2c2fa1
+    {
2c2fa1
+      discard_cleanups (old_chain);
2c2fa1
+      return;
2c2fa1
+    }
2c2fa1
+
2c2fa1
+  /* evaluate_probe_argument looks up symbols in the dynamic linker
2c2fa1
+     using find_pc_section.  find_pc_section is accelerated by a cache
2c2fa1
+     called the section map.  The section map is invalidated every
2c2fa1
+     time a shared library is loaded or unloaded, and if the inferior
2c2fa1
+     is generating a lot of shared library events then the section map
2c2fa1
+     will be updated every time svr4_handle_solib_event is called.
2c2fa1
+     We called find_pc_section in svr4_create_solib_event_breakpoints,
2c2fa1
+     so we can guarantee that the dynamic linker's sections are in the
2c2fa1
+     section map.  We can therefore inhibit section map updates across
2c2fa1
+     these calls to evaluate_probe_argument and save a lot of time.  */
2c2fa1
+  inhibit_section_map_updates (current_program_space);
2c2fa1
+  usm_chain = make_cleanup (resume_section_map_updates_cleanup,
2c2fa1
+			    current_program_space);
2c2fa1
+
2c2fa1
+  val = evaluate_probe_argument (pa->probe, 1);
2c2fa1
+  if (val == NULL)
2c2fa1
+    {
2c2fa1
+      do_cleanups (old_chain);
2c2fa1
+      return;
2c2fa1
+    }
2c2fa1
+
2c2fa1
+  debug_base = value_as_address (val);
2c2fa1
+  if (debug_base == 0)
2c2fa1
+    {
2c2fa1
+      do_cleanups (old_chain);
2c2fa1
+      return;
2c2fa1
+    }
2c2fa1
+
2c2fa1
+  /* Always locate the debug struct, in case it moved.  */
2c2fa1
+  info->debug_base = 0;
2c2fa1
+  if (locate_base (info) == 0)
2c2fa1
+    {
2c2fa1
+      do_cleanups (old_chain);
2c2fa1
+      return;
2c2fa1
+    }
2c2fa1
+
2c2fa1
+  /* GDB does not currently support libraries loaded via dlmopen
2c2fa1
+     into namespaces other than the initial one.  We must ignore
2c2fa1
+     any namespace other than the initial namespace here until
2c2fa1
+     support for this is added to GDB.  */
2c2fa1
+  if (debug_base != info->debug_base)
2c2fa1
+    action = DO_NOTHING;
2c2fa1
+
2c2fa1
+  if (action == UPDATE_OR_RELOAD)
2c2fa1
+    {
2c2fa1
+      val = evaluate_probe_argument (pa->probe, 2);
2c2fa1
+      if (val != NULL)
2c2fa1
+	lm = value_as_address (val);
2c2fa1
+
2c2fa1
+      if (lm == 0)
2c2fa1
+	action = FULL_RELOAD;
2c2fa1
+    }
2c2fa1
+
2c2fa1
+  /* Resume section map updates.  */
2c2fa1
+  do_cleanups (usm_chain);
2c2fa1
+
2c2fa1
+  if (action == UPDATE_OR_RELOAD)
2c2fa1
+    {
2c2fa1
+      if (!solist_update_incremental (info, lm))
2c2fa1
+	action = FULL_RELOAD;
2c2fa1
+    }
2c2fa1
+
2c2fa1
+  if (action == FULL_RELOAD)
2c2fa1
+    {
2c2fa1
+      if (!solist_update_full (info))
2c2fa1
+	{
2c2fa1
+	  do_cleanups (old_chain);
2c2fa1
+	  return;
2c2fa1
+	}
2c2fa1
+    }
2c2fa1
+
2c2fa1
+  discard_cleanups (old_chain);
2c2fa1
+}
2c2fa1
+
2c2fa1
+/* Helper function for svr4_update_solib_event_breakpoints.  */
2c2fa1
+
2c2fa1
+static int
2c2fa1
+svr4_update_solib_event_breakpoint (struct breakpoint *b, void *arg)
2c2fa1
+{
2c2fa1
+  struct bp_location *loc;
2c2fa1
+
2c2fa1
+  if (b->type != bp_shlib_event)
2c2fa1
+    {
2c2fa1
+      /* Continue iterating.  */
2c2fa1
+      return 0;
2c2fa1
+    }
2c2fa1
+
2c2fa1
+  for (loc = b->loc; loc != NULL; loc = loc->next)
2c2fa1
+    {
2c2fa1
+      struct svr4_info *info;
2c2fa1
+      struct probe_and_action *pa;
2c2fa1
+
2c2fa1
+      info = program_space_data (loc->pspace, solib_svr4_pspace_data);
2c2fa1
+      if (info == NULL || info->probes_table == NULL)
2c2fa1
+	continue;
2c2fa1
+
2c2fa1
+      pa = solib_event_probe_at (info, loc->address);
2c2fa1
+      if (pa == NULL)
2c2fa1
+	continue;
2c2fa1
+
2c2fa1
+      if (pa->action == DO_NOTHING)
2c2fa1
+	{
2c2fa1
+	  if (b->enable_state == bp_disabled && stop_on_solib_events)
2c2fa1
+	    enable_breakpoint (b);
2c2fa1
+	  else if (b->enable_state == bp_enabled && !stop_on_solib_events)
2c2fa1
+	    disable_breakpoint (b);
2c2fa1
+	}
2c2fa1
+
2c2fa1
+      break;
2c2fa1
+    }
2c2fa1
+
2c2fa1
+  /* Continue iterating.  */
2c2fa1
+  return 0;
2c2fa1
+}
2c2fa1
+
2c2fa1
+/* Enable or disable optional solib event breakpoints as appropriate.
2c2fa1
+   Called whenever stop_on_solib_events is changed.  */
2c2fa1
+
2c2fa1
+static void
2c2fa1
+svr4_update_solib_event_breakpoints (void)
2c2fa1
+{
2c2fa1
+  iterate_over_breakpoints (svr4_update_solib_event_breakpoint, NULL);
2c2fa1
+}
2c2fa1
+
2c2fa1
+/* Create and register solib event breakpoints.  PROBES is an array
2c2fa1
+   of NUM_PROBES elements, each of which is vector of probes.  A
2c2fa1
+   solib event breakpoint will be created and registered for each
2c2fa1
+   probe.  */
2c2fa1
+
2c2fa1
+static void
2c2fa1
+svr4_create_probe_breakpoints (struct gdbarch *gdbarch,
2c2fa1
+			       VEC (probe_p) **probes)
2c2fa1
+{
2c2fa1
+  int i;
2c2fa1
+
2c2fa1
+  for (i = 0; i < NUM_PROBES; i++)
2c2fa1
+    {
2c2fa1
+      enum probe_action action = probe_info[i].action;
2c2fa1
+      struct probe *probe;
2c2fa1
+      int ix;
2c2fa1
+
2c2fa1
+      for (ix = 0;
2c2fa1
+	   VEC_iterate (probe_p, probes[i], ix, probe);
2c2fa1
+	   ++ix)
2c2fa1
+	{
2c2fa1
+	  create_solib_event_breakpoint (gdbarch, probe->address);
2c2fa1
+	  register_solib_event_probe (probe, action);
2c2fa1
+	}
2c2fa1
+    }
2c2fa1
+
2c2fa1
+  svr4_update_solib_event_breakpoints ();
2c2fa1
+}
2c2fa1
+
2c2fa1
+/* Both the SunOS and the SVR4 dynamic linkers call a marker function
2c2fa1
+   before and after mapping and unmapping shared libraries.  The sole
2c2fa1
+   purpose of this method is to allow debuggers to set a breakpoint so
2c2fa1
+   they can track these changes.
2c2fa1
+
2c2fa1
+   Some versions of the glibc dynamic linker contain named probes
2c2fa1
+   to allow more fine grained stopping.  Given the address of the
2c2fa1
+   original marker function, this function attempts to find these
2c2fa1
+   probes, and if found, sets breakpoints on those instead.  If the
2c2fa1
+   probes aren't found, a single breakpoint is set on the original
2c2fa1
+   marker function.  */
2c2fa1
+
2c2fa1
+static void
2c2fa1
+svr4_create_solib_event_breakpoints (struct gdbarch *gdbarch,
2c2fa1
+				     CORE_ADDR address)
2c2fa1
+{
2c2fa1
+  struct obj_section *os;
2c2fa1
+
2c2fa1
+  os = find_pc_section (address);
2c2fa1
+  if (os != NULL)
2c2fa1
+    {
2c2fa1
+      int with_prefix;
2c2fa1
+
2c2fa1
+      for (with_prefix = 0; with_prefix <= 1; with_prefix++)
2c2fa1
+	{
2c2fa1
+	  VEC (probe_p) *probes[NUM_PROBES];
2c2fa1
+	  int all_probes_found = 1;
2c2fa1
+	  int i;
2c2fa1
+
2c2fa1
+	  memset (probes, 0, sizeof (probes));
2c2fa1
+	  for (i = 0; i < NUM_PROBES; i++)
2c2fa1
+	    {
2c2fa1
+	      const char *name = probe_info[i].name;
2c2fa1
+	      char buf[32];
2c2fa1
+
2c2fa1
+	      /* Fedora 17 and Red Hat Enterprise Linux 6.2-6.4
2c2fa1
+		 shipped with an early version of the probes code in
2c2fa1
+		 which the probes' names were prefixed with "rtld_"
2c2fa1
+		 and the "map_failed" probe did not exist.  The
2c2fa1
+		 locations of the probes are otherwise the same, so
2c2fa1
+		 we check for probes with prefixed names if probes
2c2fa1
+		 with unprefixed names are not present.  */
2c2fa1
+	      if (with_prefix)
2c2fa1
+		{
2c2fa1
+		  xsnprintf (buf, sizeof (buf), "rtld_%s", name);
2c2fa1
+		  name = buf;
2c2fa1
+		}
2c2fa1
+
2c2fa1
+	      probes[i] = find_probes_in_objfile (os->objfile, "rtld", name);
2c2fa1
+
2c2fa1
+	      /* The "map_failed" probe did not exist in early
2c2fa1
+		 versions of the probes code in which the probes'
2c2fa1
+		 names were prefixed with "rtld_".  */
2c2fa1
+	      if (strcmp (name, "rtld_map_failed") == 0)
2c2fa1
+		continue;
2c2fa1
+
2c2fa1
+	      if (VEC_empty (probe_p, probes[i]))
2c2fa1
+		{
2c2fa1
+		  all_probes_found = 0;
2c2fa1
+		  break;
2c2fa1
+		}
2c2fa1
+	    }
2c2fa1
+
2c2fa1
+	  if (all_probes_found)
2c2fa1
+	    svr4_create_probe_breakpoints (gdbarch, probes);
2c2fa1
+
2c2fa1
+	  for (i = 0; i < NUM_PROBES; i++)
2c2fa1
+	    VEC_free (probe_p, probes[i]);
2c2fa1
+
2c2fa1
+	  if (all_probes_found)
2c2fa1
+	    return;
2c2fa1
+	}
2c2fa1
+    }
2c2fa1
+
2c2fa1
+  create_solib_event_breakpoint (gdbarch, address);
2c2fa1
+}
2c2fa1
+
2c2fa1
 /* Helper function for gdb_bfd_lookup_symbol.  */
2c2fa1
 
2c2fa1
 static int
2c2fa1
@@ -1532,7 +2151,7 @@ enable_break (struct svr4_info *info, in
2c2fa1
 	 That knowledge is encoded in the address, if it's Thumb the low bit
2c2fa1
 	 is 1.  However, we've stripped that info above and it's not clear
2c2fa1
 	 what all the consequences are of passing a non-addr_bits_remove'd
2c2fa1
-	 address to create_solib_event_breakpoint.  The call to
2c2fa1
+	 address to svr4_create_solib_event_breakpoints.  The call to
2c2fa1
 	 find_pc_section verifies we know about the address and have some
2c2fa1
 	 hope of computing the right kind of breakpoint to use (via
2c2fa1
 	 symbol info).  It does mean that GDB needs to be pointed at a
2c2fa1
@@ -1570,7 +2189,7 @@ enable_break (struct svr4_info *info, in
2c2fa1
 		+ bfd_section_size (tmp_bfd, interp_sect);
2c2fa1
 	    }
2c2fa1
 
2c2fa1
-	  create_solib_event_breakpoint (target_gdbarch (), sym_addr);
2c2fa1
+	  svr4_create_solib_event_breakpoints (target_gdbarch (), sym_addr);
2c2fa1
 	  return 1;
2c2fa1
 	}
2c2fa1
     }
2c2fa1
@@ -1728,7 +2347,8 @@ enable_break (struct svr4_info *info, in
2c2fa1
 
2c2fa1
       if (sym_addr != 0)
2c2fa1
 	{
2c2fa1
-	  create_solib_event_breakpoint (target_gdbarch (), load_addr + sym_addr);
2c2fa1
+	  svr4_create_solib_event_breakpoints (target_gdbarch (),
2c2fa1
+					       load_addr + sym_addr);
2c2fa1
 	  xfree (interp_name);
2c2fa1
 	  return 1;
2c2fa1
 	}
2c2fa1
@@ -1754,7 +2374,7 @@ enable_break (struct svr4_info *info, in
2c2fa1
 	  sym_addr = gdbarch_convert_from_func_ptr_addr (target_gdbarch (),
2c2fa1
 							 sym_addr,
2c2fa1
 							 &current_target);
2c2fa1
-	  create_solib_event_breakpoint (target_gdbarch (), sym_addr);
2c2fa1
+	  svr4_create_solib_event_breakpoints (target_gdbarch (), sym_addr);
2c2fa1
 	  return 1;
2c2fa1
 	}
2c2fa1
     }
2c2fa1
@@ -1770,7 +2390,7 @@ enable_break (struct svr4_info *info, in
2c2fa1
 	      sym_addr = gdbarch_convert_from_func_ptr_addr (target_gdbarch (),
2c2fa1
 							     sym_addr,
2c2fa1
 							     &current_target);
2c2fa1
-	      create_solib_event_breakpoint (target_gdbarch (), sym_addr);
2c2fa1
+	      svr4_create_solib_event_breakpoints (target_gdbarch (), sym_addr);
2c2fa1
 	      return 1;
2c2fa1
 	    }
2c2fa1
 	}
2c2fa1
@@ -2266,6 +2886,10 @@ svr4_solib_create_inferior_hook (int fro
2c2fa1
 
2c2fa1
   info = get_svr4_info ();
2c2fa1
 
2c2fa1
+  /* Clear the probes-based interface's state.  */
2c2fa1
+  free_probes_table (info);
2c2fa1
+  free_solib_list (info);
2c2fa1
+
2c2fa1
   /* Relocate the main executable if necessary.  */
2c2fa1
   svr4_relocate_main_executable ();
2c2fa1
 
2c2fa1
@@ -2507,4 +3131,6 @@ _initialize_svr4_solib (void)
2c2fa1
   svr4_so_ops.lookup_lib_global_symbol = elf_lookup_lib_symbol;
2c2fa1
   svr4_so_ops.same = svr4_same;
2c2fa1
   svr4_so_ops.keep_data_in_core = svr4_keep_data_in_core;
2c2fa1
+  svr4_so_ops.update_breakpoints = svr4_update_solib_event_breakpoints;
2c2fa1
+  svr4_so_ops.handle_event = svr4_handle_solib_event;
2c2fa1
 }
2c2fa1
Index: gdb-7.6/gdb/solib.c
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.orig/gdb/solib.c	2013-06-10 14:44:37.392812675 +0200
2c2fa1
+++ gdb-7.6/gdb/solib.c	2013-06-10 14:44:37.713812578 +0200
2c2fa1
@@ -1221,6 +1221,37 @@ no_shared_libraries (char *ignored, int
2c2fa1
   objfile_purge_solibs ();
2c2fa1
 }
2c2fa1
 
2c2fa1
+/* See solib.h.  */
2c2fa1
+
2c2fa1
+void
2c2fa1
+update_solib_breakpoints (void)
2c2fa1
+{
2c2fa1
+  const struct target_so_ops *ops = solib_ops (target_gdbarch ());
2c2fa1
+
2c2fa1
+  if (ops->update_breakpoints != NULL)
2c2fa1
+    ops->update_breakpoints ();
2c2fa1
+}
2c2fa1
+
2c2fa1
+/* See solib.h.  */
2c2fa1
+
2c2fa1
+void
2c2fa1
+handle_solib_event (void)
2c2fa1
+{
2c2fa1
+  const struct target_so_ops *ops = solib_ops (target_gdbarch ());
2c2fa1
+
2c2fa1
+  if (ops->handle_event != NULL)
2c2fa1
+    ops->handle_event ();
2c2fa1
+
2c2fa1
+  clear_program_space_solib_cache (current_inferior ()->pspace);
2c2fa1
+
2c2fa1
+  /* Check for any newly added shared libraries if we're supposed to
2c2fa1
+     be adding them automatically.  Switch terminal for any messages
2c2fa1
+     produced by breakpoint_re_set.  */
2c2fa1
+  target_terminal_ours_for_output ();
2c2fa1
+  solib_add (NULL, 0, &current_target, auto_solib_add);
2c2fa1
+  target_terminal_inferior ();
2c2fa1
+}
2c2fa1
+
2c2fa1
 /* Reload shared libraries, but avoid reloading the same symbol file
2c2fa1
    we already have loaded.  */
2c2fa1
 
2c2fa1
Index: gdb-7.6/gdb/solib.h
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.orig/gdb/solib.h	2013-01-01 07:32:51.000000000 +0100
2c2fa1
+++ gdb-7.6/gdb/solib.h	2013-06-10 14:44:37.713812578 +0200
2c2fa1
@@ -90,4 +90,12 @@ extern CORE_ADDR gdb_bfd_lookup_symbol_f
2c2fa1
 								      void *),
2c2fa1
 						    void *data);
2c2fa1
 
2c2fa1
+/* Enable or disable optional solib event breakpoints as appropriate.  */
2c2fa1
+
2c2fa1
+extern void update_solib_breakpoints (void);
2c2fa1
+
2c2fa1
+/* Handle an solib event by calling solib_add.  */
2c2fa1
+
2c2fa1
+extern void handle_solib_event (void);
2c2fa1
+
2c2fa1
 #endif /* SOLIB_H */
2c2fa1
Index: gdb-7.6/gdb/solist.h
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.orig/gdb/solist.h	2013-01-01 07:32:51.000000000 +0100
2c2fa1
+++ gdb-7.6/gdb/solist.h	2013-06-10 14:44:37.713812578 +0200
2c2fa1
@@ -148,6 +148,19 @@ struct target_so_ops
2c2fa1
        core file (in particular, for readonly sections).  */
2c2fa1
     int (*keep_data_in_core) (CORE_ADDR vaddr,
2c2fa1
 			      unsigned long size);
2c2fa1
+
2c2fa1
+    /* Enable or disable optional solib event breakpoints as
2c2fa1
+       appropriate.  This should be called whenever
2c2fa1
+       stop_on_solib_events is changed.  This pointer can be
2c2fa1
+       NULL, in which case no enabling or disabling is necessary
2c2fa1
+       for this target.  */
2c2fa1
+    void (*update_breakpoints) (void);
2c2fa1
+
2c2fa1
+    /* Target-specific processing of solib events that will be
2c2fa1
+       performed before solib_add is called.  This pointer can be
2c2fa1
+       NULL, in which case no specific preprocessing is necessary
2c2fa1
+       for this target.  */
2c2fa1
+    void (*handle_event) (void);
2c2fa1
   };
2c2fa1
 
2c2fa1
 /* Free the memory associated with a (so_list *).  */
2c2fa1
Index: gdb-7.6/gdb/breakpoint.c
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.orig/gdb/breakpoint.c	2013-06-10 14:44:37.500812642 +0200
2c2fa1
+++ gdb-7.6/gdb/breakpoint.c	2013-06-10 14:44:57.301806708 +0200
2c2fa1
@@ -5348,25 +5348,6 @@ handle_jit_event (void)
2c2fa1
   target_terminal_inferior ();
2c2fa1
 }
2c2fa1
 
2c2fa1
-/* Handle an solib event by calling solib_add.  */
2c2fa1
-
2c2fa1
-void
2c2fa1
-handle_solib_event (void)
2c2fa1
-{
2c2fa1
-  clear_program_space_solib_cache (current_inferior ()->pspace);
2c2fa1
-
2c2fa1
-  /* Check for any newly added shared libraries if we're supposed to
2c2fa1
-     be adding them automatically.  Switch terminal for any messages
2c2fa1
-     produced by breakpoint_re_set.  */
2c2fa1
-  target_terminal_ours_for_output ();
2c2fa1
-#ifdef SOLIB_ADD
2c2fa1
-  SOLIB_ADD (NULL, 0, &current_target, auto_solib_add);
2c2fa1
-#else
2c2fa1
-  solib_add (NULL, 0, &current_target, auto_solib_add);
2c2fa1
-#endif
2c2fa1
-  target_terminal_inferior ();
2c2fa1
-}
2c2fa1
-
2c2fa1
 /* Prepare WHAT final decision for infrun.  */
2c2fa1
 
2c2fa1
 /* Decide what infrun needs to do with this bpstat.  */