Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make cscope display full file paths during search

When I search for a C symbol or global definition using cscope, it displays the file-names and line numbers. I would like to see the full file-paths so that I can jump to my arch specific file. For example, when searching for global definition of __switch_to on cscope build on Linux code-base, I get:

Global definition: __switch_to

  File         Line
0 process.c    297 struct task_struct *__switch_to(struct task_struct *prev,
1 switch_to.h   44 #define __switch_to(prev,next,last) do { \
2 process.c    202 struct task_struct *__switch_to(struct task_struct *old,
3 process.c    400 struct task_struct *__switch_to(struct task_struct *prev,
4 process_32.c 211 __switch_to(struct task_struct *prev, struct task_struct *next)
5 process.c     80 void *__switch_to(struct task_struct *from, struct task_struct *to)
6 process_32.c 248 __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
7 process_64.c 272 __switch_to(struct task_struct *prev_p, struct task_struct *next_p)

Now, the file process.c is different for each arch. How to make cscope display the full file-paths?

like image 578
manav m-n Avatar asked Dec 18 '12 08:12

manav m-n


People also ask

How do I find my full path?

Click the Start button and then click Computer, click to open the location of the desired file, hold down the Shift key and right-click the file. Copy As Path: Click this option to paste the full file path into a document. Properties: Click this option to immediately view the full file path (location).

How do I search in cscope?

Try doing one of Cscope's other searches by using a different letter: 'g' finds the global definition(s) of a symbol, 'c' finds all calls to a function, 'f' opens the filename under the cursor (note: since Cscope by default parses all C header files it finds in /usr/include, you can open up most standard include files ...

How do you escape the cscope?

Exit cscope. If the first character of the text for which you are searching matches one of these commands, you can escape the command by entering a \ (backslash) before the character. Now move the cursor to the fifth menu item, Find this text string, enter the text out of storage, and press the Return key.

What is a cscope out file?

Cscope is a tool for working with code (primarily C code). It functions by compiling a database of C symbols that it parses out of a group of files (in this case, you'd run it on the entire source you're working with) and then performing searches on that database.


1 Answers

Run cscope with args -pn

-pn Display the last n file path components instead of the default (1). Use 0 not to display the file name at all.

Running with cscope -p4 and searching for global definition of __switch_to results in

Global definition: __switch_to

  File                           Line
0 arch/arm64/kernel/process.c    297 struct task_struct *__switch_to(struct task_struct *prev,
1 ia64/include/asm/switch_to.h    44 #define __switch_to(prev,next,last) do { \
2 arch/openrisc/kernel/process.c 202 struct task_struct *__switch_to(struct task_struct *old,
3 arch/powerpc/kernel/process.c  400 struct task_struct *__switch_to(struct task_struct *prev,
4 arch/sh/kernel/process_32.c    211 __switch_to(struct task_struct *prev, struct task_struct *next)
5 arch/um/kernel/process.c        80 void *__switch_to(struct task_struct *from, struct task_struct *to)
6 arch/x86/kernel/process_32.c   248 __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
7 arch/x86/kernel/process_64.c   272 __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
like image 132
manav m-n Avatar answered Oct 12 '22 23:10

manav m-n