Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 27 Nov 1997 14:55:56 -0800
From:      John Polstra <jdp@polstra.com>
To:        hackers@freebsd.org
Cc:        darius@senet.com.au
Subject:   Re: Shared Libraries and debugging
Message-ID:  <199711272255.OAA18209@austin.polstra.com>
In-Reply-To: <19971126182058.04145@uriah.heep.sax.de>
References:  <199711250748.SAA16393@holly.rd.net> <19971126182058.04145@uriah.heep.sax.de>

next in thread | previous in thread | raw e-mail | index | archive | help
In article <19971126182058.04145@uriah.heep.sax.de>,
J Wunsch  <joerg_wunsch@uriah.heep.sax.de> wrote:
> As Daniel J. O'Connor wrote:
> 
> > I was fiddling with some code which links against shared libraries, and 
> > noticed that when viewing a core dumb with gdb, it doesn't load the symbols 
> > from the shared libraries, so consequently debugging the program is kind of 
> > akward.
> 
> I usually set a breakpoint at main(), run it till there, and then
> voila!, you can also specify breakpoints at shared lib functions...

But he was asking about core dumps.  And he's right, it doesn't work.
I've been looking into it, and I have a fix to the dynamic linker that
seems to make it work fine.  I'll commit it after I do a make world
and a little bit more testing.

Judging by the cause of the problem, I doubt that it ever worked.  In
order to examine shared libraries, gdb needs to look at the dynamic
linker's table which records where they were loaded into memory.  The
dynamic linker has always recorded this information in a MAP_ANON
region way up high in the address space.  But such regions are not
written to the core file when a core dump occurs.  So gdb has not been
able to get the information it needs.

To fix it, I changed the dynamic linker to use the system malloc.
(Much easier said than done!)  Now it allocates its data structures
from the same arena that the user program allocates from.  Its data
structures consequently now get written to the core file, and gdb
finds them and works properly.

John
--
   John Polstra                                       jdp@polstra.com
   John D. Polstra & Co., Inc.                Seattle, Washington USA
   "Self-knowledge is always bad news."                 -- John Barth



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199711272255.OAA18209>