달력

42025  이전 다음

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
<LWN>
http://lwn.net/Articles/driver-porting/

<Kernel Doc>
Documentation/filesystems/sysfs.txt
Documentation/firmware_class/
Documentation/driver-model/
Documentation/kobject.txt

<header file>
#include <linux/device.h>
#include <linux/kojbect.h>
#include <linux/sysfs.h>


Posted by neodelicious
|

cscope

Tool/editor & source viewer 2011. 5. 23. 23:22
cscope - interactively examine a C program

i.e) cscope -R
i.e) cscope -b -q -k -R
i.e) cscope -d

-sdir  Look in dir for additional source files. This option is ignored if source files are given on the command line.

-R     Recurse subdirectories during search for source files.

-b     Build the cross-reference only.

-q     Enable fast symbol lookup via an inverted index. This option causes cscope to  create  2  more  files (default  names  ``cscope.in.out''  and  ``cscope.po.out'')  in addition to the normal database. This allows a faster symbol search algorithm that provides noticeably faster lookup performance for  large projects.

-k     ``Kernel Mode'', turns off the use of the default include dir (usually /usr/include)  when  building the database, since kernel source trees generally do not use it.

-d     Do not update the cross-reference.

<vim plugin>
$ cd ~/.vim/plugin
$ wget http://cscope.sourceforge.net/cscope_maps.vim

    " The following maps all invoke one of the following cscope search types:
"
" 's' symbol: find all references to the token under cursor
" 'g' global: find global definition(s) of the token under cursor
" 'c' calls: find all calls to the function name under cursor
" 't' text: find all instances of the text under cursor
" 'e' egrep: egrep search for the word under cursor
" 'f' file: open the filename under cursor
" 'i' includes: find files that include the filename under cursor
" 'd' called: find functions that function under cursor calls
아래와 같이 Ctrl + \ 에 위 단축 알파벳을 입력하면 된다.
nmap <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR>

그밖에 Ctrl + space 로 찾은 결과를 새 Window에서 볼 수 있으며,
nmap <C-@>s :scs find s <C-R>=expand("<cword>")<CR><CR>

Ctrl + space + space 로 Vertical Split도 가능하다.
nmap <C-@><C-@>s :vert scs find s <C-R>=expand("<cword>")<CR><CR>
Posted by neodelicious
|

srcexpl.vim

vim_plugin.tgz


편한 IDE가 많겠지만 개인적으로 Linux의 Source를 Windows 에서 Source Insight로 분석하고 편집한다. Linux에서 Eclipse가 좋다고는 하지만 느린 것도 같고 UI가 불편하다.

Linux에서 source를 좀 보려고 vi를 열면서 혹시나 해서 'Linux Source Insight'로 구글에게 물어봤더니 아래 Link를 알려주었다.

http://linux.softpedia.com/get/Text-Editing-Processing/Others/Text-Editor/Vim-Plugins/Source-Explorer-39586.shtml

Source Explorer 라는 Vim plugin 인데, source code에서 함수나 변수에 커서를 가져가면 선언부를 아래에 보여준다.

아래와 같이 Vim 윗 부분에 mProfile 변수에 대해서 아랫부분에 선언부분을 보여준다. 사실 이 plugin은 ctags 의 TAG에 의존하기 때문에 ctags 기능인 ctrl + } 와 ctll + t 입력도 가능하고, ctrl + w, w 를 통해서 아래 preview 부분도 이동해서 scroll 해 볼 수 있다.


이제 위 Source Explorer 를 이용하는 방법을 알아보자.

우선 현재 system에 Vim가 설치되어 있어야 한다. 그런데 기본 Ubuntu의 경우 vim-basic이 아니라 vim-tiny가 설치되어 있다.

vi 는 아래와 같이 /etc/alternatives/vi 로 symbolic link 되어 있는데,

$ ls -l /usr/bin/vi
 /usr/bin/vi -> /etc/alternatives/vi

이를 다시 확인해 보면 아래처럼 vim.tiny 라는 것을 알 수 있다.

$ ls -l /etc/alternatives/vi
 /etc/alternatives/vi -> /usr/bin/vim.tiny

만약 이미 아래와 같이 vim.basic 이라면 상관 없지만,

$ ls -l /etc/alternatives/vi
 /etc/alternatives/vi -> /usr/bin/vim.basic

아니라면 아래처럼 vim 을 설치한다.

$ sudo apt-get install vim

참고적으로 https://lists.ubuntu.com/archives/sounder/2006-September/008662.html 에 아래와 같은 글도 있더라...

AFAIK 'vim-tiny' is a very basic build of 'vim' with most optional
features disabled, so that it is functionally pretty close to the
original 'vi'.
You could say it's "vim de-improved"...  ;-)

이제 Source Explorer 를 설치해야 한다. 직접 Link 에서 받거나 첨부파일에서 srcexpl.vim 을 받아 plugin 에 복사한다. 만약 plugin 디렉토리가 없으면 만들면 된다.

$ cp srcexpl.vim /home/jaeawon/.vim/plugin

그리고 Source Explorer 는 ctags의 TAG가 필요하기 때문에,
ctags 가 없다면 우선 설치하고,

$ sudo apt-get install exuberant-ctags
해당 source path로 이동하여 TAG 정보를 생성한다.
$ ctags -R .

끝으로 source path 안에 source 파일을 열고 :SrcExplToggle 를 입력하면 Source Explorer를 즐길(?) 수 있다.

참고적으로 srcexpl.vim 파일 맨 위에 설명도 있는데, 환경 설정을 일부 할 수 있는데, 나는 아래 것 하나만 .vimrc 에 넣어서 F8로 하도록 했다.

nmap <F8> :SrcExplToggle<CR>

그리고 Link 페이지에 있는 Taglist 와 MiniBufExpl 도 쓸만한 plugin 이다.


'Tool > editor & source viewer' 카테고리의 다른 글

cscope  (0) 2011.05.23
vim 이용하기 (내가 필요한 것만...)  (0) 2011.03.01
vim 이용  (0) 2007.12.31
Posted by neodelicious
|