2342
Comment: consolidating all scattered info about IDEs / Tools in one page
|
← Revision 23 as of 2021-01-10 23:28:01 ⇥
4374
add cgvg URLs
|
Deletions are marked like this. | Additions are marked like this. |
Line 2: | Line 2: |
This page provides information about the available tools to help edit / navigate / hack the Kernel source: | When dealing with a source base as large as the kernel, it certainly helps to have software tools to help understand how the pieces fit together. This page is meant to provide you with pointers to the most commonly used tools to make your first forays in kernel-land as productive as possible. == Editing Kernel Sources == Perhaps the most important tool is a good programmers's text editor. Popular choices are [[http://www.gnu.org/software/emacs/|emacs]] and any vi clone, [[http://www.vim.org|vim]] being the most widely used these days. Generally, text editors written for programmers are programmable and have features such as syntax highlighting, text folding, brace matching, and easy integration with source management tools, such as make(1), cvs(1), text reformatting, man page lookups, and more. |
Line 5: | Line 8: |
Once you're set on using a particular editor, you will need to download the kernel source tree you want to work with. Different possibilities are available. | |
Line 8: | Line 12: |
If you want to download the lastest kernel source, you need git. You can get it from [http://git.or.cz/index.html here]. * There is a very good [http://linux.yyz.us/git-howto.html Kernel Hackers' Guide to git] * [http://www.wlug.org.nz/KernelDevelopmentWithGit Kernel Development With Git] |
If you want to download the lastest kernel source, you need git. You can get it from [[https://git-scm.com/|here]]. |
Line 12: | Line 14: |
* There are some tips while using Git [[GitTips|here]] | |
Line 13: | Line 16: |
'''Kernel tarballs''' | '''Kernel tarballs''' |
Line 15: | Line 18: |
The alternative, more "classic", way to download a kernel source tree release is to pull it from http://kernel.org/ as a compressed archive file. |
The alternative, more "classic", way to download a kernel source tree release is to pull it from http://kernel.org/ as a compressed archive file. |
Line 20: | Line 21: |
You're now ready to edit the kernel source code or browse it to learn. Where to start? As you read through the code, you'll need many times to lookup the declaration or definition of this or that particular data structure, macro or function. the most basic way to do so is to use a combination of the `grep` (or `egrep) and `find` commands; | |
Line 21: | Line 23: |
Many tools allow you to index the entire kernel source tree to faciliate its browsing. This makes learning to find your landmarks in the code a lot easier and allow you to quickly find the declarations / definitions of unknown data structures. | {{{ find . -exec grep --with-filename myfunction '{}' \; }}} Another way is, |
Line 23: | Line 28: |
{{{ find . -name '*.[chS]' | xargs egrep -n "myregularexpression"; }}} |
|
Line 24: | Line 32: |
'''Indexing tools''' | If you have GNU grep (as virtually all Linux distributions do) then you can take advantage of its "recursive" flag: |
Line 26: | Line 34: |
* [http://lxr.linux.no/ LXR project] : Nice website to browse the kernel source, search for identifiers, and diff between kernel versions. Uses [http://sourceforge.net/projects/lxr/ lxr] as its backend. * Gonzui http://softice.lakeland.usf.edu/wiki/index.php/Setting_up_Gonzui |
{{{ egrep -r --include "*.[chS]" "myregularexpression" . }}} |
Line 29: | Line 38: |
Add "-w" to avoid catching words in which your search term is a substring. | |
Line 30: | Line 40: |
'''Online browsing sites''' | This searches the current directory [and all subdirectories] for files ending with .c, .h or .S, and runs egrep on each of them for the pattern myregularexpression. Substitute myregularexpression with more complex regular expressions. |
Line 32: | Line 42: |
Some websites make it their duty to archive indexed kernel source trees: * [http://lxr.linux.no/source/ LXR Project] * [http://www.kernelhq.org/ KernelHQ] : Another website to browse/navigate the kernel source. Has all the kernel sources since 1.0. * [http://fxr.watson.org/ FXR watson] FreeBSD and Linux Kernel Cross-Reference * (An archive of all kernel versions was [http://www.memalpha.cx/Linux/Kernel/ here].) |
'''Indexing tools for web browsing''' |
Line 38: | Line 44: |
While this approach works, other tools allow you to index the entire kernel source tree to faciliate its browsing. This makes learning to find your landmarks in the code a lot easier and allow you to quickly find the declarations / definitions of unknown data structures. * [[https://elixir.bootlin.com/linux/latest/source|LXR project]] : Nice website to browse the kernel source, search for identifiers, and diff between kernel versions. Uses [[http://sourceforge.net/projects/lxr/|lxr]] as its backend. Some websites make it their duty to archive indexed kernel source trees: * [[https://elixir.bootlin.com/linux/latest/source|LXR Project]] * [[http://fxr.watson.org/|FXR watson]] FreeBSD and Linux Kernel Cross-Reference |
|
Line 41: | Line 55: |
The following help you incorporate such browsing capabilities in editors: * [http://ctags.sourceforge.net/ ctags] * [http://cscope.sourceforge.net/ cscope]. Tutorials: [http://cscope.sourceforge.net/large_projects.html Using with large projects], [http://cscope.sourceforge.net/cscope_vim_tutorial.html Using Cscope with Vim]. |
Eventually, you'll want to maybe incorporate such browsing capabilities in your favored editor: |
Line 45: | Line 57: |
* [[http://ctags.sourceforge.net/|ctags]] * [[http://cscope.sourceforge.net/|cscope]]. Tutorials: [[http://cscope.sourceforge.net/large_projects.html|Using with large projects]], [[http://cscope.sourceforge.net/cscope_vim_tutorial.html|Using Cscope with Vim]]. Alternative tools include: freescope, etags, and idutils which build databases to use when searching for C symbols. Each has their own idiosyncrasies and features. Some integrate better with your text editor of choice. (Look especially for plugins to help with integration.) cgvg is another option, though it doesn't appear to use a database to speed searches. See https://uzix.org/cgvg.html or https://github.com/uzi/cgvg. |
|
Line 46: | Line 61: |
I've posted (with minor frustrations) a StructDumper python script that scans .h files for definitions and publishes them to an .htm file. Lots of room to criticise. | |
Line 48: | Line 64: |
Navigate the changesets applied to: | |
Line 49: | Line 66: |
Navigate the changesets applied to: * [http://kernel.org/git/?p=linux/kernel/git/marcelo/linux-2.4.git;a=summary linux-2.4] * [http://kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=summary linux-2.6] |
* [[http://kernel.org/git/?p=linux/kernel/git/torvalds/linux.git;a=summary|linux-current]] |
When dealing with a source base as large as the kernel, it certainly helps to have software tools to help understand how the pieces fit together. This page is meant to provide you with pointers to the most commonly used tools to make your first forays in kernel-land as productive as possible.
Editing Kernel Sources
Perhaps the most important tool is a good programmers's text editor. Popular choices are emacs and any vi clone, vim being the most widely used these days. Generally, text editors written for programmers are programmable and have features such as syntax highlighting, text folding, brace matching, and easy integration with source management tools, such as make(1), cvs(1), text reformatting, man page lookups, and more.
Downloading
Once you're set on using a particular editor, you will need to download the kernel source tree you want to work with. Different possibilities are available.
Kernel source management with git
If you want to download the lastest kernel source, you need git. You can get it from here.
There are some tips while using Git here
Kernel tarballs
The alternative, more "classic", way to download a kernel source tree release is to pull it from http://kernel.org/ as a compressed archive file.
Navigation Aid
You're now ready to edit the kernel source code or browse it to learn. Where to start? As you read through the code, you'll need many times to lookup the declaration or definition of this or that particular data structure, macro or function. the most basic way to do so is to use a combination of the grep (or egrep) and find` commands;
find . -exec grep --with-filename myfunction '{}' \;
Another way is,
find . -name '*.[chS]' | xargs egrep -n "myregularexpression";
If you have GNU grep (as virtually all Linux distributions do) then you can take advantage of its "recursive" flag:
egrep -r --include "*.[chS]" "myregularexpression" .
Add "-w" to avoid catching words in which your search term is a substring.
This searches the current directory [and all subdirectories] for files ending with .c, .h or .S, and runs egrep on each of them for the pattern myregularexpression. Substitute myregularexpression with more complex regular expressions.
Indexing tools for web browsing
While this approach works, other tools allow you to index the entire kernel source tree to faciliate its browsing. This makes learning to find your landmarks in the code a lot easier and allow you to quickly find the declarations / definitions of unknown data structures.
LXR project : Nice website to browse the kernel source, search for identifiers, and diff between kernel versions. Uses lxr as its backend.
Some websites make it their duty to archive indexed kernel source trees:
FXR watson FreeBSD and Linux Kernel Cross-Reference
Navigation Utilities
Eventually, you'll want to maybe incorporate such browsing capabilities in your favored editor:
cscope. Tutorials: Using with large projects, Using Cscope with Vim.
Alternative tools include: freescope, etags, and idutils which build databases to use when searching for C symbols. Each has their own idiosyncrasies and features. Some integrate better with your text editor of choice. (Look especially for plugins to help with integration.) cgvg is another option, though it doesn't appear to use a database to speed searches. See https://uzix.org/cgvg.html or https://github.com/uzi/cgvg.
I've posted (with minor frustrations) a StructDumper python script that scans .h files for definitions and publishes them to an .htm file. Lots of room to criticise.
Version Control
Navigate the changesets applied to: