From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28462 invoked by alias); 2 Jun 2011 13:29:46 -0000 Received: (qmail 28454 invoked by uid 22791); 2 Jun 2011 13:29:45 -0000 X-SWARE-Spam-Status: No, hits=-6.2 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SARE_SUB_6CONS_WORD,SPF_HELO_PASS,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, 02 Jun 2011 13:29:27 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p52DTQsY025589 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 2 Jun 2011 09:29:26 -0400 Received: from host1.jankratochvil.net (ovpn-113-38.phx2.redhat.com [10.3.113.38]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p52DTONG024682 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 2 Jun 2011 09:29:26 -0400 Received: from host1.jankratochvil.net (localhost [127.0.0.1]) by host1.jankratochvil.net (8.14.4/8.14.4) with ESMTP id p52DTNsk005594; Thu, 2 Jun 2011 15:29:23 +0200 Received: (from jkratoch@localhost) by host1.jankratochvil.net (8.14.4/8.14.4/Submit) id p52DTMMx005580; Thu, 2 Jun 2011 15:29:22 +0200 Date: Thu, 02 Jun 2011 13:29:00 -0000 From: Jan Kratochvil To: David Gardner Cc: gdb@sourceware.org Subject: Re: How to call functions which have ifunc symbols (e.g. strcmp) from inside gdb Message-ID: <20110602132922.GA32664@host1.jankratochvil.net> References: <20110602122944.GB30346@xmos.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20110602122944.GB30346@xmos.com> User-Agent: Mutt/1.5.21 (2010-09-15) 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: 2011-06/txt/msg00011.txt.bz2 On Thu, 02 Jun 2011 14:29:44 +0200, David Gardner wrote: > Calling strcmp from inside gdb thusly: > > (gdb) call strcmp("foo", "foo") > $3 = -146921376 > > Gives unexpected values. > > I note that there is a bug for this already > (http://sourceware.org/bugzilla/show_bug.cgi?id=12347) and this mentions > that the strcmp symbol is the ifunc wrapper for the strcmp function, but > this seems counter-intuitive for a user of gdb. This is fixed in FSF GDB HEAD and GDB 7.3-prerelease branch. [patch 0/7] STT_GNU_IFUNC support http://sourceware.org/ml/gdb-patches/2011-03/msg00937.html You can download a GDB snapshot before gdb-7.3 gets released these days/weeks. http://www.gnu.org/software/gdb/current/ > Is there an alternative method of calling ifunc-enabled functions which > can be used for calls (and related items such as conditional > breakpoints) within gdb? If you still have old GDB you can cast it yourself: (gdb) p (*(int(*(*)())())strcmp)()("a","b") $1 = -1 Regards, Jan