From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.baldwin.cx (bigwig.baldwin.cx [96.47.65.170]) by sourceware.org (Postfix) with ESMTP id CC27B3850419 for ; Mon, 20 Jul 2020 17:43:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org CC27B3850419 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=FreeBSD.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=jhb@FreeBSD.org Received: from ralph.com (unknown [71.198.231.75]) by mail.baldwin.cx (Postfix) with ESMTPSA id B060010A766 for ; Mon, 20 Jul 2020 13:33:16 -0400 (EDT) From: John Baldwin To: gdb-patches@sourceware.org Subject: [PATCH 2/5] Assume KERN_PROC_PATHNAME is present on FreeBSD hosts. Date: Mon, 20 Jul 2020 10:31:33 -0700 Message-Id: <20200720173136.10514-3-jhb@FreeBSD.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200720173136.10514-1-jhb@FreeBSD.org> References: <20200720173136.10514-1-jhb@FreeBSD.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (mail.baldwin.cx); Mon, 20 Jul 2020 13:33:17 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.99.2 at mail.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_STATUS, KHOP_HELO_FCRDNS, SPF_HELO_PASS, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org 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: , X-List-Received-Date: Mon, 20 Jul 2020 17:43:09 -0000 FreeBSD kernels have included this sysctl since 6.0 release. The most recent release without support is 5.5 which was released in May of 2006. gdb/ChangeLog: * fbsd-nat.c (fbsd_nat_target::pid_to_exec_file): Always use sysctl and remove procfs fallback. --- gdb/ChangeLog | 5 +++++ gdb/fbsd-nat.c | 13 ------------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 687d9aede5..0339083f1a 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2020-07-20 John Baldwin + + * fbsd-nat.c (fbsd_nat_target::pid_to_exec_file): Always use + sysctl and remove procfs fallback. + 2020-07-20 John Baldwin * fbsd-nat.c: Assume PT_LWPINFO is always defined. diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c index fc7136a97c..6193e0fbde 100644 --- a/gdb/fbsd-nat.c +++ b/gdb/fbsd-nat.c @@ -53,11 +53,7 @@ char * fbsd_nat_target::pid_to_exec_file (int pid) { - ssize_t len; static char buf[PATH_MAX]; - char name[PATH_MAX]; - -#ifdef KERN_PROC_PATHNAME size_t buflen; int mib[4]; @@ -71,15 +67,6 @@ fbsd_nat_target::pid_to_exec_file (int pid) for processes without an associated executable such as kernel processes. */ return buflen == 0 ? NULL : buf; -#endif - - xsnprintf (name, PATH_MAX, "/proc/%d/exe", pid); - len = readlink (name, buf, PATH_MAX - 1); - if (len != -1) - { - buf[len] = '\0'; - return buf; - } return NULL; } -- 2.25.1