歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux基礎知識 >> 技巧:使用Emacs+Cscope來閱讀代碼

技巧:使用Emacs+Cscope來閱讀代碼

日期:2017/3/2 14:56:18   编辑:Linux基礎知識
1. 安裝 cscope,

http://cscope.sourceforge.Net/

到這裡下載cscope, 最新版本為 15.6.

如果你使用 debian 或者 ubuntu,直接 sudo apt-get install cscope就可以了

2. 安裝 xcscope.el

把 cscope 附帶的 xcscope.el 文件放到你的 emacs的 load-path 下,在 ~/.eMacs 中增加:

(require 'xcscope)

3. 生成 project 文件列表,可以用如下命令完成。例如kernel代碼,找出所以 .h, .c, .S文件

find -type f | grep -E '\.[chS]$' > cscope.files

4. 生成 cscope 索引文件, -k 專門用於生成 Linux kernel 源碼的索引

cscope -b -k

5. 運行 eMacs,以下是一些常用的按鍵

C-c s C-h 查看所有的 cscope 相關的按鍵

C-c s a 設定索引文件所在目錄

C-c s c 查找調用該函數的地方

C-c s g 查找該符號的全局定義

C-c s f 查找該符號對應的文件

……

如果習慣了EMacs的這種按鍵,感覺使用起來還是挺方便的,感興趣的可以自己體會。

Copyright © Linux教程網 All Rights Reserved