Saturday, May 30, 2015

Cscope & Emacs ( simple integration)

Cscope & Emacs ( simple integration)

Installation cscope

# os           :  ubuntu 13.10
# emacs  :  24.3.1
# cscope :  15.8b

Dowload cscope

$ tar zxvf cscope-X.Y.tar.gz
$ cd cscope-X.Y
$ ./configure
$ sudo make install

Cscope & Emacs configuration

$ cd contrib/xcscope
$ sudo cp cscope-indexer /usr/local/bin
$ cp xcscope.el ~/.emacs.d/

# cscope configuration for emacs 
$ echo '(load-file "~/.emacs.d/xcscope.el")' >> ~/.emacs

Create index file and set initial dir

# get ready to browse your source code.
# if you installed cscope, run emacs and work some commands by following.
M-x cscope-index-file <RET>
# and then enter your workspace path 
# or in order to detailedly collect cscope information, separately create cscope.files and cscope.out as below  
$ rm -rf cscope.files cscope.out
$ find . \( -name '*.c' -o -name '*.cpp' -o -name '*.cc' -o -name '*.h' -o -name '*.s' -o -name '*.S' \) -print > cscope.files
$ cscope -b -i cscope.files

M-x cscope-set-initial-directory <RET>
# or run this command to assign your workspace path to it
C-c s a 

Cscope commands on emacs

# most-used
C-c s d     Find global definition.
C-c s c     Find functions calling a function.
C-c s C     Find called functions (list functions called from a function).
C-c s s     Find symbol.
C-c s u     Return the point from where you jumped.

# other commands
C-c s g     Find global definition (alternate binding).
C-c s G     Find global definition without prompting.
C-c s t     Find text string.
C-c s e     Find egrep pattern.
C-c s f     Find a file.
C-c s i     Find files #including a file.
C-c s a     Set initial directory which has a index file (cscope.out).

No comments:

Post a Comment