This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: How to call functions which have ifunc symbols (e.g. strcmp) from inside gdb
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: David Gardner <daveg at xmos dot com>
- Cc: gdb at sourceware dot org
- Date: Thu, 2 Jun 2011 15:29:22 +0200
- Subject: Re: How to call functions which have ifunc symbols (e.g. strcmp) from inside gdb
- References: <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