This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How to call functions which have ifunc symbols (e.g. strcmp) from inside gdb


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]