From owner-freebsd-toolchain@FreeBSD.ORG Sun Apr 15 14:43:30 2012 Return-Path: Delivered-To: freebsd-toolchain@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B91FB106564A; Sun, 15 Apr 2012 14:43:30 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 4F7428FC14; Sun, 15 Apr 2012 14:43:30 +0000 (UTC) Received: from skuns.kiev.zoral.com.ua (localhost [127.0.0.1]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id q3FEhNYn021654; Sun, 15 Apr 2012 17:43:23 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5) with ESMTP id q3FEhNGS003928; Sun, 15 Apr 2012 17:43:23 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5/Submit) id q3FEhMZO003927; Sun, 15 Apr 2012 17:43:22 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Sun, 15 Apr 2012 17:43:22 +0300 From: Konstantin Belousov To: John Marino Message-ID: <20120415144322.GU2358@deviant.kiev.zoral.com.ua> References: <4F3C5A3A.6050107@FreeBSD.org> <20120216154730.GL3283@deviant.kiev.zoral.com.ua> <4F5C7764.2@marino.st> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="+MW5NjnblUaFJVG7" Content-Disposition: inline In-Reply-To: <4F5C7764.2@marino.st> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.0 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: kan@freebsd.org, Pedro Giffuni , freebsd-toolchain@freebsd.org Subject: Re: DragonFly added DT_GNU_HASH support to rtld X-BeenThere: freebsd-toolchain@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Maintenance of FreeBSD's integrated toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Apr 2012 14:43:30 -0000 --+MW5NjnblUaFJVG7 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Mar 11, 2012 at 10:59:00AM +0100, John Marino wrote: > Hi Konstantin, >=20 > It seems that no BSD supported DT_GNU_HASH despite this option being=20 > available on the base binutils (FreeBSD's 2.17.50 binutils supports it).= =20 > This gnu extension is a big performance improvement over the specified= =20 > SysV hash. >=20 > The guy porting libreoffice to pkgsrc was finding -Wl,--hash-style=3Dgnu= =20 > to be the default build for that package. Indeed, using the standard=20 > hash results in very long startup times for something like Writer (> 8=20 > seconds launched from a SSD) >=20 > The result is that we brought in DT_GNU_HASH support to our real-time=20 > linker this weekend. We're still waiting to see how that improves=20 > libreoffice startup times. >=20 > full commit: > >http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/7629c6317998f850= ebca23c296822ba08af09e5b >=20 >=20 > Modification to base compiler so all system libs and binaries can take=20 > advantage of it: > >http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/4687ecd9561d76f3= d02ccb4f7adeecd5e3afdd8f >=20 >=20 > For a while, binaries with dynamic symbol tables will have both types of= =20 > hashes embedded. At some point in the future, we may switch over to=20 > only generating the GNU hash. This will break forward compatibility,=20 > but that happens rather frequently for other reasons anyway. >=20 > I was a bit surprised FreeBSD didn't already have this functionality=20 > given the performance benefits, so hopefully these DragonFly commits=20 > will be interesting for you. >=20 I finally ported the Dragonfly commit to FreeBSD. There were several changes reverted in dragonfly version of the extracted matched_symbol() function which were restored. I also blindly converted all non-x86 arches. The matched_symbol() extraction is the good opportunity to apply the style(9) formatting to the large chunk of rtld code. Any testers, esp. on non-x86 architectures, are welcome. You would need to modify gcc spec file for you architecture, see corresponding x86 changes in contrib/gcc/config/i386. For me, patch successfully worked on the machine were I disabled sysv hashes at all. http://people.freebsd.org/~kib/misc/rtld-gnu_hash.1.patch --+MW5NjnblUaFJVG7 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (FreeBSD) iEYEARECAAYFAk+K3ooACgkQC3+MBN1Mb4haUACg4ghZ+fyg8IWHKK3sU6Llffod fisAnjE/ACZRQ0QSrgc2qTXmS1ols5GA =lFUl -----END PGP SIGNATURE----- --+MW5NjnblUaFJVG7-- From owner-freebsd-toolchain@FreeBSD.ORG Mon Apr 16 04:55:55 2012 Return-Path: Delivered-To: toolchain@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 35197106566C for ; Mon, 16 Apr 2012 04:55:55 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id A6A9D8FC08 for ; Mon, 16 Apr 2012 04:55:54 +0000 (UTC) Received: from skuns.kiev.zoral.com.ua (localhost [127.0.0.1]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id q3G4tpoT099733; Mon, 16 Apr 2012 07:55:51 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5) with ESMTP id q3G4tp5v080671; Mon, 16 Apr 2012 07:55:51 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5/Submit) id q3G4tpZ2080670; Mon, 16 Apr 2012 07:55:51 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 16 Apr 2012 07:55:51 +0300 From: Konstantin Belousov To: Dmitry Mikulin Message-ID: <20120416045551.GZ2358@deviant.kiev.zoral.com.ua> References: <4F8737E9.6010300@juniper.net> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="JvcmYpkcIfvRd+Gm" Content-Disposition: inline In-Reply-To: <4F8737E9.6010300@juniper.net> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.0 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: toolchain@freebsd.org Subject: Re: gdb support for follow-fork X-BeenThere: freebsd-toolchain@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Maintenance of FreeBSD's integrated toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Apr 2012 04:55:55 -0000 --JvcmYpkcIfvRd+Gm Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Apr 12, 2012 at 01:15:37PM -0700, Dmitry Mikulin wrote: > Hi, >=20 > I implemented support for follow-fork mode in gdb and would like to submi= t=20 > it for a review. The feature allows users to specify which process to=20 > follow when the inferior does a fork(). The default mode is to stay with= =20 > the parent. A gdb command is used to switch between following the=20 > child/parent: >=20 > set follow-fork-mode child > set follow-fork-mode parent >=20 > When gdb is set to follow the child, it detaches from the parent at the= =20 > fork() point and continues to trace the newly created child. >=20 > Gdb uses support that has recently been implemented in the FreeBSD kernel= .=20 > A new ptrace() request, PT_FOLLOW_FORK was added to generate a SIGTRAP at= =20 > the point where a child process is created. This allows gdb switch from= =20 > parent to child. PT_FOLLOW_EXEC was added to SIGTRAP on return from exit(= )=20 > to allow gdb to load a new binary for debugging. >=20 > I attached the patch here. > Please let me know if can provide additional info. Yes, could you, please, split the patch somewhat ? It would be much easier to review if you were able to provide relatively small pieces with descriptions. --JvcmYpkcIfvRd+Gm Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (FreeBSD) iEYEARECAAYFAk+LplYACgkQC3+MBN1Mb4jKIACfQPHnrrTi5ROomB2yR776Vmy8 bJcAoNFL61TdqVkVw4nizSSLgZK185Om =HiE6 -----END PGP SIGNATURE----- --JvcmYpkcIfvRd+Gm-- From owner-freebsd-toolchain@FreeBSD.ORG Mon Apr 16 17:51:23 2012 Return-Path: Delivered-To: toolchain@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id AEB61106566B for ; Mon, 16 Apr 2012 17:51:23 +0000 (UTC) (envelope-from dmitrym@juniper.net) Received: from exprod7og116.obsmtp.com (exprod7og116.obsmtp.com [64.18.2.219]) by mx1.freebsd.org (Postfix) with ESMTP id 573348FC08 for ; Mon, 16 Apr 2012 17:51:23 +0000 (UTC) Received: from P-EMHUB01-HQ.jnpr.net ([66.129.224.36]) (using TLSv1) by exprod7ob116.postini.com ([64.18.6.12]) with SMTP ID DSNKT4xcFTO78UcIYuX0x0VWtEqMrSntYx7S@postini.com; Mon, 16 Apr 2012 10:51:23 PDT Received: from magenta.juniper.net (172.17.27.123) by P-EMHUB01-HQ.jnpr.net (172.24.192.33) with Microsoft SMTP Server (TLS) id 8.3.213.0; Mon, 16 Apr 2012 10:49:39 -0700 Received: from [172.24.26.191] (dmitrym-lnx.jnpr.net [172.24.26.191]) by magenta.juniper.net (8.11.3/8.11.3) with ESMTP id q3GHnd110736; Mon, 16 Apr 2012 10:49:39 -0700 (PDT) (envelope-from dmitrym@juniper.net) Message-ID: <4F8C5BAF.70507@juniper.net> Date: Mon, 16 Apr 2012 10:49:35 -0700 From: Dmitry Mikulin User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120329 Thunderbird/11.0.1 MIME-Version: 1.0 To: Konstantin Belousov References: <4F8737E9.6010300@juniper.net> <20120416045551.GZ2358@deviant.kiev.zoral.com.ua> In-Reply-To: <20120416045551.GZ2358@deviant.kiev.zoral.com.ua> Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit Cc: "toolchain@freebsd.org" Subject: Re: gdb support for follow-fork X-BeenThere: freebsd-toolchain@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Maintenance of FreeBSD's integrated toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Apr 2012 17:51:23 -0000 > Yes, could you, please, split the patch somewhat ? > It would be much easier to review if you were able to provide relatively > small pieces with descriptions. I don't think I can split it into independent functioning pieces, but I can group the changes logically and explain them in a bit more detail. I'll go by groups of files. 1. These files contain added initialization for a new fbsd target specific file fbsd-nat.c. The same change is applied to every supported target architecture. A call to _initialize_fbsdnat() is added and fbsd-nat.o is added to the make files. gnu/usr.bin/gdb/arch/arm/init.c gnu/usr.bin/gdb/arch/arm/Makefile gnu/usr.bin/gdb/arch/powerpc/init.c gnu/usr.bin/gdb/arch/powerpc/Makefile gnu/usr.bin/gdb/arch/sparc64/init.c gnu/usr.bin/gdb/arch/ia64/init.c gnu/usr.bin/gdb/arch/ia64/Makefile gnu/usr.bin/gdb/arch/mips/init.c gnu/usr.bin/gdb/arch/mips/Makefile gnu/usr.bin/gdb/arch/i386/init.c gnu/usr.bin/gdb/arch/i386/Makefile gnu/usr.bin/gdb/arch/powerpc64/init.c gnu/usr.bin/gdb/arch/powerpc64/Makefile gnu/usr.bin/gdb/arch/amd64/init.c gnu/usr.bin/gdb/arch/amd64/Makefile 2. Added target specific verions of follow_fork() and follow_exec() contrib/gdb/gdb/target.c contrib/gdb/gdb/target.h 3. Added an external interface to check if the thread list is empty. contrib/gdb/gdb/thread.c contrib/gdb/gdb/gdbthread.h 4. Added 2 new interfaces to clear step-resume breakpoint info; switched to target specific follow-fork. contrib/gdb/gdb/infrun.c 5. Fix for a problem re-loading binaries after fork-exec. contrib/gdb/gdb/objfiles.c 6. This is where the 'meat' of the implementation is. fbsd-nat.c is a new file which contains FreeBSD specific functions to handle follow-fork and follow-exec. fbsd_wait() is added to handle stops attributed to fork() and exec() and to translate those stops into target independent info that handle_inferior_event() can understand. fbsd_follow_fork() manages the switch-over from parent to child when gdb is to follow the child or manages a clean detach from the child when gdb is to follow the parent. fbsd_follow_exec() manages the switch-over from one symbol file to another when gdb is stopped after a successful exec() in the inferior. gnu/usr.bin/gdb/libgdb/fbsd-nat.c The changes here deal with the fact that thread state if a process gdb is tracing changes after fork() when we follow the child and exec(). gnu/usr.bin/gdb/libgdb/fbsd-threads.c