From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24797 invoked by alias); 14 Jan 2015 23:00:47 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 24785 invoked by uid 89); 14 Jan 2015 23:00:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ie0-f180.google.com Received: from mail-ie0-f180.google.com (HELO mail-ie0-f180.google.com) (209.85.223.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 14 Jan 2015 23:00:44 +0000 Received: by mail-ie0-f180.google.com with SMTP id rp18so11787008iec.11 for ; Wed, 14 Jan 2015 15:00:42 -0800 (PST) X-Received: by 10.107.132.210 with SMTP id o79mr7170176ioi.50.1421276442124; Wed, 14 Jan 2015 15:00:42 -0800 (PST) MIME-Version: 1.0 Received: by 10.42.70.73 with HTTP; Wed, 14 Jan 2015 15:00:12 -0800 (PST) In-Reply-To: <1421274213.29961.12.camel@thevertigo.com> References: <1421274213.29961.12.camel@thevertigo.com> From: Simon Marchi Date: Wed, 14 Jan 2015 23:00:00 -0000 Message-ID: Subject: Re: Stepping into glibc To: Kip Warner Cc: gdb@sourceware.org Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2015-01/txt/msg00024.txt.bz2 On 14 January 2015 at 17:23, Kip Warner wrote: > Hey list, > > I'm trying to debug some code with Nemiver (a Gtk+ frontend for GDB). > When I try to step into glibc functions, it complains about not being > able to find its source. e.g. > > Cannot find file '/build/buildd/glibc-2.19/posix/getopt1.c'. > > I have installed libc6-dbg and glibc-source packages (using Ubuntu > 14.10). > > Is there something I need to add to my ~/.gdbinit, such as a directory > / set solib-absolute-prefix / set sysroot or what have you? > > I could always download the source of my distro's version of glibc into > the above location, but I'm sure there is a more elegant way of > handling this. > > Respectfully, > > -- > Kip Warner -- Senior Software Engineer > OpenPGP encrypted/signed mail preferred > http://www.thevertigo.com You are looking for "set substitute-path" [1]. On Ubuntu/Debian, you can easily download the exact source of a package you are running (including distribution-specific patches), by using "apt-get source". In your case, it would be: $ apt-get source libc6 You would then use set substitute-path to tell gdb to replace the "/build/buildd" part, which is the path where the source was on Ubuntu's server when the package was built, with your own path. For example, assuming that you download package sources in /home/kip/package-sources: $ set substitute-path /build/buildd /home/kip/package-sources I might be forgetting something, but that's the idea. Also, if it happens that you want to debug a program that does not have a *-dbg version, you can use the dbgsym which is built automatically for every Ubuntu package [2]. Simon [1] https://sourceware.org/gdb/onlinedocs/gdb/Source-Path.html#set%20substitute-path [2] https://wiki.ubuntu.com/DebuggingProgramCrash#Non-built-in_debug_symbol_packages_.28.2A-dbgsym.29