public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* How to call functions which have ifunc symbols (e.g. strcmp) from inside gdb
@ 2011-06-02 12:30 David Gardner
  2011-06-02 13:29 ` Jan Kratochvil
  0 siblings, 1 reply; 3+ messages in thread
From: David Gardner @ 2011-06-02 12:30 UTC (permalink / raw)
  To: gdb

[-- Attachment #1: Type: text/plain, Size: 705 bytes --]

Hi,

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.

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?  Or is just an open bug which is awaiting a fix
and I should work around by making wrappers for such functions which I
want to call from within gdb?


        Many thanks for any help!


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to call functions which have ifunc symbols (e.g. strcmp) from inside gdb
  2011-06-02 12:30 How to call functions which have ifunc symbols (e.g. strcmp) from inside gdb David Gardner
@ 2011-06-02 13:29 ` Jan Kratochvil
  2011-06-06 21:23   ` Thiago Jung Bauermann
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Kratochvil @ 2011-06-02 13:29 UTC (permalink / raw)
  To: David Gardner; +Cc: 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to call functions which have ifunc symbols (e.g. strcmp) from inside gdb
  2011-06-02 13:29 ` Jan Kratochvil
@ 2011-06-06 21:23   ` Thiago Jung Bauermann
  0 siblings, 0 replies; 3+ messages in thread
From: Thiago Jung Bauermann @ 2011-06-06 21:23 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: David Gardner, gdb

On Thu, 2011-06-02 at 15:29 +0200, Jan Kratochvil wrote:
> If you still have old GDB you can cast it yourself:
> (gdb) p (*(int(*(*)())())strcmp)()("a","b")
> $1 = -1

If GDB supported Lisp, this is what it would look like. :-)
-- 
[]'s
Thiago Jung Bauermann
IBM Linux Technology Center

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-06-06 21:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-02 12:30 How to call functions which have ifunc symbols (e.g. strcmp) from inside gdb David Gardner
2011-06-02 13:29 ` Jan Kratochvil
2011-06-06 21:23   ` Thiago Jung Bauermann

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).