+/* Find all the glibc named probes. Only if all of the probes are found, then
+ create them and return true. Otherwise return false. If WITH_PREFIX is set
+ then add "rtld" to the front of the probe names. */
+static bool
+svr4_find_and_create_probe_breakpoints (svr4_info *info,
+ struct gdbarch *gdbarch,
+ struct obj_section *os,
+ bool with_prefix)
+{
+ std::vector<probe *> probes[NUM_PROBES];
+
+ for (int i = 0; i < NUM_PROBES; i++)
+ {
+ const char *name = probe_info[i].name;
+ char buf[32];
+
+ /* Fedora 17 and Red Hat Enterprise Linux 6.2-6.4 shipped with an early
+ version of the probes code in which the probes' names were prefixed
+ with "rtld_" and the "map_failed" probe did not exist. The locations
+ of the probes are otherwise the same, so we check for probes with
+ prefixed names if probes with unprefixed names are not present. */
+ if (with_prefix)
+ {
+ xsnprintf (buf, sizeof (buf), "rtld_%s", name);
+ name = buf;
+ }
+
+ probes[i] = find_probes_in_objfile (os->objfile, "rtld", name);
+
+ /* The "map_failed" probe did not exist in early
+ versions of the probes code in which the probes'
+ names were prefixed with "rtld_". */
+ if (with_prefix && streq (name, "rtld_map_failed"))
+ continue;
+
+ /* Ensure at least one probe for the current name was found. */
+ if (probes[i].empty ())
+ return false;
+
+ /* Ensure probe arguments can be evaluated. */
+ for (probe *p : probes[i])
+ {
+ if (!p->can_evaluate_arguments ())
+ return false;
+ /* This will fail if the probe is invalid. This has been seen on Arm
+ due to references to symbols that have been resolved away. */
+ try
+ {
+ p->get_argument_count (gdbarch);
+ }
+ catch (const gdb_exception_error &ex)
+ {
+ exception_print (gdb_stderr, ex);
+ warning (_("Initializing probes-based dynamic linker interface "
+ "failed.\nReverting to original interface."));
+ return false;
+ }
+ }
+ }
+
+ /* All probes found. Now create them. */
+ svr4_create_probe_breakpoints (info, gdbarch, probes, os->objfile);
+ return true;
+}
+