ライブラリ関数のトレースツール ltrace の雑多メモ
バージョン & usage
root@choco002:~# ltrace --version ltrace 0.7.91 Copyright (C) 2010-2013 Petr Machata, Red Hat Inc. Copyright (C) 1997-2009 Juan Cespedes <cespedes@debian.org>. License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. root@choco002:~# ltrace -h Usage: ltrace [option ...] [command [arg ...]] Trace library calls of a given program. -a, --align=COLUMN align return values in a secific column. -A MAXELTS maximum number of array elements to print. -b, --no-signals don't print signals. -c count time and calls, and report a summary on exit. -C, --demangle decode low-level symbol names into user-level names. -D, --debug=MASK enable debugging (see -Dh or --debug=help). -Dh, --debug=help show help on debugging. -e FILTER modify which library calls to trace. -f trace children (fork() and clone()). -F, --config=FILE load alternate configuration file (may be repeated). -h, --help display this help and exit. -i print instruction pointer at time of library call. -l, --library=LIBRARY_PATTERN only trace symbols implemented by this library. -L do NOT display library calls. -n, --indent=NR indent output by NR spaces for each call level nesting. -o, --output=FILENAME write the trace output to file with given name. -p PID attach to the process with the process ID pid. -r print relative timestamps. -s STRSIZE specify the maximum string size to print. -S trace system calls as well as library calls. -t, -tt, -ttt print absolute timestamps. -T show the time spent inside each call. -u USERNAME run command with the userid, groupid of username. -V, --version output version information and exit. -w, --where=NR print backtrace showing NR stack frames at most. -x FILTER modify which static functions to trace. Report bugs to ltrace-devel@lists.alioth.debian.org
実行時間を表示する
$ ltrace -p 21021 -t
特定のライブラリ関数を表示する
$ ltrace -p 21021 -e malloc
子プロセス/スレッドをトレースする方法(-f)
ltrace -p 13589 -f
統計情報を表示する方法(-c)
ltrace -p 13589 -f -c