From owner-freebsd-hackers@FreeBSD.ORG Fri Oct 29 19:18:45 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 161221065693 for ; Fri, 29 Oct 2010 19:18:45 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-qy0-f175.google.com (mail-qy0-f175.google.com [209.85.216.175]) by mx1.freebsd.org (Postfix) with ESMTP id C11158FC12 for ; Fri, 29 Oct 2010 19:18:44 +0000 (UTC) Received: by qyk7 with SMTP id 7so6298463qyk.13 for ; Fri, 29 Oct 2010 12:18:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:subject :message-id:mime-version:content-type:content-disposition:user-agent; bh=H3Mzut5iqEfqZPIhV4gdhhy0JseNDYmpeQ/IUW0n2Yk=; b=uhVFfWqiVRlObt4hk/UUB0xi0UDch0UQD6sIfte7bpGg9gY4GKU7KAfG7mweW2CoRi 87xW3TvmrfRba6eCYHaTuKMX1Bo05vK3PGgNwA723Zk2OtaBryeXT1cpJBmnineGMlNU RfbB4Y9m6d5xq2uHOZqp8Ml4HK6eGYejlW1Tk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:subject:message-id:mime-version:content-type :content-disposition:user-agent; b=kiwgZN2Yu4TlFnZz/GNQWoJjPs/C57LndQSXRfLerQ4fB4FAbPdQvKzuutxIqjvd+6 tImiNSlDUKBr6g6QMaK7cmZ17JgRP5EqQufQAE4hhfkk1PoTDkPvRi08tp1/y1/sPttY NNBZk9m6O2DbZPc30PawHGRwmF/kVWXnndBUc= Received: by 10.224.177.205 with SMTP id bj13mr5317775qab.170.1288379923820; Fri, 29 Oct 2010 12:18:43 -0700 (PDT) Received: from mark-laptop-bsd.mark-home (mail1.sandvine.com [64.7.137.162]) by mx.google.com with ESMTPS id n7sm2597986qcu.40.2010.10.29.12.18.42 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 29 Oct 2010 12:18:43 -0700 (PDT) Date: Fri, 29 Oct 2010 15:18:27 -0400 From: Mark Johnston To: freebsd-hackers@freebsd.org Message-ID: <20101029191827.GC1443@mark-laptop-bsd.mark-home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Subject: Generating userland debugging symbols X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Oct 2010 19:18:45 -0000 Hello all, I've been working on some changes to the system build scripts that make it easier to create and install debugging symbols files for the base userland. What we do in the tree at my work (Sandvine) is use a script that invokes strip(1) and objcopy(1) to create a separate file containing the debugging symbols for each binary; so for example, the symbols for /bin/ls get placed in another directory, e.g. /usr/local/lib/debug/bin/ls.symbols. The name of the symbols file for each binary is encoded in the .gnu_debuglink segment; when gdb comes across it, it searches a set of directories for the debug symbols file and loads it if found. It turns out to be pretty convenient - one can keep the debugging symbols on a separate slice or on an NFS-mounted directory if space is an issue, or package the debug symbols separately and keep them on an FTP server, ready to install if needed. I'm not aware of any infrastructure in place that makes it easy to do this for the userland programs. What I'm hoping to find out is whether there's any interest in adding such support. I've discussed this with Ed Maste to some degree, but it'd be nice to get some additional feedback. My basic idea is to add an option to /etc/src.conf that indicates that the build system should build all the userland programs with debugging symbols and later extract them. So a user would define something like WITH_DEBUG_SYMBOLS in src.conf, and then in bsd.own.mk, have something like .if !defined(_WITHOUT_SRCCONF) .if defined(WITH_DEBUG_SYMBOLS) SYMBOLS_DIR?=/usr/local/lib/debug STRIP_BIN:=" ${SYMBOLS_DIR}" .endif .endif and then in bsd.prog.mk: .if defined(STRIP_BIN) .PHONY: export STRIPBIN=${STRIP_BIN} .endif so that when install(1) gets run, STRIPBIN will be in the environment. In our setup, STRIPBIN points to a script which just uses strip(1) and objcopy(1) to extract the debug symbols for each binary that gets installed. Ed suggested that I could just add an option to strip(1) to do all of this in one command so that we wouldn't need to add a separate script to the FreeBSD tree for this. It's pretty simple to do - I can post the patch if anyone wants to see it. This also requires a smallish change to install(1) which I can also post. Any thoughts or suggestions on this approach in general? I'm still getting to know the FreeBSD system, so I'm open to alternatives. If there's agreement that this feature might be useful, I'll post my patches. Thanks, -Mark