From owner-svn-ports-all@freebsd.org Thu Dec 6 17:56:01 2018 Return-Path: Delivered-To: svn-ports-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2C453130D2D7; Thu, 6 Dec 2018 17:56:01 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C3DEA77B21; Thu, 6 Dec 2018 17:56:00 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A4D9B27178; Thu, 6 Dec 2018 17:56:00 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id wB6Hu0AC068727; Thu, 6 Dec 2018 17:56:00 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id wB6Hu0Lx068725; Thu, 6 Dec 2018 17:56:00 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201812061756.wB6Hu0Lx068725@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Thu, 6 Dec 2018 17:56:00 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r486773 - in head/devel/gdb: . files X-SVN-Group: ports-head X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in head/devel/gdb: . files X-SVN-Commit-Revision: 486773 X-SVN-Commit-Repository: ports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: C3DEA77B21 X-Spamd-Result: default: False [-1.76 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_SHORT(-0.84)[-0.840,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_MEDIUM(-0.87)[-0.865,0]; NEURAL_HAM_LONG(-0.05)[-0.054,0] X-Rspamd-Server: mx1.freebsd.org X-BeenThere: svn-ports-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the ports tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Dec 2018 17:56:01 -0000 Author: jhb (src,doc committer) Date: Thu Dec 6 17:55:59 2018 New Revision: 486773 URL: https://svnweb.freebsd.org/changeset/ports/486773 Log: Speed up devel/gdb startup on FreeBSD On non-Linux systems that do not have fdwalk(), gdb currently iterates over all possible file descriptors when checking for open files. Merge an upstream patch that fixes this by adding a FreeBSD implementation using kinfo_getfile(). Submitted by: Brandon Bergren (initial patch) Reviewed by: pizzamig (maintainer) Differential Revision: https://reviews.freebsd.org/D17426 Added: head/devel/gdb/files/commit-93579f6f90 (contents, props changed) Modified: head/devel/gdb/Makefile Modified: head/devel/gdb/Makefile ============================================================================== --- head/devel/gdb/Makefile Thu Dec 6 17:50:54 2018 (r486772) +++ head/devel/gdb/Makefile Thu Dec 6 17:55:59 2018 (r486773) @@ -3,6 +3,7 @@ PORTNAME= gdb PORTVERSION= 8.2 +PORTREVISION= 1 CATEGORIES= devel MASTER_SITES= GNU @@ -38,7 +39,8 @@ CFLAGS+= -DRL_NO_COMPAT -Wno-unused-function -Wno-unus CFLAGS+= -Wno-unknown-warning-option EXCLUDE= dejagnu expect sim texinfo intl EXTRACT_AFTER_ARGS= ${EXCLUDE:S/^/--exclude /} -EXTRA_PATCHES= ${FILESDIR}/commit-8aa0243d54 +EXTRA_PATCHES= ${FILESDIR}/commit-8aa0243d54 \ + ${FILESDIR}/commit-93579f6f90 LIB_DEPENDS+= libexpat.so:textproc/expat2 VER= ${PORTVERSION:S/.//g} Added: head/devel/gdb/files/commit-93579f6f90 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/devel/gdb/files/commit-93579f6f90 Thu Dec 6 17:55:59 2018 (r486773) @@ -0,0 +1,57 @@ +commit 93579f6f908fa6010b141fd5da2974d878869c80 +Author: John Baldwin +Date: Fri Nov 30 15:14:18 2018 -0800 + + Use kinfo_getfile to implement fdwalk on FreeBSD. + + kinfo_getfile() requires a couple of system calls to fetch the list of + open file descriptors. This can be much cheaper than invoking fstat + on all of the values from 0 to the open file resource limit maximum. + + gdb/ChangeLog: + + * common/filestuff.c [HAVE_KINFO_GETFILE]: Include headers. + (fdwalk) [HAVE_KINFO_GETFILE]: Use kinfo_getfile. + +diff --git gdb/common/filestuff.c gdb/common/filestuff.c +index 0db5c6936b..f4d5e38f07 100644 +--- gdb/common/filestuff.c ++++ gdb/common/filestuff.c +@@ -36,6 +36,11 @@ + #define HAVE_SOCKETS 1 + #endif + ++#ifdef HAVE_KINFO_GETFILE ++#include ++#include ++#endif ++ + #ifdef HAVE_SYS_RESOURCE_H + #include + #endif /* HAVE_SYS_RESOURCE_H */ +@@ -108,6 +113,25 @@ fdwalk (int (*func) (void *, int), void *arg) + } + /* We may fall through to the next case. */ + #endif ++#ifdef HAVE_KINFO_GETFILE ++ int nfd; ++ gdb::unique_xmalloc_ptr fdtbl ++ (kinfo_getfile (getpid (), &nfd)); ++ if (fdtbl != NULL) ++ { ++ for (int i = 0; i < nfd; i++) ++ { ++ if (fdtbl[i].kf_fd >= 0) ++ { ++ int result = func (arg, fdtbl[i].kf_fd); ++ if (result != 0) ++ return result; ++ } ++ } ++ return 0; ++ } ++ /* We may fall through to the next case. */ ++#endif + + { + int max, fd;