From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25741 invoked by alias); 9 Jan 2007 07:58:10 -0000 Received: (qmail 25725 invoked by uid 22791); 9 Jan 2007 07:58:09 -0000 X-Spam-Check-By: sourceware.org Received: from sophia.inria.fr (HELO sophia.inria.fr) (138.96.64.20) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 09 Jan 2007 07:58:03 +0000 Received: from localhost (localhost [127.0.0.1]) by sophia.inria.fr (8.13.8/8.13.4) with ESMTP id l097vnON018003; Tue, 9 Jan 2007 08:57:49 +0100 Received: from garfield.inria.fr (garfield.inria.fr [138.96.88.66]) (authenticated bits=0) by sophia.inria.fr (8.13.8/8.13.4) with ESMTP id l097v8Mk017777 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO); Tue, 9 Jan 2007 08:57:08 +0100 Subject: Re: gdb and dynamic loader namespaces From: Mathieu Lacage To: Daniel Jacobowitz Cc: gdb@sourceware.org In-Reply-To: <20070108151510.GA14359@nevyn.them.org> References: <1168268998.21818.44.camel@garfield.inria.fr> <20070108151510.GA14359@nevyn.them.org> Content-Type: text/plain Date: Tue, 09 Jan 2007 07:58:00 -0000 Message-Id: <1168329428.21818.61.camel@garfield.inria.fr> Mime-Version: 1.0 X-Mailer: Evolution 2.6.3 (2.6.3-1.fc5.5) Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (sophia.inria.fr [138.96.64.20]); Tue, 09 Jan 2007 08:57:08 +0100 (MET) 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: 2007-01/txt/msg00136.txt.bz2 On Mon, 2007-01-08 at 10:15 -0500, Daniel Jacobowitz wrote: > On Mon, Jan 08, 2007 at 04:09:58PM +0100, Mathieu Lacage wrote: > > So, I tried to figure out how I could fix this in gdb: a bit of > > debugging shows that gdb is notified of dlmopen calls through the > > r_debug structure since "set stop-on-solib-events 1" triggers correctly > > an event upon dlmopen. The question then is why gdb does not add the new > > binary to its map. Maybe someone more knowledgeable than me about the > > layout of the gdb code source could point me to the piece of code which > > updates and manipulates the gdb map of binaries used during symbol > > lookup ? (I am using an x86 linux system) > > It's in solib-svr4.c. Look especially at current_sos and compare that > to where glibc adds things in namespaces. I doubt they're on the same > list, and in fact they may not even be listed in the public part of > struct r_debug. They are not, indeed in the public part of r_debug. My understanding is that the rtld_global data structure (see sysdeps/generic/ldsodefs.h) contains an array of struct link_namespaces, each of which contains a struct r_debug. The first entry in this array is supposed to represent the LD_ID_BASE which is the default namespace: it is not super clear to me what is the relationship between the struct r_debug embedded in the associated struct link_namespace and the global _r_debug variable used to hold the process struct r_debug. The latter seems to be the default value used to initialize the dynamic loader's DT_DEBUG entry which you use for all your debugging needs in solib-svr4.c. The question then is how can we get access to the link_map of each namespace from the parent process ? We could perform a lookup for the rtld_global data structure and then, use an offset from there to get the required data. I suspect you won't be thrilled by that though. Do you have any better idea ? Maybe I should ask this question on a glibc ML: I would be surprised if no one had ever planned debugger support for this feature. Mathieu --