August 11, 2007

好用的source navigator:global

寫程式的人員閱讀source code的機率相當大,這時候擁有一套好了source code瀏覽器就很重要了。

在這裡,我推薦GNU Global這一套軟體,他的優點如下:

GNU GLOBAL has following features:

* support C, C++, Yacc, Java and PHP4.
* work the same way across diverse environments. Currently, support followings:
o Generic shell command line
o Bash shell
o Vi clone editor (nvi, elvis, vim)
o Emacs editor (emacs, mule, xemacs)
o Glimmer editor
o Less viewer
o Web browser (See UNIX kernel source tour!.)
o Doxygen documentation system

如果你有使用過lxr(Linux Cross Reference)這個工具的話,就會更了解這個軟體的意義,比lxr更好用的地方是還能搭配editor,例如VIM(see global with Vim)。

安裝你的distribution所附的global軟體,在Debian下只要apt-get install global就可以了。接下來,把要檢視的source code解壓縮後,在目錄下執行

gtags

它會產生四個檔案:
'GTAGS'
Tag file for function definitions.

'GRTAGS'
Tag file for function references.

'GSYMS'
Tag file for other symbols.

'GPATH'
Tag file for path of source files.

如果你要產生HTML的文件方便瀏覽的話,請繼續執行

htags -Fnsa

會在目錄下產生一個HTML目錄,可以用browser觀看,畫面如這裡(感謝Rex)。

如果要有查詢的功能,指令要改成

htags -Ffnsa

也就是多加一個"f"的參數,這個功能要搭配web server才能用喔!因為有了global這一套,我現在寫軟體都是利用global + Vim

Posted by asho at August 11, 2007 09:11 AM
Comments

global 看似 ctags+cscope 的结合体。习惯用ctags,用Global需要一点时间适应。

Gtags 有什么卖点,ctags 是比不上的?

Posted by: mysurface at October 17, 2007 11:35 PM
Post a comment









Remember personal info?