From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29171 invoked by alias); 1 Apr 2004 14:22:25 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 29164 invoked from network); 1 Apr 2004 14:22:23 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sources.redhat.com with SMTP; 1 Apr 2004 14:22:23 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.10/8.12.10) with ESMTP id i31EMNjj020431 for ; Thu, 1 Apr 2004 09:22:23 -0500 Received: from zenia.home.redhat.com (porkchop.devel.redhat.com [172.16.58.2]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id i31EMKj07462; Thu, 1 Apr 2004 09:22:21 -0500 To: Richard Tierney Cc: gdb@sources.redhat.com Subject: Re: How do you debug a shared library if the main app is compiled without debug? References: <406BEBF5.4090600@dsl.pipex.com> From: Jim Blandy Date: Thu, 01 Apr 2004 14:22:00 -0000 In-Reply-To: <406BEBF5.4090600@dsl.pipex.com> Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2004-04/txt/msg00003.txt.bz2 Richard Tierney writes: > I've written a shared library (ELF/.so), with debug enabled, which is > called from a commercial package. I don't have sources for the other > vendor's code, and it was (I think) compiled without debug info. > > Question: can I use gdb to debug my own code in this environment? If I > set 'file' to the name of the vendor's executable then I get a message > about there being no symbols. I've tried setting breakpoints in my own > code, using a function name or a file and a line number, and then > running the main app. I had assumed that the breakpoints would be set > when my code is loaded, but this isn't happening - I get a warning > about not being able to insert a breakpoint, and a memory access error. You should try the current GDB sources. As of about a month ago, Jeff Johnston got "pending breakpoint" support working, which does exactly what you want. Below, '__overflow' is a function used internally by the 'puts' function: $ cat hello.c #include char foo; int bar = 0x1729; main (int argc, char **argv) { puts ("Hello, world!"); } $ gcc hello.c -o hello $ strip hello $ gdb hello GNU gdb 2004-02-17-cvs Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i686-pc-linux-gnu"...(no debugging symbols found)...Using host libthread_db library "/lib/libthread_db.so.1". (gdb) break __overflow Function "__overflow" not defined. Make breakpoint pending on future shared library load? (y or n) y Breakpoint 1 (__overflow) pending. (gdb) run Starting program: /rigel/jimb/play/hello (no debugging symbols found)...(no debugging symbols found)...Breakpoint 2 at 0x4206fc06 Pending breakpoint "__overflow" resolved Breakpoint 2, 0x4206fc06 in __overflow () from /lib/i686/libc.so.6 (gdb)