From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19586 invoked by alias); 12 Oct 2008 15:36:31 -0000 Received: (qmail 19577 invoked by uid 22791); 12 Oct 2008 15:36:31 -0000 X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.33.17) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sun, 12 Oct 2008 15:35:12 +0000 Received: from wpaz21.hot.corp.google.com (wpaz21.hot.corp.google.com [172.24.198.85]) by smtp-out.google.com with ESMTP id m9CFZ4Xb013435 for ; Sun, 12 Oct 2008 16:35:04 +0100 Received: from wa-out-1112.google.com (wahj5.prod.google.com [10.114.236.5]) by wpaz21.hot.corp.google.com with ESMTP id m9CFYnwC008249 for ; Sun, 12 Oct 2008 08:35:02 -0700 Received: by wa-out-1112.google.com with SMTP id j5so686100wah.4 for ; Sun, 12 Oct 2008 08:35:02 -0700 (PDT) Received: by 10.114.175.16 with SMTP id x16mr4228332wae.155.1223825702116; Sun, 12 Oct 2008 08:35:02 -0700 (PDT) Received: by 10.114.78.12 with HTTP; Sun, 12 Oct 2008 08:35:02 -0700 (PDT) Message-ID: <8ac60eac0810120835t4e3426b1w40ec632fc9d0f59@mail.gmail.com> Date: Sun, 12 Oct 2008 15:36:00 -0000 From: "Paul Pluzhnikov" To: rimon Subject: Re: gdb - loading symbols of shared library Cc: gdb@sourceware.org In-Reply-To: <19941465.post@talk.nabble.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <19941465.post@talk.nabble.com> X-IsSubscribed: yes 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 X-SW-Source: 2008-10/txt/msg00051.txt.bz2 On Sun, Oct 12, 2008 at 5:57 AM, rimon wrote: > > I am debugging in gdb a program that dynamically loads libodbcinst.so. I want > to debug the code from libodbcinst - I can break in it, see the source and > step through it, but whenever I try printing a variable, I get (e.g. for the > variable ret): > "No symbol "ret" in current context." Most often this is the result of libodbcinst.so being compiled with 'gcc -g -O2'. Compiler has optimized the variable out. > In my program libodbcinst.so loads my own library (an odbc driver). This > library I can debug fully, symbols and all. Your own library was compiled without -O*. > Things I've verified: > - libodbcinst.so is compiled with debug information. I compiled it myself > from UnixODBC sources, and made sure it was compiled with debug info. You can verify that it was compiled with '-O2 -g', and rebuilt it with 'CFLAGS=-g -O0'. > - libodcinst.so is not stripped - I ran 'nm' on it, and got a symbol table. > - From gdb I ran 'info share' and saw that libodbcinst.so was in the list of > loaded libraries. I also tried running 'sharedlibrary libodbcinst.so' but > this made no difference. > - I tried running add-symbol-file for the library. If the library is listed in 'info shared' (which must be true since you can set breakpoints in it), then GDB has already added it; you don't need to do that. > I must admit I have a > problem here. This command is supposed to receive an 'address' parameter. > The manual says this should be the address where the library was loaded. How > do I know that library? I tried putting different things there - for example > the address of the text segment I got from 'maint info sections', but not > only could I still not see the symbols, this also screwed up something with > the rest of the debugging. Calculation of the address is somewhat complicated, and adding the library at the wrong address will result in GDB "loosing" it. > > So, in addition to a solution to show the symbols, I would also be very > grateful for an explanation of the address parameter for add-symbol-file. > > I'm working on HP-UX 11.23 (Itanium). Using HP gdb (wdb) 5.7 . > > TIA! > > RO > -- > View this message in context: http://www.nabble.com/gdb---loading-symbols-of-shared-library-tp19941465p19941465.html > Sent from the Sourceware - gdb list mailing list archive at Nabble.com. > > -- Paul Pluzhnikov