ftrace
The working set of events ftrace should trace is defined by the following arguments.
-p=PID
-f, -follow
-dl
-sym=SYMBOL[,SYMBOL...]
If SYMBOL references PLT slot, calls done through that PLT slot are recorded. You then effectively trace calls done FROM given library or executable, and generally can't say which library the call leads TO.
When tracing ordinary symbol, catch all calls that end up at this symbol. That includes the calls that don't go through PLT and as such are not intended as inter-library calls, but rather intra-library calls.
See below for detailed description of SYMBOL rule syntax.
-sys=SYSCALL[,SYSCALL...]
-sig=SIGNAL[,SIGNAL...]
-addr=RULE[,RULE...]
-m
-pc
-stack
-number-of-frames count
-lite
-rich
-print print-option,...
debug-names: use debug information, such as DWARF, to determine the name of functions
paths: include the full path to source files and libraries
inline: include in-line function in back-trace
locals: to include local variables from each frame
params: include the function parameters
To negate a print-option prefix it with "-".
-exe
-noexe
-sysroot directory
-debug class=level...
To decide which PLT slots or entry points should be traced, following process takes place. A set of symbols to trace ("working set") is initially empty. Rules, if present, are then enumerated from left to right, and set is modified depending on the rules. Rules are delimited by a comma. Syntax of each rule is following:
[-]pattern[/options]
Without the optional "-" all symbols that match the pattern are added to the working set. With "-", matching symbols are removed.
If "/" is present at the end of the rule, following letters are interpreted as rule flags. Currently only one flag is available, "s". When present, it means ftrace should show a stack trace when it hits a symbol that matches this rule.
When a "-" rule has an "/s" flag, the call should still be traced, but stack trace shouldn't be generated.
pattern defines which symbols or PLT slots from which libraries should be added or removed from working set. Syntax of pattern is as follows:
[#soname#][filename.c#][(proc|line)#][plt:]symbol[@version]
soname component is matched against a soname of a library in which we wish to trace the call. If the library has no associated soname (such as is usual in case of main executable), the match is done against the file name (without a path). Two special sonames are distinguished: "MAIN", which always matches main executable; and "INTERP", which always matches ELF interpreter (dynamic linker) of the main executable. If the component is missing, then the rule is applicable in all libraries and in main executable.
filename.c component is matched against the name of a file where the symbol is defined. NOTE: This is currently not implemented.
proc component is matched against the name of block surrounding the definition we wish to trace. If the block doesn't have a name, you can instead refer to it with the line number that the block surrounds. NOTE: This is currently not implemented.
symbol component is matched against the name of symbol under consideration. If "plt:" prefix is present, the rule matches PLT entry associated with the symbol instead of the symbol itself.
version component is matched against version associated with symbol. If the symbol has no associated version, it is considered to be an empty string. (It is possible to request symbol without a version with the pattern "foo@".) NOTE: This is currently not implemented.
All components are presented in glob syntax. See glob(7) manual page for more details. See below for examples.
Under the presence of the -sys (or -sig) option, ALL system calls (or signals) are ALWAYS traced. This is a limitation of the ptrace layer. The system call and signal rules however serve as a simple way of filtering out the output that you are not interested in. In following paragraphs, the word "event" will be used to mean "signal or syscall, whatever applies".
The system call and signal rule syntax and semantics are the same as the symbol rule syntax:
[-]pattern[/options]
Event selection pattern syntax is then as follows:
[event name|event number]
When the pattern is empty, it matches all events known to frysk. When the pattern is simple number (e.g. "12"), then the pattern matches the event with the given number. Otherwise the pattern is considered to be case-insensitive glob, and matched against event names. Whole name has to match for event to be a part of working set.
Signal can be given both with and without leading "sig" (e.g. "sigkill" as well as "kill").
The process of establishing a working set of addresses that should be traced is the same as for symbol rules, and the general syntax reflects that. Each rule looks like this:
[-]pattern[/options]
Each pattern then looks like this:
[#soname#][0x]address
Addresses are always given in hexadecimal notation, even if initial 0x is missing.
soname component is the same as in symbol tracing, i.e. it's matched against a soname of a library in which we wish to trace the address. Same rules apply regarding INTERP and MAIN meta-sonames. Refer to the chapter "SYMBOL RULE SYNTAX" for detailed description.
Even though soname is optional, at least one soname has to be specified at the beginning of the -addr command. That's because in general it makes no sense to want to trace the same address in ALL object files at once. The components that are soname-less are assumed to have a soname of the previous component that has soname.
For example, this will trace two addresses from the main binary, and stack trace one of them:
The addresses are assumed to be copied from readelf or objdump. ftrace biases the value accordingly depending on where the module is actually mapped.
Trace all system calls:
The option parser is greedy when looking for options so running ftrace on a program that uses options can be a problem, use -- to split between ftrace and the program. So change from:
~/prefix/bin/ftrace ~/prefix/lib64/frysk/funit --arch 32 frysk.proc.TestAbandon
to
~/prefix/bin/ftrace -- ~/prefix/lib64/frysk/funit --arch 32 frysk.proc.TestAbandon
Report bugs to m[blue]http://sourceware.org/fryskm[]