2014-06-10 14:38:26 +00:00
|
|
|
.\" Copyright (C) 2014 Michael Kerrisk <mtk.manpages@gmail.com>
|
|
|
|
.\"
|
|
|
|
.\" %%%LICENSE_START(VERBATIM)
|
|
|
|
.\" Permission is granted to make and distribute verbatim copies of this
|
|
|
|
.\" manual provided the copyright notice and this permission notice are
|
|
|
|
.\" preserved on all copies.
|
|
|
|
.\"
|
|
|
|
.\" Permission is granted to copy and distribute modified versions of this
|
|
|
|
.\" manual under the conditions for verbatim copying, provided that the
|
|
|
|
.\" entire resulting derived work is distributed under the terms of a
|
|
|
|
.\" permission notice identical to this one.
|
|
|
|
.\"
|
|
|
|
.\" Since the Linux kernel and libraries are constantly changing, this
|
|
|
|
.\" manual page may be incorrect or out-of-date. The author(s) assume no
|
|
|
|
.\" responsibility for errors or omissions, or for damages resulting from
|
|
|
|
.\" the use of the information contained herein. The author(s) may not
|
|
|
|
.\" have taken the same level of care in the production of this manual,
|
|
|
|
.\" which is licensed free of charge, as they might when working
|
|
|
|
.\" professionally.
|
|
|
|
.\"
|
|
|
|
.\" Formatted or processed versions of this manual, if unaccompanied by
|
|
|
|
.\" the source, must acknowledge the copyright and authors of this work.
|
|
|
|
.\" %%%LICENSE_END
|
|
|
|
.\"
|
iconv.1, locale.1, memusage.1, memusagestat.1, pldd.1, sprof.1, _syscall.2, add_key.2, adjtimex.2, bind.2, bpf.2, chown.2, clone.2, close.2, copy_file_range.2, eventfd.2, fanotify_init.2, fanotify_mark.2, fork.2, fsync.2, futex.2, getdents.2, getrlimit.2, getxattr.2, io_cancel.2, io_destroy.2, io_getevents.2, io_setup.2, ioctl_fat.2, ioctl_getfsmap.2, ioctl_ns.2, ioctl_tty.2, ioctl_userfaultfd.2, kcmp.2, keyctl.2, listen.2, listxattr.2, mbind.2, membarrier.2, memfd_create.2, mkdir.2, move_pages.2, mremap.2, msync.2, nfsservctl.2, open.2, perf_event_open.2, pidfd_send_signal.2, pipe.2, pivot_root.2, pkey_alloc.2, process_vm_readv.2, ptrace.2, readlink.2, readv.2, recv.2, recvmmsg.2, rename.2, request_key.2, s390_runtime_instr.2, sched_setaffinity.2, seccomp.2, send.2, sendmmsg.2, sigaltstack.2, signalfd.2, socket.2, socketpair.2, splice.2, spu_create.2, spu_run.2, statfs.2, syscall.2, sysctl.2, sysfs.2, tee.2, timer_getoverrun.2, timer_settime.2, umount.2, userfaultfd.2, utimensat.2, wait4.2, INFINITY.3, __ppc_get_timebase.3, __setfpucw.3, abort.3, aio_cancel.3, aio_error.3, aio_read.3, aio_return.3, atexit.3, backtrace.3, basename.3, bsearch.3, bswap.3, cacos.3, cacosh.3, catan.3, catanh.3, cexp2.3, clock_getcpuclockid.3, clog2.3, cmsg.3, confstr.3, div.3, dl_iterate_phdr.3, dlerror.3, dlinfo.3, dlopen.3, dlsym.3, duplocale.3, encrypt.3, end.3, endian.3, envz_add.3, err.3, expm1.3, fdim.3, flockfile.3, fmtmsg.3, frexp.3, ftw.3, get_nprocs_conf.3, get_phys_pages.3, getaddrinfo_a.3, getauxval.3, getdate.3, getdtablesize.3, getgrent_r.3, getgrouplist.3, gethostbyname.3, getline.3, getnameinfo.3, getopt.3, getprotoent_r.3, getpwent_r.3, getpwnam.3, getservent_r.3, getsubopt.3, getutent.3, glob.3, gnu_get_libc_version.3, hsearch.3, if_nameindex.3, inet.3, inet_net_pton.3, inet_ntop.3, inet_pton.3, insque.3, killpg.3, makecontext.3, mallinfo.3, malloc.3, malloc_hook.3, malloc_info.3, mallopt.3, matherr.3, mbsnrtowcs.3, mbstowcs.3, mcheck.3, mempcpy.3, mq_getattr.3, mq_notify.3, mtrace.3, newlocale.3, nextafter.3, ntp_gettime.3, offsetof.3, open_memstream.3, pow.3, printf.3, pthread_attr_init.3, pthread_attr_setdetachstate.3, pthread_attr_setguardsize.3, pthread_attr_setinheritsched.3, pthread_attr_setschedparam.3, pthread_attr_setschedpolicy.3, pthread_attr_setstack.3, pthread_attr_setstacksize.3, pthread_cancel.3, pthread_cleanup_push.3, pthread_create.3, pthread_detach.3, pthread_getattr_default_np.3, pthread_getattr_np.3, pthread_getcpuclockid.3, pthread_join.3, pthread_mutex_consistent.3, pthread_mutexattr_setrobust.3, pthread_setaffinity_np.3, pthread_setcancelstate.3, pthread_setname_np.3, pthread_setschedparam.3, pthread_sigmask.3, pthread_spin_init.3, pthread_testcancel.3, pthread_tryjoin_np.3, ptsname.3, qsort.3, rand.3, random.3, remainder.3, rpmatch.3, rtime.3, rtnetlink.3, scalb.3, scalbln.3, scandir.3, sem_getvalue.3, sem_wait.3, setaliasent.3, setlogmask.3, sigwait.3, sincos.3, sockatmark.3, stdarg.3, stpcpy.3, strcat.3, strfmon.3, strptime.3, strtod.3, strtok.3, strtol.3, strtoul.3, strverscmp.3, tsearch.3, uselocale.3, wcstok.3, wcstombs.3, wordexp.3, y0.3, loop.4, vcs.4, veth.4, charmap.5, core.5, filesystems.5, gai.conf.5, hosts.5, hosts.equiv.5, locale.5, nss.5, repertoiremap.5, securetty.5, shells.5, ttytype.5, ascii.7, complex.7, cpuset.7, credentials.7, fanotify.7, hier.7, inotify.7, ip.7, mount_namespaces.7, mq_overview.7, netlink.7, network_namespaces.7, pid_namespaces.7, pkeys.7, rtld-audit.7, rtnetlink.7, sem_overview.7, signal-safety.7, sock_diag.7, spufs.7, standards.7, symlink.7, tcp.7, time_namespaces.7, unix.7, user_namespaces.7, xattr.7, ldconfig.8: tstamp
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-06-09 12:43:54 +00:00
|
|
|
.TH SPROF 1 2020-06-09 "Linux" "Linux User Manual"
|
2014-06-10 14:38:26 +00:00
|
|
|
.SH NAME
|
|
|
|
sprof \- read and display shared object profiling data
|
|
|
|
.SH SYNOPSIS
|
|
|
|
.nf
|
2014-08-30 13:45:00 +00:00
|
|
|
.BR sprof " [\fIoption\fP]... \fIshared-object-path\fP \
|
|
|
|
[\fIprofile-data-path\fP]"
|
2014-06-10 14:38:26 +00:00
|
|
|
.fi
|
|
|
|
.SH DESCRIPTION
|
|
|
|
The
|
|
|
|
.B sprof
|
|
|
|
command displays a profiling summary for the
|
2015-07-10 18:37:59 +00:00
|
|
|
shared object (shared library) specified as its first command-line argument.
|
2014-06-10 14:38:26 +00:00
|
|
|
The profiling summary is created using previously generated
|
|
|
|
profiling data in the (optional) second command-line argument.
|
|
|
|
If the profiling data pathname is omitted, then
|
|
|
|
.B sprof
|
|
|
|
will attempt to deduce it using the soname of the shared object,
|
|
|
|
looking for a file with the name
|
getent.1, iconv.1, ldd.1, locale.1, localedef.1, memusage.1, memusagestat.1, pldd.1, sprof.1, time.1: tfix, use a one-font macro for a single argument
1) Use a single capital font macro for a genuine single argument.
The output is unchanged.
2) Remove quotation marks (") around a single argument.
The output is unchanged.
3) Change ".IR ab()" to ".IR ab ()"
A font is changed in the output.
mtk: I verified that the output is unchanged (other than fonts)
by comparing the output of:
for a in *.1; do man $a >> out.txt; done
before and after the patch.
Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-12-24 00:20:29 +00:00
|
|
|
.I <soname>.profile
|
2014-06-10 14:38:26 +00:00
|
|
|
in the current directory.
|
|
|
|
.SH OPTIONS
|
|
|
|
The following command-line options specify the profile output
|
|
|
|
to be produced:
|
|
|
|
.TP
|
|
|
|
.BR \-c ", " \-\-call\-pairs
|
|
|
|
Print a list of pairs of call paths for the interfaces exported
|
|
|
|
by the shared object,
|
|
|
|
along with the number of times each path is used.
|
|
|
|
.TP
|
|
|
|
.BR \-p ", " \-\-flat\-profile
|
|
|
|
Generate a flat profile of all of the functions in the monitored object,
|
|
|
|
with counts and ticks.
|
|
|
|
.TP
|
|
|
|
.BR \-q ", " \-\-graph
|
|
|
|
Generate a call graph.
|
|
|
|
.PP
|
|
|
|
If none of the above options is specified,
|
|
|
|
then the default behavior is to display a flat profile and a call graph.
|
|
|
|
.PP
|
|
|
|
The following additional command-line options are available:
|
|
|
|
.TP
|
|
|
|
.BR \-? ", " \-\-help
|
|
|
|
Display a summary of command-line options and arguments and exit.
|
|
|
|
.TP
|
getent.1, iconv.1, ldd.1, locale.1, localedef.1, memusage.1, memusagestat.1, pldd.1, sprof.1, time.1: tfix, use a one-font macro for a single argument
1) Use a single capital font macro for a genuine single argument.
The output is unchanged.
2) Remove quotation marks (") around a single argument.
The output is unchanged.
3) Change ".IR ab()" to ".IR ab ()"
A font is changed in the output.
mtk: I verified that the output is unchanged (other than fonts)
by comparing the output of:
for a in *.1; do man $a >> out.txt; done
before and after the patch.
Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-12-24 00:20:29 +00:00
|
|
|
.B \-\-usage
|
2014-06-10 14:38:26 +00:00
|
|
|
Display a short usage message and exit.
|
|
|
|
.TP
|
|
|
|
.BR \-V ", " \-\-version
|
|
|
|
Display the program version and exit.
|
|
|
|
.SH CONFORMING TO
|
|
|
|
The
|
|
|
|
.B sprof
|
|
|
|
command is a GNU extension, not present in POSIX.1.
|
2020-05-21 08:00:37 +00:00
|
|
|
.SH EXAMPLES
|
2014-06-10 14:38:26 +00:00
|
|
|
The following example demonstrates the use of
|
|
|
|
.BR sprof .
|
|
|
|
The example consists of a main program that calls two functions
|
2015-07-10 18:37:59 +00:00
|
|
|
in a shared object.
|
2014-06-10 14:38:26 +00:00
|
|
|
First, the code of the main program:
|
iconv.1, locale.1, localedef.1, memusage.1, memusagestat.1, mtrace.1, pldd.1, sprof.1, time.1, iconvconfig.8, ld.so.8, ldconfig.8, sln.8: Formatting fix: replace blank lines with .PP/.IP
Blank lines shouldn't generally appear in *roff source (other
than in code examples), since they create large vertical
spaces between text blocks.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-16 00:52:54 +00:00
|
|
|
.PP
|
2014-06-10 14:38:26 +00:00
|
|
|
.in +4n
|
2017-08-16 09:14:04 +00:00
|
|
|
.EX
|
2014-06-10 14:38:26 +00:00
|
|
|
$ \fBcat prog.c\fP
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
void x1(void);
|
|
|
|
void x2(void);
|
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
x1();
|
|
|
|
x2();
|
|
|
|
exit(EXIT_SUCCESS);
|
|
|
|
}
|
2017-08-16 09:14:04 +00:00
|
|
|
.EE
|
2014-06-10 14:38:26 +00:00
|
|
|
.in
|
|
|
|
.PP
|
|
|
|
The functions
|
getent.1, iconv.1, ldd.1, locale.1, localedef.1, memusage.1, memusagestat.1, pldd.1, sprof.1, time.1: tfix, use a one-font macro for a single argument
1) Use a single capital font macro for a genuine single argument.
The output is unchanged.
2) Remove quotation marks (") around a single argument.
The output is unchanged.
3) Change ".IR ab()" to ".IR ab ()"
A font is changed in the output.
mtk: I verified that the output is unchanged (other than fonts)
by comparing the output of:
for a in *.1; do man $a >> out.txt; done
before and after the patch.
Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-12-24 00:20:29 +00:00
|
|
|
.IR x1 ()
|
2014-06-10 14:38:26 +00:00
|
|
|
and
|
getent.1, iconv.1, ldd.1, locale.1, localedef.1, memusage.1, memusagestat.1, pldd.1, sprof.1, time.1: tfix, use a one-font macro for a single argument
1) Use a single capital font macro for a genuine single argument.
The output is unchanged.
2) Remove quotation marks (") around a single argument.
The output is unchanged.
3) Change ".IR ab()" to ".IR ab ()"
A font is changed in the output.
mtk: I verified that the output is unchanged (other than fonts)
by comparing the output of:
for a in *.1; do man $a >> out.txt; done
before and after the patch.
Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-12-24 00:20:29 +00:00
|
|
|
.IR x2 ()
|
2014-06-10 14:38:26 +00:00
|
|
|
are defined in the following source file that is used to
|
2015-07-10 18:37:59 +00:00
|
|
|
construct the shared object:
|
iconv.1, locale.1, localedef.1, memusage.1, memusagestat.1, mtrace.1, pldd.1, sprof.1, time.1, iconvconfig.8, ld.so.8, ldconfig.8, sln.8: Formatting fix: replace blank lines with .PP/.IP
Blank lines shouldn't generally appear in *roff source (other
than in code examples), since they create large vertical
spaces between text blocks.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-16 00:52:54 +00:00
|
|
|
.PP
|
2014-06-10 14:38:26 +00:00
|
|
|
.in +4n
|
2017-08-16 09:14:04 +00:00
|
|
|
.EX
|
2014-06-10 14:38:26 +00:00
|
|
|
$ \fBcat libdemo.c\fP
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
void
|
|
|
|
consumeCpu1(int lim)
|
|
|
|
{
|
sprof.1, eventfd.2, execve.2, futex.2, getdents.2, mprotect.2, open_by_handle_at.2, recvmmsg.2, sched_setaffinity.2, CPU_SET.3, backtrace.3, bsearch.3, dl_iterate_phdr.3, dlinfo.3, duplocale.3, encrypt.3, envz_add.3, fopencookie.3, getaddrinfo.3, getaddrinfo_a.3, getdate.3, getgrent_r.3, getgrouplist.3, getifaddrs.3, getprotoent_r.3, getservent_r.3, hsearch.3, mallinfo.3, malloc_info.3, mbstowcs.3, mtrace.3, pthread_create.3, pthread_getcpuclockid.3, pthread_setaffinity_np.3, qsort.3, rand.3, strcat.3, strtok.3, tsearch.3, wordexp.3, core.5, aio.7, inotify.7, sock_diag.7, unix.7, user_namespaces.7: Use C99 style to declare loop counter variables
Rather than:
sometype x;
for (x = ....; ...)
use
for (sometype x = ...; ...)
This brings the declaration and use closer together (thus aiding
readability) and also clearly indicates the scope of the loop
counter variable.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-05 15:18:10 +00:00
|
|
|
for (int j = 0; j < lim; j++)
|
2014-06-10 14:38:26 +00:00
|
|
|
getppid();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
x1(void) {
|
sprof.1, eventfd.2, execve.2, futex.2, getdents.2, mprotect.2, open_by_handle_at.2, recvmmsg.2, sched_setaffinity.2, CPU_SET.3, backtrace.3, bsearch.3, dl_iterate_phdr.3, dlinfo.3, duplocale.3, encrypt.3, envz_add.3, fopencookie.3, getaddrinfo.3, getaddrinfo_a.3, getdate.3, getgrent_r.3, getgrouplist.3, getifaddrs.3, getprotoent_r.3, getservent_r.3, hsearch.3, mallinfo.3, malloc_info.3, mbstowcs.3, mtrace.3, pthread_create.3, pthread_getcpuclockid.3, pthread_setaffinity_np.3, qsort.3, rand.3, strcat.3, strtok.3, tsearch.3, wordexp.3, core.5, aio.7, inotify.7, sock_diag.7, unix.7, user_namespaces.7: Use C99 style to declare loop counter variables
Rather than:
sometype x;
for (x = ....; ...)
use
for (sometype x = ...; ...)
This brings the declaration and use closer together (thus aiding
readability) and also clearly indicates the scope of the loop
counter variable.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-05 15:18:10 +00:00
|
|
|
for (int j = 0; j < 100; j++)
|
2014-06-10 14:38:26 +00:00
|
|
|
consumeCpu1(200000);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
consumeCpu2(int lim)
|
|
|
|
{
|
sprof.1, eventfd.2, execve.2, futex.2, getdents.2, mprotect.2, open_by_handle_at.2, recvmmsg.2, sched_setaffinity.2, CPU_SET.3, backtrace.3, bsearch.3, dl_iterate_phdr.3, dlinfo.3, duplocale.3, encrypt.3, envz_add.3, fopencookie.3, getaddrinfo.3, getaddrinfo_a.3, getdate.3, getgrent_r.3, getgrouplist.3, getifaddrs.3, getprotoent_r.3, getservent_r.3, hsearch.3, mallinfo.3, malloc_info.3, mbstowcs.3, mtrace.3, pthread_create.3, pthread_getcpuclockid.3, pthread_setaffinity_np.3, qsort.3, rand.3, strcat.3, strtok.3, tsearch.3, wordexp.3, core.5, aio.7, inotify.7, sock_diag.7, unix.7, user_namespaces.7: Use C99 style to declare loop counter variables
Rather than:
sometype x;
for (x = ....; ...)
use
for (sometype x = ...; ...)
This brings the declaration and use closer together (thus aiding
readability) and also clearly indicates the scope of the loop
counter variable.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-05 15:18:10 +00:00
|
|
|
for (int j = 0; j < lim; j++)
|
2014-06-10 14:38:26 +00:00
|
|
|
getppid();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
x2(void)
|
|
|
|
{
|
sprof.1, eventfd.2, execve.2, futex.2, getdents.2, mprotect.2, open_by_handle_at.2, recvmmsg.2, sched_setaffinity.2, CPU_SET.3, backtrace.3, bsearch.3, dl_iterate_phdr.3, dlinfo.3, duplocale.3, encrypt.3, envz_add.3, fopencookie.3, getaddrinfo.3, getaddrinfo_a.3, getdate.3, getgrent_r.3, getgrouplist.3, getifaddrs.3, getprotoent_r.3, getservent_r.3, hsearch.3, mallinfo.3, malloc_info.3, mbstowcs.3, mtrace.3, pthread_create.3, pthread_getcpuclockid.3, pthread_setaffinity_np.3, qsort.3, rand.3, strcat.3, strtok.3, tsearch.3, wordexp.3, core.5, aio.7, inotify.7, sock_diag.7, unix.7, user_namespaces.7: Use C99 style to declare loop counter variables
Rather than:
sometype x;
for (x = ....; ...)
use
for (sometype x = ...; ...)
This brings the declaration and use closer together (thus aiding
readability) and also clearly indicates the scope of the loop
counter variable.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-09-05 15:18:10 +00:00
|
|
|
for (int j = 0; j < 1000; j++)
|
2014-06-10 14:38:26 +00:00
|
|
|
consumeCpu2(10000);
|
|
|
|
}
|
2017-08-16 09:14:04 +00:00
|
|
|
.EE
|
2014-06-10 14:38:26 +00:00
|
|
|
.in
|
|
|
|
.PP
|
2015-07-10 18:37:59 +00:00
|
|
|
Now we construct the shared object with the real name
|
2014-06-10 14:38:26 +00:00
|
|
|
.IR libdemo.so.1.0.1 ,
|
|
|
|
and the soname
|
|
|
|
.IR libdemo.so.1 :
|
iconv.1, locale.1, localedef.1, memusage.1, memusagestat.1, mtrace.1, pldd.1, sprof.1, time.1, iconvconfig.8, ld.so.8, ldconfig.8, sln.8: Formatting fix: replace blank lines with .PP/.IP
Blank lines shouldn't generally appear in *roff source (other
than in code examples), since they create large vertical
spaces between text blocks.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-16 00:52:54 +00:00
|
|
|
.PP
|
2014-06-10 14:38:26 +00:00
|
|
|
.in +4n
|
2017-08-16 09:14:04 +00:00
|
|
|
.EX
|
2014-06-10 14:38:26 +00:00
|
|
|
$ \fBcc \-g \-fPIC \-shared \-Wl,\-soname,libdemo.so.1 \e\fP
|
|
|
|
\fB\-o libdemo.so.1.0.1 libdemo.c\fP
|
2017-08-16 09:14:04 +00:00
|
|
|
.EE
|
2014-06-10 14:38:26 +00:00
|
|
|
.in
|
|
|
|
.PP
|
|
|
|
Then we construct symbolic links for the library soname and
|
|
|
|
the library linker name:
|
iconv.1, locale.1, localedef.1, memusage.1, memusagestat.1, mtrace.1, pldd.1, sprof.1, time.1, iconvconfig.8, ld.so.8, ldconfig.8, sln.8: Formatting fix: replace blank lines with .PP/.IP
Blank lines shouldn't generally appear in *roff source (other
than in code examples), since they create large vertical
spaces between text blocks.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-16 00:52:54 +00:00
|
|
|
.PP
|
2014-06-10 14:38:26 +00:00
|
|
|
.in +4n
|
2017-08-16 09:14:04 +00:00
|
|
|
.EX
|
2014-06-10 14:38:26 +00:00
|
|
|
$ \fBln \-sf libdemo.so.1.0.1 libdemo.so.1\fP
|
|
|
|
$ \fBln \-sf libdemo.so.1 libdemo.so\fP
|
2017-08-16 09:14:04 +00:00
|
|
|
.EE
|
2014-06-10 14:38:26 +00:00
|
|
|
.in
|
|
|
|
.PP
|
2015-07-10 18:37:59 +00:00
|
|
|
Next, we compile the main program, linking it against the shared object,
|
2014-06-10 14:38:26 +00:00
|
|
|
and then list the dynamic dependencies of the program:
|
iconv.1, locale.1, localedef.1, memusage.1, memusagestat.1, mtrace.1, pldd.1, sprof.1, time.1, iconvconfig.8, ld.so.8, ldconfig.8, sln.8: Formatting fix: replace blank lines with .PP/.IP
Blank lines shouldn't generally appear in *roff source (other
than in code examples), since they create large vertical
spaces between text blocks.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-16 00:52:54 +00:00
|
|
|
.PP
|
2014-06-10 14:38:26 +00:00
|
|
|
.in +4n
|
2017-08-16 09:14:04 +00:00
|
|
|
.EX
|
2014-06-10 14:38:26 +00:00
|
|
|
$ \fBcc \-g \-o prog prog.c \-L. \-ldemo\fP
|
|
|
|
$ \fBldd prog\fP
|
|
|
|
linux\-vdso.so.1 => (0x00007fff86d66000)
|
|
|
|
libdemo.so.1 => not found
|
|
|
|
libc.so.6 => /lib64/libc.so.6 (0x00007fd4dc138000)
|
|
|
|
/lib64/ld\-linux\-x86\-64.so.2 (0x00007fd4dc51f000)
|
2017-08-16 09:14:04 +00:00
|
|
|
.EE
|
2014-06-10 14:38:26 +00:00
|
|
|
.in
|
|
|
|
.PP
|
2015-07-10 18:37:59 +00:00
|
|
|
In order to get profiling information for the shared object,
|
2014-06-10 14:38:26 +00:00
|
|
|
we define the environment variable
|
getent.1, iconv.1, ldd.1, locale.1, localedef.1, memusage.1, memusagestat.1, pldd.1, sprof.1, time.1: tfix, use a one-font macro for a single argument
1) Use a single capital font macro for a genuine single argument.
The output is unchanged.
2) Remove quotation marks (") around a single argument.
The output is unchanged.
3) Change ".IR ab()" to ".IR ab ()"
A font is changed in the output.
mtk: I verified that the output is unchanged (other than fonts)
by comparing the output of:
for a in *.1; do man $a >> out.txt; done
before and after the patch.
Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-12-24 00:20:29 +00:00
|
|
|
.B LD_PROFILE
|
2014-06-10 14:38:26 +00:00
|
|
|
with the soname of the library:
|
iconv.1, locale.1, localedef.1, memusage.1, memusagestat.1, mtrace.1, pldd.1, sprof.1, time.1, iconvconfig.8, ld.so.8, ldconfig.8, sln.8: Formatting fix: replace blank lines with .PP/.IP
Blank lines shouldn't generally appear in *roff source (other
than in code examples), since they create large vertical
spaces between text blocks.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-16 00:52:54 +00:00
|
|
|
.PP
|
2014-06-10 14:38:26 +00:00
|
|
|
.in +4n
|
2017-08-16 09:14:04 +00:00
|
|
|
.EX
|
2014-06-10 14:38:26 +00:00
|
|
|
$ \fBexport LD_PROFILE=libdemo.so.1\fP
|
2017-08-16 09:14:04 +00:00
|
|
|
.EE
|
2014-06-10 14:38:26 +00:00
|
|
|
.in
|
|
|
|
.PP
|
|
|
|
We then define the environment variable
|
getent.1, iconv.1, ldd.1, locale.1, localedef.1, memusage.1, memusagestat.1, pldd.1, sprof.1, time.1: tfix, use a one-font macro for a single argument
1) Use a single capital font macro for a genuine single argument.
The output is unchanged.
2) Remove quotation marks (") around a single argument.
The output is unchanged.
3) Change ".IR ab()" to ".IR ab ()"
A font is changed in the output.
mtk: I verified that the output is unchanged (other than fonts)
by comparing the output of:
for a in *.1; do man $a >> out.txt; done
before and after the patch.
Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-12-24 00:20:29 +00:00
|
|
|
.B LD_PROFILE_OUTPUT
|
2014-06-10 14:38:26 +00:00
|
|
|
with the pathname of the directory where profile output should be written,
|
|
|
|
and create that directory if it does not exist already:
|
iconv.1, locale.1, localedef.1, memusage.1, memusagestat.1, mtrace.1, pldd.1, sprof.1, time.1, iconvconfig.8, ld.so.8, ldconfig.8, sln.8: Formatting fix: replace blank lines with .PP/.IP
Blank lines shouldn't generally appear in *roff source (other
than in code examples), since they create large vertical
spaces between text blocks.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-16 00:52:54 +00:00
|
|
|
.PP
|
2014-06-10 14:38:26 +00:00
|
|
|
.in +4n
|
2017-08-16 09:14:04 +00:00
|
|
|
.EX
|
2014-06-10 14:38:26 +00:00
|
|
|
$ \fBexport LD_PROFILE_OUTPUT=$(pwd)/prof_data\fP
|
|
|
|
$ \fBmkdir \-p $LD_PROFILE_OUTPUT\fP
|
2017-08-16 09:14:04 +00:00
|
|
|
.EE
|
2014-06-10 14:38:26 +00:00
|
|
|
.in
|
|
|
|
.PP
|
|
|
|
.B LD_PROFILE
|
|
|
|
causes profiling output to be
|
|
|
|
.I appended
|
|
|
|
to the output file if it already exists,
|
|
|
|
so we ensure that there is no preexisting profiling data:
|
iconv.1, locale.1, localedef.1, memusage.1, memusagestat.1, mtrace.1, pldd.1, sprof.1, time.1, iconvconfig.8, ld.so.8, ldconfig.8, sln.8: Formatting fix: replace blank lines with .PP/.IP
Blank lines shouldn't generally appear in *roff source (other
than in code examples), since they create large vertical
spaces between text blocks.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-16 00:52:54 +00:00
|
|
|
.PP
|
2014-06-10 14:38:26 +00:00
|
|
|
.in +4n
|
2017-08-16 09:14:04 +00:00
|
|
|
.EX
|
2014-06-10 14:38:26 +00:00
|
|
|
$ \fBrm \-f $LD_PROFILE_OUTPUT/$LD_PROFILE.profile\fP
|
2017-08-16 09:14:04 +00:00
|
|
|
.EE
|
2014-06-10 14:38:26 +00:00
|
|
|
.in
|
|
|
|
.PP
|
|
|
|
We then run the program to produce the profiling output,
|
|
|
|
which is written to a file in the directory specified in
|
|
|
|
.BR LD_PROFILE_OUTPUT :
|
iconv.1, locale.1, localedef.1, memusage.1, memusagestat.1, mtrace.1, pldd.1, sprof.1, time.1, iconvconfig.8, ld.so.8, ldconfig.8, sln.8: Formatting fix: replace blank lines with .PP/.IP
Blank lines shouldn't generally appear in *roff source (other
than in code examples), since they create large vertical
spaces between text blocks.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-16 00:52:54 +00:00
|
|
|
.PP
|
2014-06-10 14:38:26 +00:00
|
|
|
.in +4n
|
2017-08-16 09:14:04 +00:00
|
|
|
.EX
|
2014-06-10 14:38:26 +00:00
|
|
|
$ \fBLD_LIBRARY_PATH=. ./prog\fP
|
|
|
|
$ \fBls prof_data\fP
|
|
|
|
libdemo.so.1.profile
|
2017-08-16 09:14:04 +00:00
|
|
|
.EE
|
2014-06-10 14:38:26 +00:00
|
|
|
.in
|
|
|
|
.PP
|
|
|
|
We then use the
|
getent.1, iconv.1, ldd.1, locale.1, localedef.1, memusage.1, memusagestat.1, pldd.1, sprof.1, time.1: tfix, use a one-font macro for a single argument
1) Use a single capital font macro for a genuine single argument.
The output is unchanged.
2) Remove quotation marks (") around a single argument.
The output is unchanged.
3) Change ".IR ab()" to ".IR ab ()"
A font is changed in the output.
mtk: I verified that the output is unchanged (other than fonts)
by comparing the output of:
for a in *.1; do man $a >> out.txt; done
before and after the patch.
Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-12-24 00:20:29 +00:00
|
|
|
.B sprof \-p
|
2014-06-10 14:38:26 +00:00
|
|
|
option to generate a flat profile with counts and ticks:
|
iconv.1, locale.1, localedef.1, memusage.1, memusagestat.1, mtrace.1, pldd.1, sprof.1, time.1, iconvconfig.8, ld.so.8, ldconfig.8, sln.8: Formatting fix: replace blank lines with .PP/.IP
Blank lines shouldn't generally appear in *roff source (other
than in code examples), since they create large vertical
spaces between text blocks.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-16 00:52:54 +00:00
|
|
|
.PP
|
2014-06-10 14:38:26 +00:00
|
|
|
.in +4n
|
2017-08-16 09:14:04 +00:00
|
|
|
.EX
|
2014-06-10 14:38:26 +00:00
|
|
|
$ \fBsprof \-p libdemo.so.1 $LD_PROFILE_OUTPUT/libdemo.so.1.profile\fP
|
|
|
|
Flat profile:
|
|
|
|
|
|
|
|
Each sample counts as 0.01 seconds.
|
|
|
|
% cumulative self self total
|
|
|
|
time seconds seconds calls us/call us/call name
|
|
|
|
60.00 0.06 0.06 100 600.00 consumeCpu1
|
|
|
|
40.00 0.10 0.04 1000 40.00 consumeCpu2
|
|
|
|
0.00 0.10 0.00 1 0.00 x1
|
|
|
|
0.00 0.10 0.00 1 0.00 x2
|
2017-08-16 09:14:04 +00:00
|
|
|
.EE
|
2014-06-10 14:38:26 +00:00
|
|
|
.in
|
|
|
|
.PP
|
|
|
|
The
|
getent.1, iconv.1, ldd.1, locale.1, localedef.1, memusage.1, memusagestat.1, pldd.1, sprof.1, time.1: tfix, use a one-font macro for a single argument
1) Use a single capital font macro for a genuine single argument.
The output is unchanged.
2) Remove quotation marks (") around a single argument.
The output is unchanged.
3) Change ".IR ab()" to ".IR ab ()"
A font is changed in the output.
mtk: I verified that the output is unchanged (other than fonts)
by comparing the output of:
for a in *.1; do man $a >> out.txt; done
before and after the patch.
Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-12-24 00:20:29 +00:00
|
|
|
.B sprof \-q
|
2014-06-10 14:38:26 +00:00
|
|
|
option generates a call graph:
|
iconv.1, locale.1, localedef.1, memusage.1, memusagestat.1, mtrace.1, pldd.1, sprof.1, time.1, iconvconfig.8, ld.so.8, ldconfig.8, sln.8: Formatting fix: replace blank lines with .PP/.IP
Blank lines shouldn't generally appear in *roff source (other
than in code examples), since they create large vertical
spaces between text blocks.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-16 00:52:54 +00:00
|
|
|
.PP
|
2014-06-10 14:38:26 +00:00
|
|
|
.in +4n
|
2017-08-16 09:14:04 +00:00
|
|
|
.EX
|
2014-06-10 14:38:26 +00:00
|
|
|
$ \fBsprof \-q libdemo.so.1 $LD_PROFILE_OUTPUT/libdemo.so.1.profile\fP
|
|
|
|
|
|
|
|
index % time self children called name
|
|
|
|
|
|
|
|
0.00 0.00 100/100 x1 [1]
|
|
|
|
[0] 100.0 0.00 0.00 100 consumeCpu1 [0]
|
|
|
|
\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
|
|
|
|
0.00 0.00 1/1 <UNKNOWN>
|
|
|
|
[1] 0.0 0.00 0.00 1 x1 [1]
|
|
|
|
0.00 0.00 100/100 consumeCpu1 [0]
|
|
|
|
\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
|
|
|
|
0.00 0.00 1000/1000 x2 [3]
|
|
|
|
[2] 0.0 0.00 0.00 1000 consumeCpu2 [2]
|
|
|
|
\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
|
|
|
|
0.00 0.00 1/1 <UNKNOWN>
|
|
|
|
[3] 0.0 0.00 0.00 1 x2 [3]
|
|
|
|
0.00 0.00 1000/1000 consumeCpu2 [2]
|
|
|
|
\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
|
2017-08-16 09:14:04 +00:00
|
|
|
.EE
|
2014-06-10 14:38:26 +00:00
|
|
|
.in
|
|
|
|
.PP
|
|
|
|
Above and below, the "<UNKNOWN>" strings represent identifiers that
|
|
|
|
are outside of the profiled object (in this example, these are instances of
|
|
|
|
.IR main() ).
|
|
|
|
.PP
|
|
|
|
The
|
getent.1, iconv.1, ldd.1, locale.1, localedef.1, memusage.1, memusagestat.1, pldd.1, sprof.1, time.1: tfix, use a one-font macro for a single argument
1) Use a single capital font macro for a genuine single argument.
The output is unchanged.
2) Remove quotation marks (") around a single argument.
The output is unchanged.
3) Change ".IR ab()" to ".IR ab ()"
A font is changed in the output.
mtk: I verified that the output is unchanged (other than fonts)
by comparing the output of:
for a in *.1; do man $a >> out.txt; done
before and after the patch.
Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-12-24 00:20:29 +00:00
|
|
|
.B sprof \-c
|
2014-06-10 14:38:26 +00:00
|
|
|
option generates a list of call pairs and the number of their occurrences:
|
iconv.1, locale.1, localedef.1, memusage.1, memusagestat.1, mtrace.1, pldd.1, sprof.1, time.1, iconvconfig.8, ld.so.8, ldconfig.8, sln.8: Formatting fix: replace blank lines with .PP/.IP
Blank lines shouldn't generally appear in *roff source (other
than in code examples), since they create large vertical
spaces between text blocks.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-16 00:52:54 +00:00
|
|
|
.PP
|
2014-06-10 14:38:26 +00:00
|
|
|
.in +4n
|
2017-08-16 09:14:04 +00:00
|
|
|
.EX
|
2014-06-10 14:38:26 +00:00
|
|
|
$ \fBsprof \-c libdemo.so.1 $LD_PROFILE_OUTPUT/libdemo.so.1.profile\fP
|
|
|
|
<UNKNOWN> x1 1
|
|
|
|
x1 consumeCpu1 100
|
|
|
|
<UNKNOWN> x2 1
|
|
|
|
x2 consumeCpu2 1000
|
2017-08-16 09:14:04 +00:00
|
|
|
.EE
|
2014-06-10 14:38:26 +00:00
|
|
|
.in
|
|
|
|
.SH SEE ALSO
|
|
|
|
.BR gprof (1),
|
|
|
|
.BR ldd (1),
|
|
|
|
.BR ld.so (8)
|