Give help information about cscope commands. Special keys If your terminal has arrow keys that work in vi, you can use them to move around the input fields. Line-Oriented interface The -l option lets you use cscope where a screen-oriented interface would not be useful, for example, from another screen-oriented program. For -l, cscope outputs the number of reference lines cscope: 2 lines For each reference found, cscope outputs a line consisting of the file name, function name, line number, and line text, separated by spaces, for example, main.
|Country:||Central African Republic|
|Published (Last):||5 January 2005|
|PDF File Size:||13.64 Mb|
|ePub File Size:||19.17 Mb|
|Price:||Free* [*Free Regsitration Required]|
Finally, start the Cscope browser: cscope -d The -d flag tells Cscope not to regenerate the database which you already did in the previous step. Within the Cscope browser, type? The browser will show you a list of the searches you can perform in your code: Find this C symbol: Find this global definition: Find functions called by this function: Find functions calling this function: Find this text string: Change this text string: Find this egrep pattern: Find this file: Find files including this file: Most of these should be self-explanatory.
You can search for all instances of a symbol, or find its original definition. Cscope can find all of the functions that call a particular function, which can be extremely useful; this is a feature of Cscope that other tools like Ctags do not have.
If you find that the C symbol and function searches do not find what you are looking for, you can fall back to the text search options at the bottom of the list. At the top of the screen Cscope will display a list of results with the file, function, and line where the search term was found. If you select one of these results and hit Enter, Cscope will open up the editor to the matching line in the file.
You can manipulate the file as you please, and when you close it the browser will appear again. Note After making modifications to your source code, the cscope database will become out of sync, so you can periodically regenerate the database by running the find and cscope commands again. Tip When searching for "global definitions," sometimes Cscope will return multiple definitions, which is annoying. It appears that many forward declarations i.
Tip See the Cscope man page and help page press? For example: -C disables case-sensitive search this can also be toggled from within Cscope with Ctrl-c. Pressing Ctrl-b allows you to search for previous search terms again. For more information on executing Cscope commands from directly within your editor especially vi , see the list of resource links at the top of this tutorial.
Cscope for Project 1 Cscope along with Ctags is an invaluable tool for navigating through the Linux kernel code that is used in project 1. To begin, follow the instructions in the project 1 description or the git tutorial to get a copy of the Linux kernel source code. Using Cscope with the Linux kernel is mostly the same as with any other project, except that we use a more advanced find command to only search through the relevant files in the Linux code.
Read the instructions in the previous section before following these steps. Warning Generating the entire Cscope database for the entire linux The size of the database can be reduced to about MB if -q is omitted, but lookups may take longer. Again, first make sure that Cscope is set to use your preferred editor, e. Here is the code that should be put into the script:!
Specifically, Cscope is used to find symbols in source code, for example variables, functions, files etc.. In order to use Cscope with leaving Vim, most of Vim have the Cscope plugin enabled. This article is going to introduce how to use Cscope integrated Vim to browse source code. Step 1: Building Cscope database of your source code Cscope database likes indexes of your source code, which facilitate finding your source code symbols more fast.
Finally, start the Cscope browser: cscope -d The -d flag tells Cscope not to regenerate the database which you already did in the previous step. Within the Cscope browser, type? The browser will show you a list of the searches you can perform in your code: Find this C symbol: Find this global definition: Find functions called by this function: Find functions calling this function: Find this text string: Change this text string: Find this egrep pattern: Find this file: Find files including this file: Most of these should be self-explanatory. You can search for all instances of a symbol, or find its original definition.
Subscribe to RSS
Jump to the tag underneath the cursor M-. Say yes when prompted to load the really big tags file. The first command is probably the one you will use most often: it jumps to the definition of the tag function name, structure name, variable name, or pretty much anything. The second command can be used to search for any tag in the TAGS file, regardless of the file you are currently viewing.
cscope(1) - Linux man page
Vim to use it. Fortunately, Cscope support has been built into Vim. But since Cscope has more search types than ctags, there are a few differences. Ideally, you will also have Vim 6. Most Vim binaries that ship with Linux distributions have the Cscope plugin enabled.