Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Jim Blandy <jimb@redhat.com>
To: Richard Tierney <mfoc73@dsl.pipex.com>
Cc: gdb@sources.redhat.com
Subject: Re: How do you debug a shared library if the main app is compiled without debug?
Date: Thu, 01 Apr 2004 14:22:00 -0000	[thread overview]
Message-ID: <vt2fzbneq3m.fsf@zenia.home> (raw)
In-Reply-To: <406BEBF5.4090600@dsl.pipex.com>

Richard Tierney <mfoc73@dsl.pipex.com> 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 <stdio.h>

  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)


  reply	other threads:[~2004-04-01 14:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-04-01 10:16 Richard Tierney
2004-04-01 14:22 ` Jim Blandy [this message]
2004-04-01 21:36   ` Richard Tierney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=vt2fzbneq3m.fsf@zenia.home \
    --to=jimb@redhat.com \
    --cc=gdb@sources.redhat.com \
    --cc=mfoc73@dsl.pipex.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox