.\" Automatically generated by Pandoc 1.17.2 .\" .TH "UFTRACE\-REPLAY" "1" "May, 2016" "Uftrace User Manuals" "" .hy .SH NAME .PP uftrace\-replay \- Print recorded function trace .SH SYNOPSIS .PP uftrace replay [\f[I]options\f[]] .SH DESCRIPTION .PP This command prints trace data recorded using the \f[C]uftrace\-record\f[](1) command. The traced functions are printed like a C program in time order. .SH OPTIONS .TP .B \-\-flat Print flat format rather than C\-like format. This is usually for debugging and testing purpose. .RS .RE .TP .B \-F \f[I]FUNC\f[], \-\-filter=\f[I]FUNC\f[] Set filter to trace selected functions only. This option can be used more than once. See \f[I]FILTERS\f[]. .RS .RE .TP .B \-N \f[I]FUNC\f[], \-\-notrace=\f[I]FUNC\f[] Set filter not to trace selected functions (or the functions called underneath them). This option can be used more than once. See \f[I]FILTERS\f[]. .RS .RE .TP .B \-T \f[I]TRG\f[], \-\-trigger=\f[I]TRG\f[] Set trigger on selected functions. This option can be used more than once. See \f[I]TRIGGERS\f[]. .RS .RE .TP .B \-t \f[I]TIME\f[], \-\-time\-filter=\f[I]TIME\f[] Do not show functions which run under the time threshold. If some functions explicitly have the \[aq]trace\[aq] trigger applied, those are always traced regardless of execution time. .RS .RE .TP .B \-\-tid=\f[I]TID\f[][,\f[I]TID\f[],...] Only print functions called by the given threads. To see the list of threads in the data file, you can use \f[C]uftrace\ report\ \-\-threads\f[] or \f[C]uftrace\ info\f[]. .RS .RE .TP .B \-D \f[I]DEPTH\f[], \-\-depth \f[I]DEPTH\f[] Set trace limit in nesting level. .RS .RE .TP .B \-\-disable Start uftrace with tracing disabled. This is only meaningful when used with a \f[C]trace_on\f[] trigger. .RS .RE .TP .B \-\-column\-view Show each task in separate column. This makes easy to distinguish functions in different tasks. .RS .RE .TP .B \-\-column\-offset=\f[I]DEPTH\f[] When \f[C]\-\-column\-view\f[] option is used, this option specifies the amount of offset between each task. Default is 8. .RS .RE .TP .B \-\-task\-newline Interleave a new line when task is changed. This makes easy to distinguish functions in different tasks. .RS .RE .TP .B \-\-no\-comment Do not show comments of returned functions. .RS .RE .TP .B \-k, \-\-kernel Trace kernel functions as well as user functions. .RS .RE .TP .B \-\-kernel\-full Show all kernel functions called outside of user functions. This option is the inverse of \f[C]\-\-kernel\-skip\-out\f[]. Implies \f[C]\-\-kernel\f[]. .RS .RE .TP .B \-\-kernel\-skip\-out Do not show kernel functions called outside of user functions. This option is deprecated and set to true by default. .RS .RE .SH FILTERS .PP The uftrace tool supports filtering out uninteresting functions. When uftrace is called it receives two types of function filter; an opt\-in filter with \f[C]\-F\f[]/\f[C]\-\-filter\f[] and an opt\-out filter with \f[C]\-N\f[]/\f[C]\-\-notrace\f[]. These filters can be applied either at record time or replay time. .PP The first one is an opt\-in filter. By default, it doesn\[aq]t show anything. But when one of the specified functions is met, printing is started. When the function returns, printing is stopped again. .PP For example, consider a simple program which calls \f[C]a()\f[], \f[C]b()\f[] and \f[C]c()\f[] in turn. .IP .nf \f[C] $\ cat\ abc.c void\ c(void)\ { \ \ \ \ /*\ do\ nothing\ */ } void\ b(void)\ { \ \ \ \ c(); } void\ a(void)\ { \ \ \ \ b(); } int\ main(void)\ { \ \ \ \ a(); \ \ \ \ return\ 0; } $\ gcc\ \-pg\ \-o\ abc\ abc.c \f[] .fi .PP Normally uftrace replay will show all the functions from \f[C]main()\f[] to \f[C]c()\f[]. .IP .nf \f[C] $\ uftrace\ ./abc #\ DURATION\ \ \ \ TID\ \ \ \ \ FUNCTION \ 138.494\ us\ [\ 1234]\ |\ __cxa_atexit(); \ \ \ \ \ \ \ \ \ \ \ \ [\ 1234]\ |\ main()\ { \ \ \ \ \ \ \ \ \ \ \ \ [\ 1234]\ |\ \ \ a()\ { \ \ \ \ \ \ \ \ \ \ \ \ [\ 1234]\ |\ \ \ \ \ b()\ { \ \ \ 3.880\ us\ [\ 1234]\ |\ \ \ \ \ \ \ c(); \ \ \ 5.475\ us\ [\ 1234]\ |\ \ \ \ \ }\ /*\ b\ */ \ \ \ 6.448\ us\ [\ 1234]\ |\ \ \ }\ /*\ a\ */ \ \ \ 8.631\ us\ [\ 1234]\ |\ }\ /*\ main\ */ \f[] .fi .PP But when the \f[C]\-F\ b\f[] filter option is used, it will not show \f[C]main()\f[] or \f[C]a()\f[] but only \f[C]b()\f[] and \f[C]c()\f[]. Note that the filter was set on \f[C]uftrace\ replay\f[], not at record time. .IP .nf \f[C] $\ uftrace\ record\ ./abc $\ uftrace\ replay\ \-F\ b #\ DURATION\ \ \ \ TID\ \ \ \ \ FUNCTION \ \ \ \ \ \ \ \ \ \ \ \ [\ 1234]\ |\ b()\ { \ \ \ 3.880\ us\ [\ 1234]\ |\ \ \ c(); \ \ \ 5.475\ us\ [\ 1234]\ |\ }\ /*\ b\ */ \f[] .fi .PP The second type of filter is opt\-out. When used, everything is shown by default, but printing stops once one of the specified functions is met. When the given function returns, printing is started again. .PP In the above example, you can omit the function \f[C]b()\f[] and all calls it makes with the \f[C]\-N\f[] option. .IP .nf \f[C] $\ uftrace\ record\ ./abc $\ uftrace\ replay\ \-N\ b #\ DURATION\ \ \ \ TID\ \ \ \ \ FUNCTION \ 138.494\ us\ [\ 1234]\ |\ __cxa_atexit(); \ \ \ \ \ \ \ \ \ \ \ \ [\ 1234]\ |\ main()\ { \ \ \ 6.448\ us\ [\ 1234]\ |\ \ \ a(); \ \ \ 8.631\ us\ [\ 1234]\ |\ }\ /*\ main\ */ \f[] .fi .PP In addition, you can limit the print nesting level with \-D option. .IP .nf \f[C] $\ uftrace\ record\ ./abc $\ uftrace\ replay\ \-D\ 3 #\ DURATION\ \ \ \ TID\ \ \ \ \ FUNCTION \ 138.494\ us\ [\ 1234]\ |\ __cxa_atexit(); \ \ \ \ \ \ \ \ \ \ \ \ [\ 1234]\ |\ main()\ { \ \ \ \ \ \ \ \ \ \ \ \ [\ 1234]\ |\ \ \ a()\ { \ \ \ 5.475\ us\ [\ 1234]\ |\ \ \ \ \ b(); \ \ \ 6.448\ us\ [\ 1234]\ |\ \ \ }\ /*\ a\ */ \ \ \ 8.631\ us\ [\ 1234]\ |\ }\ /*\ main\ */ \f[] .fi .PP In the above example, uftrace only prints functions up to a depth of 3, so leaf function \f[C]c()\f[] was omitted. Note that the \f[C]\-D\f[] option also works with \f[C]\-F\f[]. .PP Sometimes it\[aq]s useful to see long\-running functions only. This is good because there are usually many tiny functions that are not interesting. The \f[C]\-t\f[]/\f[C]\-\-time\-filter\f[] option implements the time\-based filter that only records functions which run longer than the given threshold. In the above example, the user might want to see functions running more than 5 microseconds like below: .IP .nf \f[C] $\ uftrace\ record\ ./abc $\ uftrace\ replay\ \-t\ 5us #\ DURATION\ \ \ \ TID\ \ \ \ \ FUNCTION \ 138.494\ us\ [\ 1234]\ |\ __cxa_atexit(); \ \ \ \ \ \ \ \ \ \ \ \ [\ 1234]\ |\ main()\ { \ \ \ \ \ \ \ \ \ \ \ \ [\ 1234]\ |\ \ \ a()\ { \ \ \ 5.475\ us\ [\ 1234]\ |\ \ \ \ \ b(); \ \ \ 6.448\ us\ [\ 1234]\ |\ \ \ }\ /*\ a\ */ \ \ \ 8.631\ us\ [\ 1234]\ |\ }\ /*\ main\ */ \f[] .fi .PP You can also see replay output with different time threshold for the same recorded data. .IP .nf \f[C] $\ uftrace\ replay\ \-t\ 6us #\ DURATION\ \ \ \ TID\ \ \ \ \ FUNCTION \ 138.494\ us\ [\ 1234]\ |\ __cxa_atexit(); \ \ \ \ \ \ \ \ \ \ \ \ [\ 1234]\ |\ main()\ { \ \ \ 6.448\ us\ [\ 1234]\ |\ \ \ a(); \ \ \ 8.631\ us\ [\ 1234]\ |\ }\ /*\ main\ */ \f[] .fi .PP You can also set triggers on filtered functions. See \f[I]TRIGGERS\f[] section below for details. .SH TRIGGERS .PP The uftrace tool supports triggering actions on selected function calls with or without filters. Currently supported triggers are \f[C]depth\f[], \f[C]backtrace\f[], \f[C]trace_on\f[] and \f[C]trace_off\f[]. The BNF for trigger specifications is like below: .IP .nf \f[C] \ \ :=\ \ \ "\@"\ \ \ :=\ \ \ \ |\ \ ","\ \ \ \ :=\ \ "depth="\ |\ "backtrace"\ |\ "trace_on"\ |\ "trace_off"\ |\ "color=" \f[] .fi .PP The \f[C]depth\f[] trigger is to change filter depth during execution of the function. It can be used to apply different filter depths for different functions. And the \f[C]backtrace\f[] trigger is used to print a stack backtrace at replay time. .PP The color trigger is to change the color of the function in replay output. The supported colors are \f[C]red\f[], \f[C]green\f[], \f[C]blue\f[], \f[C]yellow\f[], \f[C]magenta\f[], \f[C]cyan\f[], \f[C]bold\f[], and \f[C]gray\f[]. .PP The following example shows how triggers work. We set a filter on function \f[C]b()\f[] with the \f[C]backtrace\f[] action and change the maximum filter depth under \f[C]b()\f[] to 2. .IP .nf \f[C] $\ uftrace\ record\ ./abc $\ uftrace\ replay\ \-F\ \[aq]b\@backtrace,depth=2\[aq] #\ DURATION\ \ \ \ TID\ \ \ \ \ FUNCTION \ \ backtrace\ [\ 1234]\ |\ /*\ [\ 0]\ main\ */ \ \ backtrace\ [\ 1234]\ |\ /*\ [\ 1]\ a\ */ \ \ \ \ \ \ \ \ \ \ \ \ [\ 1234]\ |\ b\ { \ \ \ 3.880\ us\ [\ 1234]\ |\ \ \ c(); \ \ \ 5.475\ us\ [\ 1234]\ |\ }\ /*\ b\ */ \f[] .fi .PP The \f[C]traceon\f[] and \f[C]traceoff\f[] actions (the \f[C]_\f[] can be omitted from \f[C]trace_on\f[] and \f[C]trace_off\f[]) control whether uftrace shows functions or not. The trigger runs at replay time, not run time, so it can handle kernel functions as well. Contrast this with triggers used under \f[C]uftrace\ record\f[]. .SH SEE ALSO .PP \f[C]uftrace\f[](1), \f[C]uftrace\-record\f[](1), \f[C]uftrace\-report\f[](1), \f[C]uftrace\-info\f[](1) .SH AUTHORS Namhyung Kim .