From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16339 invoked by alias); 16 May 2013 14:43:45 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 16329 invoked by uid 89); 16 May 2013 14:43:45 -0000 X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.1 Received: from gbenson.demon.co.uk (HELO blade.nx) (80.177.220.214) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 16 May 2013 14:43:43 +0000 Received: by blade.nx (Postfix, from userid 500) id 72618263EAE; Thu, 16 May 2013 15:43:40 +0100 (BST) Date: Thu, 16 May 2013 14:43:00 -0000 From: Gary Benson To: gdb-patches@sourceware.org Subject: [RFA 0/7] Improved linker-debugger interface Message-ID: <20130516144340.GA2105@blade.nx> Mail-Followup-To: gdb-patches@sourceware.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-SW-Source: 2013-05/txt/msg00624.txt.bz2 Hi all, This is an updated version of a patch series I posted last year (I underestimated the disruption a baby can bring to your life!) The series implements an improved interface between glibc and GDB which significantly improves performance and fixes the following bug: https://bugzilla.redhat.com/show_bug.cgi?id=658851 http://sources.redhat.com/bugzilla/show_bug.cgi?id=2328 "_dl_debug_state() RT_CONSISTENT called too early" The existing linker-debugger interface has a structure (r_debug) containing a list of loaded libraries, and an empty function (_dl_debug_state) for debuggers to set breakpoints on and which the linker calls both before and after modifying this list. The problems with the current interface are as follows: - There is one place where glibc calls _dl_debug_state earlier than Solaris libc. This is PR 2328. The discrepancy means GDB reports libraries as loaded and ready before they really are. - There is also no provision for communicating what (if anything) has changed when _dl_debug_state is called. GDB must therefore load the entire list of loaded libraries at every stop. This hurts performance. - In normal use GDB only needs to stop _after_ the list is modified. Because _dl_debug_state is called both before and after changes, GDB stops twice as often as it needs to in most cases. This also hurts performance. glibc since 2.17 has named probes in the runtime linker, everywhere that _dl_debug_state is called, and an extra pair surrounding relocation events. By using this probes-based interface this patch series solves the above problems: - GDB can pick and choose which probes to set breakpoints on. By using the "relocation completed" probe instead of the one mirroring _dl_debug_state debuggers can stop after relocations have occurred, matching the behaviour of Solaris libc. - Probes adding new libraries supply the address of the link-map entry of the first newly added library. This enables GDB to skip past libraries it has already seen. - When stop-on-solib-events is unset, GDB does not have to stop before changes are made, only after. By disabling the "before" breakpoints the number of stops made can be halved. This patch series modifies GDB to search for named probes in the runtime linker, and to use them instead of _dl_debug_state if found. If the probes are not found then GDB will fall back to its previous behaviour. I've regression tested this natively and using gdbserver on RHEL 6.3 x86_64, with customized glibc rpms for the following setups: - A glibc with no probes. - A glibc with probes as they are in glibc 2.17. - A glibc with a slightly different set of probes that were originally shipped in Fedora 17 and in RHEL 6 since 6.2. A quick and dirty speed comparison yielded the following results: no of solibs 128 256 512 1024 2048 4096 -------------------------------------------------------------- old interface 0 1 4 12 47 185 new interface 0 0 2 4 10 36 (time in seconds) If it's more convenient, you can find a tree with this series applied in the gbenson/rtld-probes branch in archer git. Thanks, Gary -- http://gbenson.net/