public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: David Gardner <daveg@xmos.com>
Cc: gdb@sourceware.org
Subject: Re: How to call functions which have ifunc symbols (e.g. strcmp) from inside gdb
Date: Thu, 02 Jun 2011 13:29:00 -0000	[thread overview]
Message-ID: <20110602132922.GA32664@host1.jankratochvil.net> (raw)
In-Reply-To: <20110602122944.GB30346@xmos.com>

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

  reply	other threads:[~2011-06-02 13:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-02 12:30 David Gardner
2011-06-02 13:29 ` Jan Kratochvil [this message]
2011-06-06 21:23   ` Thiago Jung Bauermann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110602132922.GA32664@host1.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=daveg@xmos.com \
    --cc=gdb@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).