+2016-07-01 Pedro Alves <palves@redhat.com>
+
+ * darwin-nat.c (darwin_detach): Use target_announce_detach.
+ * inf-ptrace.c (inf_ptrace_detach): Likewise.
+ * nto-procfs.c (procfs_detach): Likewise.
+ * remote.c (remote_detach_1): Likewise.
+ * target.c (target_announce_detach): New function.
+ * target.h (target_announce_detach): New declaration.
+
2016-06-29 Tom Tromey <tom@tromey.com>
PR python/20129:
int res;
/* Display message. */
- if (from_tty)
- {
- char *exec_file = get_exec_file (0);
- if (exec_file == 0)
- exec_file = "";
- printf_unfiltered (_("Detaching from program: %s, %s\n"), exec_file,
- target_pid_to_str (pid_to_ptid (pid)));
- gdb_flush (gdb_stdout);
- }
+ target_announce_detach (from_tty);
/* If ptrace() is in use, stop the process. */
if (!inf->priv->no_ptrace)
pid_t pid = ptid_get_pid (inferior_ptid);
int sig = 0;
- if (from_tty)
- {
- char *exec_file = get_exec_file (0);
- if (exec_file == 0)
- exec_file = "";
- printf_unfiltered (_("Detaching from program: %s, %s\n"), exec_file,
- target_pid_to_str (pid_to_ptid (pid)));
- gdb_flush (gdb_stdout);
- }
+ target_announce_detach (from_tty);
if (args)
sig = atoi (args);
int siggnal = 0;
int pid;
- if (from_tty)
- {
- char *exec_file = get_exec_file (0);
- if (exec_file == 0)
- exec_file = "";
- printf_unfiltered ("Detaching from program: %s %s\n",
- exec_file, target_pid_to_str (inferior_ptid));
- gdb_flush (gdb_stdout);
- }
+ target_announce_detach ();
+
if (args)
siggnal = atoi (args);
if (!target_has_execution)
error (_("No process to detach from."));
- if (from_tty)
- {
- char *exec_file = get_exec_file (0);
- if (exec_file == NULL)
- exec_file = "";
- printf_unfiltered (_("Detaching from program: %s, %s\n"), exec_file,
- target_pid_to_str (pid_to_ptid (pid)));
- gdb_flush (gdb_stdout);
- }
+ target_announce_detach (from_tty);
/* Tell the remote target to detach. */
remote_detach_pid (pid);
}
\f
+
+/* See target.h */
+
+void
+target_announce_detach (int from_tty)
+{
+ pid_t pid;
+ char *exec_file;
+
+ if (!from_tty)
+ return;
+
+ exec_file = get_exec_file (0);
+ if (exec_file == NULL)
+ exec_file = "";
+
+ pid = ptid_get_pid (inferior_ptid);
+ printf_unfiltered (_("Detaching from program: %s, %s\n"), exec_file,
+ target_pid_to_str (pid_to_ptid (pid)));
+ gdb_flush (gdb_stdout);
+}
+
/* The inferior process has died. Long live the inferior! */
void
#define target_post_attach(pid) \
(*current_target.to_post_attach) (¤t_target, pid)
+/* Display a message indicating we're about to detach from the current
+ inferior process. */
+
+extern void target_announce_detach (int from_tty);
+
/* Takes a program previously attached to and detaches it.
The program may resume execution (some targets do, some don't) and will
no longer stop on signals, etc. We better not have left any breakpoints