[lkml]   [1996]   [Jul]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: further..

> I've only tried the above on sparc, but I believe
> __builtin_return_address() is available on intel boxes.

__builtin_return_address() is a pretty dangerous thing. On many
architectures is returns useless data with -fomit-frame-pointer (Intel and
68k also, I think), hasn't been implemented at all (among those GCC <= 2.7.2
for MIPS) or fails silently for certain cases and/or arguments (among those
GCC >= 2.8.0 for MIPS). In short check your object code if you don't
exactly know what __builtin_return_address() will really do.

So far I made good experiences using the hook provided by GCC's -p option.
GCC will emit in the prologue of every function a call to mcount or _mcount
(depends of your architecture/OS/object file format). GCC passes the
called function's address to mcount (beware - on some CPUs the calling
convention for mcount is unusual); just perfect for counting the number
of calls to a function. For the __builtin_return_address() reason it's
unfortunately impossible to implement mcount completly portable, but
what is perfect on this world ...


 \ /
  Last update: 2005-03-22 13:38    [W:0.037 / U:0.108 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site