From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id UKhyDZPc1WHtWAAAWB0awg (envelope-from ) for ; Wed, 05 Jan 2022 12:59:47 -0500 Received: by simark.ca (Postfix, from userid 112) id 338641EE18; Wed, 5 Jan 2022 12:59:47 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 91BC21EAA4 for ; Wed, 5 Jan 2022 12:59:46 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E19BF3858439 for ; Wed, 5 Jan 2022 17:59:45 +0000 (GMT) Received: from progateway7-pub.mail.pro1.eigbox.com (gproxy5-pub.mail.unifiedlayer.com [67.222.38.55]) by sourceware.org (Postfix) with ESMTPS id 62D30385840C for ; Wed, 5 Jan 2022 17:59:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 62D30385840C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw11.mail.unifiedlayer.com (unknown [10.0.90.126]) by progateway7.mail.pro1.eigbox.com (Postfix) with ESMTP id CBBB310048ABB for ; Wed, 5 Jan 2022 17:59:20 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id 5AZEnyLOcwm8i5AZEnvdTB; Wed, 05 Jan 2022 17:59:20 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=DpSTREz+ c=1 sm=1 tr=0 ts=61d5dc78 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=DghFqjY3_ZEA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=RMySY_FS6Jdn2vUmyd4A:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=HAR1LVek60aOrxtaYpvKuSWiG/xezcwrxWtDsYPPptc=; b=L6ScjEE9LYUdg8x1GoHYd9C9hB T84l+mv9vsSwyjYV6b3BQJGkuDcFUwstY3yi0vT0FOjUmS28e7rYT33ppE+dgY7BnwXAJAH4Du/Hw 0d/HPgGk9ArnofMdvZBfIhVWk; Received: from 75-166-134-30.hlrn.qwest.net ([75.166.134.30]:52060 helo=prentzel.Home) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1n5AZD-002Z8v-J1; Wed, 05 Jan 2022 10:59:19 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Subject: [PATCH 2/2] Use target_announce_detach in more targets Date: Wed, 5 Jan 2022 10:59:16 -0700 Message-Id: <20220105175916.2969966-3-tom@tromey.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220105175916.2969966-1-tom@tromey.com> References: <20220105175916.2969966-1-tom@tromey.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 75.166.134.30 X-Source-L: No X-Exim-ID: 1n5AZD-002Z8v-J1 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-134-30.hlrn.qwest.net (prentzel.Home) [75.166.134.30]:52060 X-Source-Auth: tom+tromey.com X-Email-Count: 6 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tom Tromey Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" target_announce_detach was added in commit 0f48b757 ("Factor out "Detaching from program" message printing"). There, Pedro wrote: (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.) It seems to me that the differences aren't very big, and in some cases other targets handled the output a bit more nicely. In particular, some targets will print a different message when exec_file==NULL, rather than printing the same output with an empty string as exec_file. This patch incorporates the nicer output into target_announce_detach, then changes the remaining ports to use this function. --- gdb/gnu-nat.c | 11 +---------- gdb/procfs.c | 14 +------------- gdb/target.c | 13 +++++++------ gdb/windows-nat.c | 10 ++-------- 4 files changed, 11 insertions(+), 37 deletions(-) diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c index ad870c94d63..b6bccd8b4b7 100644 --- a/gdb/gnu-nat.c +++ b/gdb/gnu-nat.c @@ -2215,16 +2215,7 @@ gnu_nat_target::attach (const char *args, int from_tty) void gnu_nat_target::detach (inferior *inf, int from_tty) { - if (from_tty) - { - const char *exec_file = get_exec_file (0); - - if (exec_file) - printf_unfiltered ("Detaching from program `%s' pid %d\n", - exec_file, gnu_current_inf->pid); - else - printf_unfiltered ("Detaching from pid %d\n", gnu_current_inf->pid); - } + target_announce_detach (from_tty); inf_detach (gnu_current_inf); diff --git a/gdb/procfs.c b/gdb/procfs.c index ddc8623b1e1..840201d1897 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -1786,19 +1786,7 @@ procfs_target::attach (const char *args, int from_tty) void procfs_target::detach (inferior *inf, int from_tty) { - int pid = inferior_ptid.pid (); - - if (from_tty) - { - const char *exec_file; - - exec_file = get_exec_file (0); - if (exec_file == NULL) - exec_file = ""; - - printf_filtered (_("Detaching from program: %s, %s\n"), exec_file, - target_pid_to_str (ptid_t (pid)).c_str ()); - } + target_announce_detach (from_tty); do_detach (); diff --git a/gdb/target.c b/gdb/target.c index 65b98c5a9b8..90a279b2902 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -3628,13 +3628,14 @@ target_announce_detach (int from_tty) if (!from_tty) return; - exec_file = get_exec_file (0); - if (exec_file == NULL) - exec_file = ""; - pid = inferior_ptid.pid (); - printf_unfiltered (_("Detaching from program: %s, %s\n"), exec_file, - target_pid_to_str (ptid_t (pid)).c_str ()); + exec_file = get_exec_file (0); + if (exec_file == nullptr) + printf_unfiltered ("Detaching from pid %s\n", + target_pid_to_str (ptid_t (pid)).c_str ()); + else + printf_unfiltered (_("Detaching from program: %s, %s\n"), exec_file, + target_pid_to_str (ptid_t (pid)).c_str ()); } /* See target.h */ diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index 89084acabaa..0faf138c0c7 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -1965,14 +1965,8 @@ windows_nat_target::detach (inferior *inf, int from_tty) } DebugSetProcessKillOnExit (FALSE); - if (detached && from_tty) - { - const char *exec_file = get_exec_file (0); - if (exec_file == 0) - exec_file = ""; - printf_unfiltered ("Detaching from program: %s, Pid %u\n", exec_file, - (unsigned) current_event.dwProcessId); - } + if (detached) + target_announce_detach (from_tty); x86_cleanup_dregs (); switch_to_no_thread (); -- 2.31.1