+ do_cleanups (old_chain);
+}
+
+/* See gdbcore.h. */
+
+void
+exec_file_locate_attach (int pid, int defer_bp_reset, int from_tty)
+{
+ char *exec_file_target, *exec_file_host;
+ struct cleanup *old_chain;
+ symfile_add_flags add_flags = 0;
+
+ /* Do nothing if we already have an executable filename. */
+ if (get_exec_file (0) != NULL)
+ return;
+
+ /* Try to determine a filename from the process itself. */
+ exec_file_target = target_pid_to_exec_file (pid);
+ if (exec_file_target == NULL)
+ {
+ warning (_("No executable has been specified and target does not "
+ "support\n"
+ "determining executable automatically. "
+ "Try using the \"file\" command."));
+ return;
+ }
+
+ exec_file_host = exec_file_find (exec_file_target, NULL);
+ old_chain = make_cleanup (xfree, exec_file_host);
+
+ if (defer_bp_reset)
+ add_flags |= SYMFILE_DEFER_BP_RESET;
+
+ if (from_tty)
+ add_flags |= SYMFILE_VERBOSE;
+
+ /* Attempt to open the exec file. */
+ try_open_exec_file (exec_file_host, current_inferior (), add_flags);
+ do_cleanups (old_chain);