From 0f48b757071509040d800ff9f7c8726e5828bd1a Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Fri, 1 Jul 2016 11:16:32 +0100 Subject: Factor out "Detaching from program" message printing Several targets have a copy of the same code that prints "Detaching from program ..." in their target_detach implementation. Factor that out to a common function. (For now, I left the couple targets that print this a bit differently alone. Maybe this could be further pulled out into infcmd.c. If we did that, and those targets want to continue printing differently, this new function could be converted to a target method.) gdb/ChangeLog: 2016-07-01 Pedro Alves * 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. --- gdb/target.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'gdb/target.c') diff --git a/gdb/target.c b/gdb/target.c index bb86adf..d3fc35b 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -3251,6 +3251,28 @@ find_target_at (enum strata stratum) } + +/* 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 -- cgit v1.1