Read the linux source code and tools --- lxr glimpse introduction Author: sea_cloud@263.net we have such experience when reading the linux source code: the core of the organization is relatively loose, when looking at a document often involve other Header file, source code file. So coming back and forth looking for variables, constants, and the definition of functions is very inconvenient, so that it is tossing several times, the mood of reading code has fallen to low. LXR (Linux Cross Reference) is a tool to solve this problem: he establishes an index database for your specified source code file, using Perl script CGI to dynamically generate web pages containing the source code, you can consult with any browser. In this web page, all variables, constants, functions are given in the form of super-connection, very convenient to check. For example, you are reading /usr/src/linux/net/socket.c source code, found function get_empty_inode doesn't know how and where to define, you just click Get_empty_Inode, LXR will return this function's definition, implementation, and What is the file in what document? Note that this information is also a super connection, click to go directly to the corresponding file. In addition, LXR also provides identifier search, file search, and combiners GlimPS can also provide full-text retrieval of all source files, even annotations! The basic installation and use of LXR and GLIMPS will be introduced below. Because Glimpse is relatively simple, it starts from it: first access the site: http://glimpse.cs.arizona.edu / get the source code of Glimpse, such as I get It is glimpse-4.12.5.tar.gz. Log in with root, in any directory, uncontrolled the compressed package with TAR ZXVF Glimpse-4.12.5.tar.gz, appears in the current directory Glimpse-4.12.5 Go to this directory, execute make. Enter the bin directory, copy the files GLIMPSE and GLIMPSEINDEX to / bin or / usr / bIN. If you use GLIMPSE separately, just simply perform GlimpseIndex foo, where foo is the directory you want to index, such as / usr / src / linux .GlimpseIndex execution result is a number in your starting directory. The index file of GLIMPSE *. Then you can find all the files containing the string yourstring under / usr / src / linux. For LXR, you can access http://lxr.linux.no to get its source code. After unpacking, follow the steps: / * The following text is derived from the help documentation of the LXR and your installment * / 1) Modify the variables in Makefile Perlbin and InstallPrefix so that they are the location of the Perl program and you want to install your LXR installation. Location. On my machine, Perlbin's value is / usr / bin / perl. As for InstallPrefix, the following principles have the following principles that the LXR installation path must be a Web server to have permission access. Therefore, its value is simple to take / home / httpd / html / lxr (for Apache Web Server).
2) Implement Make Install 3) Modify $ InstallPrefix / HTTP / LXR.CONF: BASEURL: http: // Yourip / LXR / http / htmlhead: / home / httpd / html / lxr / home / template-head htmltail: / home / HTTPD / HTML / LXR / HTTP / TEMPLATE-TAIL HTMLDIR: / HOME / HTTPD / HTML / LXR / HTTP / TEMPLATE-DIR Sourceroot: / usr / src / linux # If the Linux core code index dbdir: / home / httpd / html / lxr / dbdir / #dbdirk can be arbitrarily named, and the position of any glimpsebin: / usr / bin / glimpse # can add a file in $ installprefix / http /. htaccess content: setHandler CGI-script This file guarantees that Apache Server uses several Perl files as CGI-Script. 5) Create DBDIR according to the settings in lxr.conf, follow the above example, establish directory / home / httpd / html / lxr / dbdir to enter this directory to execute $ InstallPRefix / BIN / GENXREF YOURDIR, YourDir is a source directory, such as / usr / src / linux If you want to combine glimpse, execute GLIMPSEINDEX -H. YourDir 6) Modify /etc/httpd/conf/access.conf, join options all allowoverride all Order Allow , Deny Allow from ALL
7) Go to /etc/rc.d/init.d/ Execute Killall Httpd ./httpd start into X, use the browser http: //yourip/lxr/http/blurb.html to tell, this you can comfortable reading code . Note: The above is just the basic usage of LXR and GLIMPSE, and further instructions can refer to the connecting document. Please contact SEA_CLOUD@263.net if you have any questions. China Linux Forum Copyright