From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5918 invoked by alias); 10 May 2012 14:14:08 -0000 Received: (qmail 5908 invoked by uid 22791); 10 May 2012 14:14:07 -0000 X-SWARE-Spam-Status: No, hits=-7.2 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,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; Thu, 10 May 2012 14:13:41 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q4AEDPB5001170 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 10 May 2012 10:13:25 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q4AEDO6Q021939; Thu, 10 May 2012 10:13:24 -0400 Message-ID: <4FABCD04.2070006@redhat.com> Date: Thu, 10 May 2012 14:14:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120430 Thunderbird/12.0.1 MIME-Version: 1.0 To: Joel Brobecker CC: gdb-patches@sourceware.org Subject: Re: [RFC] choose symbol from given block's objfile first. References: <1336430581-11262-1-git-send-email-brobecker@adacore.com> In-Reply-To: <1336430581-11262-1-git-send-email-brobecker@adacore.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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: 2012-05/txt/msg00340.txt.bz2 On 05/07/2012 11:43 PM, Joel Brobecker wrote: > Hello, > > This patch is a prototype for an issue very briefly discussed on IRC. > Quick description of the problem: > > We have a program which is linked against two shared libraries. > Both libraries define a global symbol with the same name. In my > example, I used an int called this_library_version. When trying > to print the value of this global, GDB just randomly selects > the first one it finds, and I couldn't find a way (that worked) > which allowed me to print the value of the other global. > > The idea behind this patch is to reduce a little bit the randomness. > If one is debugging code inside one of the shared libraries, then > the variable that the user probably wants is the one that is defined > inside that shared library. +1. > > It's a bit of a poor man's answer to this issue. On the one hand, > you do not always get the same symbol every single time. But on > the other hand, the selection process is implicit and not always > work-able for the user. Eventually, what we thought we needed was > extend the expression parser to allow the user to qualify his > variable name with the name of the objfile, such as for instance: > > (gdb) print libsomething.so::this_library_version > > This is something that can be done in parallel to this effort. Yeah... It's one of those features that I think if we added together all the time people have spent saying IWBN to have it, it'd sum up to enough to implement it. :-) Still, this wouldn't solve the case of loading the same library twice... Which symbol would you print? -- Pedro Alves