This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


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

[dmj+@andrew.cmu.edu: Re: profiling a MT-App (with shared libs) on Linux]


Oops, this was meant for the list...  Sorry, Andreas.

On Tue, Nov 07, 2000 at 03:08:45PM +0100, Andreas Jaeger wrote:
> >>>>> Lothar Werzinger writes:
> 
>  > Hi,
>  > has anybody being successfully using the profiling support of gcc with a
>  > multithreaded app on Linux. The code I want to profile is inside a
>  > shared library, that gets loaded manually by the application program. I
>  > have the source to both the app and the lib. Due to some architectual
>  > constraints I can NOT statically link the library.
> 
> Use LD_PROFILE=libsomething.so, e.g.:
> 
> $ LD_PROFILE=libc.so.6 ls
> [..]
> $ sprof libc.so.6 libc.so.6.profile
> Flat profile:
> 
> Each sample counts as 0.01 seconds.
>   %   cumulative   self              self     total
>  time   seconds   seconds    calls  us/call  us/call  name
>   0.00      0.00     0.00     2958     0.00           __overflow
>   0.00      0.00     0.00     1782     0.00           strncmp
>   0.00      0.00     0.00      788     0.00           strcmp
>   0.00      0.00     0.00      723     0.00           mempcpy
>   0.00      0.00     0.00      314     0.00           memcpy
> [...]
> 
> 
> LD_PROFILE_OUTPUT determines the path where it's written - this only
> works with glibc 2.1 and newer.  AFAIR it should work with
> multithreaded apps - if not complain on the glibc lists.

That's a very nice feature, but it sets my teeth on edge - it will
follow symlinks, and defaults to using /var/tmp.  LD_PROFILE_OUTPUT is
ignored if __libc_enable_secure, but that's useless in most cases,
because symlinks are followed.

Admittedly, the risk is fairly small, because the profile code errors
out if the file has nonzero size and contains invalid profiling data. 
But it will gladly fill any 0-length file, owned by any user!

Dan

/--------------------------------\  /--------------------------------\
|       Daniel Jacobowitz        |__|        SCS Class of 2002       |
|   Debian GNU/Linux Developer    __    Carnegie Mellon University   |
|         dan@debian.org         |  |       dmj+@andrew.cmu.edu      |
\--------------------------------/  \--------------------------------/

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