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