Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 6 Dec 2018 17:56:00 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r486773 - in head/devel/gdb: . files
Message-ID:  <201812061756.wB6Hu0Lx068725@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 <git@bdragon.rtk0.net> (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 <jhb@FreeBSD.org>
+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 <sys/user.h>
++#include <libutil.h>
++#endif
++
+ #ifdef HAVE_SYS_RESOURCE_H
+ #include <sys/resource.h>
+ #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<struct kinfo_file[]> 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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201812061756.wB6Hu0Lx068725>