= 2011-03-31 = == IOWait == * [[Image(jazz/11-03-31:top_vs_iotop.png,width=500)]] * [[Image(jazz/11-03-31:munin-status.png)]] == callgraph == * C/C++ * Rex 在 [http://people.debian.org.tw/~chihchun/2011/03/30/callgraphviz/ CallGraphviz – call graph visualzer based on csope, graphviz and xdot] 一文中介紹了許多不同的 callgraph 產生方式。 * 搭配[http://en.wikipedia.org/wiki/Call_graph 維基百科 Call_graph]的軟體簡介,大概整理如下: * [http://www.skynet.ie/~mel/projects/codeviz/ CodeViz] - 缺點:必須 patch GCC 然後用 Perl 來產生圖形 * [http://students.ceid.upatras.gr/~sxanth/ncc/ ncc] - 目標是取代 cflow 跟 cscope,[http://blog.linux.org.tw/~jserv/archives/001723.html jserv 有介紹過] - 缺點:相依 GCC 環境版本 * 有 [http://packages.debian.org/ncc Debian 套件 ncc] * [http://www.gnu.org/software/cflow/ cflow] - 老字號 GNU 的流程分析工具 - [http://fred-zone.blogspot.com/2009/09/trace-cflow.html Fred 有寫過用在分析 Android Dalvik VM 的示範] - 產生文字輸出 * 有 [http://packages.debian.org/cflow Debian 套件 cflow] * [http://cscope.sourceforge.net/ cscope]/[http://www.gnu.org/software/global/ global] - Interactively examine a C program source - 我想 cscope 要強調的是 interactive 互動式除錯,而且照 Rex 的講法,可以只針對某個函數當進入點,而不是整個程式原始碼。 * 有 [http://packages.debian.org/cscope Debian 套件 cscope] 跟 [http://packages.debian.org/global global] * [http://www.vim.org/scripts/script.php?script_id=2368 CCTree] - C Call-Tree Explorer - Cscope based source-code browser, code flow analysis tool - 給 VIM 用的 cscope plugin * [http://code.google.com/p/seascope/ seascope] - A pyQt GUI front-end for cscope - pyQt 寫的 cscope 圖形介面 * [http://sourceforge.net/projects/kscope/ kscope] - A source-code browsing, analysis and editing environment for large C projects. - KDE 版本的 cscope 圖形介面 - 有 [http://packages.debian.org/kscope Debian 套件 kscope] * [http://kcachegrind.sourceforge.net/ KCachegrind] - Profiling Visualization - 這個工具是搭配 Valgrind 這個 Profiler 可以在 runtime 產生 callgrah * [http://code.google.com/p/jrfonseca/wiki/Gprof2Dot Gprof2Dot] - 也是透過 profiler 產生的輸出來作視覺化動作,最初是支援 gprof 現在已經支援更多不同 profiler 了。 * [http://www.gson.org/egypt/ egypt] - 用 Perl 寫的 * Python * [http://pycallgraph.slowchop.com/ pycallgraph] - Python Call Graph * Bash * 我一直想找的是 Bash 的遞迴式 callgraph 產生器,雖然 Bash 可以加入 -X 參數來做 runtime 除錯,不過還沒有找到可以查出多層該怎麼追。 * [http://bashdb.sourceforge.net/ bashdb] - BASH Debugger - 可以用類似 GDB 的指令來 DEBUG Bash * shprof - a line profiler for shell scripts * [http://dev.gentoo.org/~dberkholz/scripts/shprof 原始碼] * 這邊有一招是蠻好玩的,居然只要設定 PS4 環境變數就可以秀出每個呼叫的開始時間。(這算是 bash 的簡易版 profiler 嘛?) [http://www.myunitsconverter.com/thread/885124/time%20profiling%20a%20linux%20command%20or%20script <參考討論> time profiling a linux command or script] {{{ Least invasive you may want to play with some variant of... set -x PS4='$( date ): ' sleep 1 sleep 3 sleep 2 exit 0 which produces timestamps in front of the commands... Mon Mar 17 02:39:35 CET 2008: PS4='$( date ): ' Mon Mar 17 02:39:35 CET 2008: sleep 1 Mon Mar 17 02:39:36 CET 2008: sleep 3 Mon Mar 17 02:39:39 CET 2008: sleep 2 Mon Mar 17 02:39:41 CET 2008: exit 0 }}}