LINUX Developer must must master: grep ,| , awk , fine,ldd, pmap,ps,vim+cscope +ctags...

http://www.vim.org/scripts/script_search_results.php 

 

 

1.源码文件搜索

源码分析时,寻找文件名中包含某关键字的文件路径:比如寻找kernel源码中包含  usb的文件名。

cd  kernelSourceCode/

ls -R | grep usb

------------------------------------------一堆反馈中有一个 usbip.h

find ./ -maxdepth 100 -name usbip.h

会罗列出路径 ./**/**/**/usbip.h

----------------------------------------------------------------------------------------------------------------------------------------------

2.程序和进程链接到的lib文件

比如查看/bin/ls 相关的lib文件

ldd   /bin/ls

------------------------------------------------------------------------------------------------

ps  -ax     #in android smart phone may be  ps -A ,because of like busybox

pmap  2235

--------------------------------------------------------------------------------------------------

3.vim cscope ctags ...

ctags:在vim打开的源码文件中,能够跳转到被调函数的定义处。

ctags

(1.)安装ctags

下载5.8版,ubuntu18 LTS还是可以用的。http://ctags.sourceforge.net

找一个自己的文件夹,cp过去,

$tar zxvf   ./ctags**.tar.gz

$cd ./ctags-5.8

$./configure

$make

$sudo make install

(2.)应用ctags

cd至项目源码的根目录,比如/home/leilei/projectsSource/,执行:

$ctags -R

在当前项目源码根目录/home/leilei/projectsSource/中产生一个新文件:tags,它记录了函数调用关系,是一个几十兆大小的文件。

vim打开本项目中某源码文件,比如/home/leilei/projectsSource/hello/hello.c

$vim hello.c

vim命令模式时输入:

:set  tags=/home/leilei/projectsSource/tags

回车。

使用上下左右键将光标缓缓移至被调函数处,比如 helloCallMeFunc();。

按下Ctl+],即跳至helloCallMeFunc(){...}

可以递归Ctl+]

每每按下Ctl+t,即可跳回上一层函数定义和调用处。

----------------------------------------------------------------------

GLOBAL

安装global

1、download GLOBAL

http://www.gnu.org/software/global/global.html 

2、三板斧

./configure --prefix=[your install dir]

make

make install
--------------------------------------------------------------------
使用global......

Source Explorer      https://github.com/wesleyche/SrcExpl 
NERD Tree             http://www.vim.org/scripts/script.php?script_id=1658 
Tag List                   http://www.vim.org/scripts/script.php?script_id=273
----------------------------------------------------- ------------------------

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值