From owner-freebsd-hackers Thu Nov 27 14:56:03 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id OAA28899 for hackers-outgoing; Thu, 27 Nov 1997 14:56:03 -0800 (PST) (envelope-from owner-freebsd-hackers) Received: from austin.polstra.com (austin.polstra.com [206.213.73.10]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id OAA28870 for ; Thu, 27 Nov 1997 14:55:58 -0800 (PST) (envelope-from jdp@austin.polstra.com) Received: from austin.polstra.com (jdp@localhost) by austin.polstra.com (8.8.8/8.8.7) with ESMTP id OAA18209; Thu, 27 Nov 1997 14:55:56 -0800 (PST) (envelope-from jdp) Message-Id: <199711272255.OAA18209@austin.polstra.com> To: hackers@freebsd.org Subject: Re: Shared Libraries and debugging In-Reply-To: <19971126182058.04145@uriah.heep.sax.de> References: <199711250748.SAA16393@holly.rd.net> <19971126182058.04145@uriah.heep.sax.de> Organization: Polstra & Co., Seattle, WA Cc: darius@senet.com.au Date: Thu, 27 Nov 1997 14:55:56 -0800 From: John Polstra Sender: owner-freebsd-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk In article <19971126182058.04145@uriah.heep.sax.de>, J Wunsch 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