From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11019 invoked by alias); 20 Jul 2010 19:38:33 -0000 Received: (qmail 11011 invoked by uid 22791); 20 Jul 2010 19:38:32 -0000 X-SWARE-Spam-Status: No, hits=-6.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,TW_BJ,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 20 Jul 2010 19:38:25 +0000 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o6KJcNsC024498 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 20 Jul 2010 15:38:23 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o6KJcMkH018221; Tue, 20 Jul 2010 15:38:22 -0400 Received: from opsy.redhat.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o6KJcLEG000440; Tue, 20 Jul 2010 15:38:22 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id A5F1B3797EE; Tue, 20 Jul 2010 13:38:21 -0600 (MDT) From: Tom Tromey To: Mathieu Lacage Cc: gdb-patches@sourceware.org Subject: Re: impossible to resolve symbols in same binary loaded twice with dlmopen References: <1278528582.10151.23.camel@localhost.localdomain> Date: Tue, 20 Jul 2010 19:38:00 -0000 In-Reply-To: (Mathieu Lacage's message of "Fri, 9 Jul 2010 13:36:47 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-07/txt/msg00313.txt.bz2 >>>>> "Mathieu" =3D=3D Mathieu Lacage writes: Tom> into it too much since I wasn't aware of anybody really using dlmopen. Tom> If gdb cannot do this, please file a bug report. Mathieu> I do not believe that gdb can do this and I could file a bug but i= t's Mathieu> probably going to be hard to fix (beyond my own abilities). Yeah, that is ok -- please file it anyway. Tom> Once you have this patch, does it really work? =C2=A0It seems like it = would Tom> work ok for some things, like backtraces, but not other things. =C2=A0= E.g., Tom> does symbol lookup work properly in the dlmopen case? =C2=A0I would im= agine Tom> that it does or does not depending on the ordering of objfiles in gdb's Tom> internal list. Mathieu> If you use the libc loader and run the test program I attached to = the Mathieu> bug report, you will see that it's indeed impossible to put a Mathieu> breakpoint or print the address of a function located in a binary Mathieu> loaded with dlmopen [...] Actually I am curious about failures even with your loader. Can you set breakpoints on all instances of a function? Does printing a global variable defined in a dlmopen()d .so always work properly? I would guess that you could construct a case where it does not, something like: File x.c defines a function, file y.c defines a global. Compile into a shared library. Have the main program dlmopen the library twice and call the function in each one. Then, step into each instance of the function and print the address of the global. The reason I think this will fail is that I am not sure that gdb will do the symbol search properly. I suspect it will always find the first instance of the global, not the one in the current objfile. Maybe I'm wrong about this, though :-) Anyway, AFAICT, your patch won't break anything, and it is a step in the right direction. So, please check it in. Tom