I'm using gvim/vim with cscope/ctags to find a symbol definition in the linux kernel. The source code is huge. when I want to search for the structure device with "tag device" command as example, vim will propose me hundred of occurrences. because it will propose global variable named device, structure's member that are named device. Is there anyway to improve this? Is it possible to tell vim/cscope/tag to look only for structure definition?
Asked
Active
Viewed 2,765 times
4
-
1My comment may not be directly related. I had used cscope but found lxr to be more convinent. So i would suggest to use lxr instead of cscope. You can also try out a web based lxr at http://lxr.free-electrons.com/ and get a feel of things – Prajosh Premdas Sep 25 '14 at 11:41
-
If you want to move hand away from vim, then eclipse would be much powerful. – Neo Sep 25 '14 at 12:41
-
I am not sure eclipse and Linux kernel will be good combination – Prajosh Premdas Sep 25 '14 at 12:47
-
I have used it in the past. It tends to be slow on my i3 core cpu /3 GB ram. but then I was forced to work on virtual machine and it becomes impractical. – Neo Sep 25 '14 at 13:23
1 Answers
1
This, you might have known already. I narrow it down by cscope vim command
:cs f e struct device {
Please refer the usage of cscope vim commands
cscope commands:
add : Add a new database (Usage: add file|dir [pre-path] [flags])
find : Query for a pattern (Usage: find c|d|e|f|g|i|s|t name)
c: Find functions calling this function
d: Find functions called by this function
e: Find this egrep pattern
f: Find this file
g: Find this definition
i: Find files #including this file
s: Find this C symbol
t: Find assignments to
help : Show this message (Usage: help)
kill : Kill a connection (Usage: kill #)
reset: Reinit all connections (Usage: reset)
show : Show connections (Usage: show)

Drad
- 96
- 1
- 3
-
Thank you for posting an answer. Rather than posting links to external sites, can you please include the essence of the link/article in your answer in case the site is no longer available. – Deanna Sep 25 '14 at 13:39
-
Yes, but you have to take into account spaces ... Sometimes I use method. I add the option g- to cscopequickfix variable (set cscopequickfix=+g) so I can display the search result in the quick fix window, then cs f g ... and then I can quickly search the quick window to locate the structure definition or whatever I want. – Neo Sep 25 '14 at 14:21
-
-
-
yes, it greps the entire source. It is a tradeoff. If you have lots of definition of device, this narrows down on the struct definition in source. – Drad Sep 27 '14 at 10:36