cscope笔记

LNX=/home/jru/linux-2.4.18
cd /
find $LNX -path “$LNX/arch/*” ! -path “$LNX/arch/i386*” -prune -o -path “$LNX/include/asm-*” ! -path “$LNX/include/asm-i386*” -prune -o -path “$LNX/tmp*” -prune -o -path “$LNX/Documentation*” -prune -o -path “$LNX/scripts*” -prune -o -path “$LNX/drivers*” -prune -o -name “*.[chxsS]” -print >/home/jru/cscope/cscope.files

cscope -b -q -k
-b build the database without launching Cscope GUI
-q additional ‘inverted index’
-k ‘kernel’ mode, turn off the use of default include dir

export CSCOPE_DB=./cscope.out

vim -t symbol_name

See also
http://cscope.sourceforge.net/large_projects.html

Tags: ,

Gentoo – 中文化

ln -sf /usr/share/zoneinfo/Asia/Taipei /etc/localtime
USE中加入cjk nls zh_CN

# nano -w /etc/env.d/00locale
然後在那個檔案裡面加入:
LC_ALL=”zh_TW.Big5″
LANG=”zh_TW.Big5″
以上兩個參數將告訴系統要使用繁體中文

只中文化X
# nano -w ~/.xinitrc
輸入以下指令:
export LC_ALL=”zh_TW.Big5″
如果您打算在使用 gnome:
exec gnome-session
如果您打算使用 kde:
exec startkde

emerge arphicfonts twmoefonts zh-kcfonts

Tags:

Gentoo – Portage

emerge sync

emerge –pretend kdevelop
–fetchonly:下载安装套件需要的档案以及他依赖的套件。
–emptytree:这个选项让 Portage 以为相依的套件都没有安装。这是一个很有用的选项让 –pretend 显示完整的相依性列表。
–nodeps:Portage 指安装指定的套件而略过任何的相依性。如果你没优安装合适的相依套件,编译时可能会失败。
–onlydeps:只安装相依套件,指定要安装的套件不会被安装。
–noreplace:如果套件已经安装了就略过不装。
–usepkg:不要编译指定的套件,Portage 会使用预先编译好放在指定位置的 tbz2 套件,这个位置在 PKGDIR 环境变数指定。
–debug:ebuild会显示更多东西,这在发展者检查以 bash script 为基础的 ebuild 档的语法错误是很有用的。
–autoclean:强制 emerge 在刊使编译前清除暂可收购存目录。Portage 预设就会执行这个动作,所以这对关闭这个选项的发展者才有用。
–verbose:告诉 emerge 以完整模式执行。这通常和 –pretend 一起使用来显示这个套件可用的 USE 设定。

emerge unmerge \<=dev-utils/ltrace-0.3.15
移除特定的版本

emerge –update system
系统更新(只包含基础套件)
emerge –update –deep world
包含dependencies

emerge –update –deep –newuse world
改变了USE

emerge –update world
可手工编辑 /var/cache/edb/world
例:net-im/gaim
net-www/skipstone
net-www/galeon

emerge –upgradeonly world
只升级(不降级)

emerge clean

# emerge –update –deep –newuse world
# emerge –depclean
# revdep-rebuild // 包含在gentoolkit
因为有些库被移走,故需要重新编译

摘自
http://gentoo.linuxsir.org/doc/cn/portage-manual.xml
http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=2&chap=1

Tags:

VIM笔记

=============================
help
=============================
PREPEND
Visual mode commands v_
Insert mode commands i_
Command-line commands :
Command-line editing c_
Options ‘ // :help ‘textwidth’

=============================
editing
=============================
:g+//+s/foobar/barfoo/g // g[lobal]默认作用范围是整个文件
:g/./,/^$/join

!5Gsort<Enter>
!{motion}{filter}
!!{filter}

set virtualedit=all
set virtualedit=

=============================
motion
=============================
:map <Space> W
g前缀使命令不是linewise的,常在wrap时和原命令有所区别

; Repeat latest f, t, F or T [count] times.
, Repeat latest f, t, F or T in opposite direction [count] times.

word WORD w W
sentences ( )
paragraph { }
section ]] ][ [[ [] // 函数”{“须在第一列
]} [{ ]) [( ]/ [/

// Text object selection
// can only be used while in Visual mode or after an operator
The commands that start with "a" select "a"n object including white space, the
commands starting with "i" select an "inner" object without white space, or
just the white space.

aw aW as ap a] a[ a) a( a> a< a} a{ // s for sentence && p for paragraph
iw iW is ip i] i[ i) i( i> i< i} i{ // excluding ] [ ) ( > < } {

:set guioptions+=b // 显示滚动条

ze when 'wrap' off scroll horizontally to position the cursor at the end (right side) of the screen.
zh when 'wrap' off scroll screen N characters to the right.
zl when 'wrap' off scroll screen N characters to the left.
zs when 'wrap' off scroll horizontally to position the cursor at the start (left side) of the screen.

=============================
motion-II
=============================
CTRL-O Go to [count] Older cursor position in jump list (not a motion command).
CTRL-I Go to [count] newer cursor position in jump list (not a motion command).

=============================
programming
=============================
:tags // 显示tag stack
:tag {tagname} // 缺省时至stack的top
CTRL-]
:ptag tagname // preview
CTRL-W }
:pclose
:pedit
:psearch
:stag tagname
CTRL-W ]
CTRL-T

:set tags=./tags,./../tags,./*/tags
:set tags=./*/tags
:!ctags -R *

:tnext
:tselect tagname
:tag /block 再按tab补齐

[i // 第一个匹配项
[I // [<Tab> 跳转到[I找到的第一条匹配项
]I // start at the current cursor position
[D // 宏定义

:set path+=d:\mingw\include\*
:checkpath

=============================
text formatting
=============================
:set cindent shiftwidth=4
gg=G
:set textwidth=80

<CTRL-V> // <CTRL-Q> for Windows
Istring<Esc>
cstring<Esc>

:center // :{range}center [width]
:right

=============================
map command autocmd
=============================
:o map <F7> a{
:map <F3> oDate: <Esc>:read !date<CR>kJ

:command -nargs=* DoIt :call AFunction(<f-args>)

:autocmd [group] {events} {file_pattern} [nested] {command}

:augroup cprograms
: autocmd BufReadPost *.c,*.h :set sw=4 sts=4
: autocmd BufReadPost *.cpp :set sw=3 sts=3
:augroup END

:autocmd! cprograms //删除

=============================
vim-script
=============================
b:name buffer variable
w:name window variable
g:name global variable (also in a function)
v:name variable predefined by Vim
s:name script variable
l:name local variable
a:name function argument

$NAME environment variable
&name option
@r register

:execute “tag ” . tag_name // . for cancatenate
—> :tag tag_name
:normal gg=G
:execute “normal ” . normal_commands
:execute “normal Inew text \<Esc>”

=============================
useful links for VIM scripts
=============================
c.vim http://vim.sourceforge.net/scripts/script.php?script_id=213
——-
Setting
——-
see doc
——-
Usage
——-
<A-F9> save and compile
<F9> link
<C-F9> run

taglist.vim http://vim.sourceforge.net/scripts/script.php?script_id=273
——-
Notes
——-
noremap <silent> <F11> <Esc><Esc>:Tlist<CR>
inoremap <silent> <F11> <Esc><Esc>:Tlist<CR>
——-
Usage
——-
<CR> Jump to the location where the tag under cursor is
defined.
o Jump to the location where the tag under cursor is
defined in a new window.
p Display the tag definition in the file window and
keep the cursor in the taglist window itself.
<Space> Display the prototype of the tag under the cursor.
u Update the tags listed in the taglist window
s Change the sort order of the tags (by name or by order)
d Remove the tags for the file under the cursor
x Zoom-in or Zoom-out the taglist window
+ Open a fold
- Close a fold
* Open all folds
= Close all folds
[[ Jump to the beginning of the previous file
<Backspace> Jump to the beginning of the previous file
]] Jump to the beginning of the next file
<Tab> Jump to the beginning of the next file

EnhCommentify.vim http://vim.sourceforge.net/scripts/script.php?script_id=23
——-
Setting
——-
let g:EnhCommentifyRespectIndent = ‘yes’
let g:EnhCommentifyPretty = ‘yes’
let g:EnhCommentifyAlignRight = ‘yes’
——-
Usage
——-
\x \c

bufexplorer.zip http://vim.sourceforge.net/scripts/script.php?script_id=42
——-
Notes
——-
Needed by winmanager
——-
Usage
——-
\be \bs

winmanager http://vim.sourceforge.net/scripts/script.php?script_id=95
——-
Notes
——-
noremap <silent> <F4> <Esc><Esc>:WMToggle<CR>
inoremap <silent> <F4> <Esc><Esc>:WMToggle<CR>
——-
Usage
——-
:WManager :WMClose :WMToggle

1: File Explorer Area
<tab> : open the file or directory in a new window in the FileEditing area.
c : change the pwd to the directory currently displayed
C : change the currently displayed directory to pwd (converse of c)
s : select sort field (size, date, name)
r : reverse direction of sort
R : rename file
D : delete file
- : move up one level

cppcomplete http://vim.sourceforge.net/scripts/script.php?script_id=527
——-
Notes
——-
default mapping of <F9> conflicts with c.vim
<F8> <F9> –> <F7> <F8>
——-
Usage
——-
<A-j> <A-l> <F7> <F8> <F5>

a.vim http://vim.sourceforge.net/scripts/script.php?script_id=31
——-
Usage
——-
:A :AS :AV

borland.vim http://vim.sourceforge.net/scripts/script.php?script_id=92
——-
Usage
——-
:colorscheme borland

xmledit http://vim.sourceforge.net/scripts/script.php?script_id=301
cvsmenu.vim http://vim.sourceforge.net/scripts/script.php?script_id=58
project.tar.gz http://vim.sourceforge.net/scripts/script.php?script_id=69
grep.vim http://vim.sourceforge.net/scripts/script.php?script_id=311

————————————————–
摘录自:
VIM USER MANUAL
VIM 手册中文版 by ZhaoRuFei

Tags: ,

awk笔记

awk -F”:” ‘{ print “username: ” $1 “\t\tuid:” $3 }’ /etc/passwd

awk ‘FS=”:” {OFS=”-”} {print NR “–>” $1, $2}’ /etc/passwd

awk ‘{x=x+$3} {print NR, $3, x}’ data
awk ‘{x=x+$3} END {print NR, $3, x}’ data

awk ‘{x=x+$3} {print NR, $3, x “sort -nr”}’ data

FS=”[[:space:]+]”

NF The number of fields in the current input record.
NR The total number of input records seen so far.
OFMT The output format for numbers, “%.6g”, by default.
OFS The output field separator, a space by default.
ORS The output record separator, by default a newline.

awk中数组从1开始

for ( x in myarray ) {
print myarray[x]
}
当 awk 在数组下标之间轮转时,它不会依照任何特定的顺序

delete fooarray[1]

print length(mystring)

print index(mystring,”you”)

print tolower(mystring)
print toupper(mystring)
print mystring // unchanged

mysub=substr(mystring,startpos,maxlen)

print match(mystring,/you/), RSTART, RLENGTH
RSTART 包含返回值(第一个匹配的位置),RLENGTH 指定它占据的字符跨度(如果没有找到匹配,则返回 -1)。

sub(regexp,replstring,mystring)
sub() 将替换第一个 regexp 匹配(如果有的话),gsub() 将执行全局替换

numelements=split(“Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec”,mymonths,”,”)

test.awk
———
BEGIN { x=0 }
/^$/ { x=x+1 }
END { print “I found ” x ” blank lines. :) ” }
—————
awk -f test.awk inputfile

摘录自:
http://www-128.ibm.com/developerworks/cn/linux/shell/awk/awk-1/index.html
http://www-128.ibm.com/developerworks/cn/linux/shell/awk/awk-2/index.html
http://www-128.ibm.com/developerworks/cn/linux/shell/awk/awk-3/index.html

Tags: ,

gdb笔记

(gdb) set $i=0
(gdb) while argv[$i] != 0
>print argv[$i++]
>end

(gdb) x /2cb argv[0]
0xfef82b5e: 47 ‘/’ 114 ‘r’
(gdb) x /2tb argv[0]
0xfef82b5e: 00101111 01110010
(gdb) x /2tw argv[0]
0xfef82b5e: 01101111011011110111001000101111 01101111011101110010111101110100

>silent
>set $p=obj
>while $p != 0
>print $p->name
>set $p=$p->next
>end
>cont (断点不停)

backtrace (bt)
info frame
up
info frame
info locals
frame 0
return 10

call printf(“test\0″)
call fflush(0)

disassemble
watchpoint
display
info display show display

http://www.linuxforum.net/books/LinuxFAQ/program-gdb.html

Tags: ,

vmware下将RH9内核升级至2.6

虚拟机版本vmware:4.5.1 build-7568
原内核版本Redhat 9 linux-2.4.20-8
待升级版本linux-2.6.11.7

下载内核linux-2.6.11.7.tar.bz2至/usr/src并解压
ln -s linux-2.6.11.7 linux-2.6
在/usr/src/linux/Documentation/Changes查看相应软件的版本要求

下载并安装module-init-tools-3.1.tar.bz2
# configure –prefix=/
# make moveold
# make all install
# ./generate-modprobe.conf /etc/modprobe.conf
下载并安装device-mapper-1.00.19-2.i386.rpm
下载并安装lvm2-2.00.25-1.01.i386.rpm,用rpm -ivph –nodeps –force
下载并安装mkinitrd-4.1.18-2.i386.rpm

在/usr/src/linux-2.6下make mrproper(如果之前未编译过,此步骤可省)
make menuconfig,选择编译的模块。
Device Drivers
Block devices
Default RAM disk size 改为8192
USB support
UHCI HCD 选中(或OHCI,EHCI单独无法工作)
其余模块根据实际情况选择
make all
make modules_install
make install
/etc/modprobe.conf中相应部分更改为
alias usbfs usbcore
alias usb-controller uhci-hcd
鼠标键盘部分(hid, mousedev, keybdev)等部分酌情修改
/etc/rc.sysinit中
usbdevfs改为usbfs
hid改为usbhid
mousedev和keybdev酌情修改(分别改为usbmouse和usbkeybd或注释掉)
/etc/grub.conf中
更改default
2.6内核部分加一句elevator=deadline
reboot

学习总结
openssl+openssh的设置,配合PuTTY的使用
/etc/inetd.conf增加ssh stream tcp nowait root /usr/sbin/tcpd sshd -i
密钥对的生成ssh-keygen(Linux/Win)
公钥拷贝至~/.ssh/authorized_keys,密钥在客户端使用
grep -rnH “pattern” *
find ./ -name ‘*name*’ -print
vim
set foldmethod=indent
zf%; zi; zo; zO; .,$ d
dmesg
cat /proc/version
insmod; lsmod; modprobe -l | grep usb
useradd -s /bin/bash -g lfs -m -k /dev/null lfs

cat > ~/.bash_profile << “EOF”
exec env -i HOME=$HOME TERM=$TERM PS1=’u:w$ ‘ /bin/bash
EOF

cat > ~/.bashrc << “EOF”
set +h
umask 022
LFS=/mnt/lfs
LC_ALL=POSIX
PATH=/tools/bin:/bin:/usr/bin
export LFS LC_ALL PATH
EOF

readelf -l filename | grep interpreter
ld –verbose | grep SEARCH

Tags: ,
Page 3 of 3123