A.1 Functionality

   


The LXR source-code browser creates a reference file for existing C/C++ source texts. This reference file stores links between different parts of the source code. For initializing of the LXR, the source files are searched for certain keywords, and an index of these keywords is created. The following elements of a C program are recognized as keywords, and their functions are interpreted accordingly:

  • Functions and function prototypes;

  • global variables;

  • type definitions (typedef);

  • structure definitions (struct);

  • variant definitions (union);

  • enumeration types (enum); and

  • preprocessor macros and definitions (#define).

Figure A-1. Browsing the Linux kernel in the LXR source-code browser.

graphics/xafig01.jpg


Subsequently, all keywords occurring in the source code are stored in an index file.

When a Web browser requests one of the source files, a Web page consisting of the original source-code file with all keywords emphasized by hyperlinks (see Figure A-2) is created. By clicking one of the links, another page is generated, which shows all information about this keyword. (See Figure A-3.) When a function is called, for example, the location (file and line number) of the function declaration, the actual function itself, and all locations where this function is invoked are displayed. Hyperlinks offer an easy way to jump to these locations. Figure A-2 uses the ip_rcv() function as an example, to show how this works.

Figure A-2. Browsing the Linux kernel in the LXR source-code browser, using the ip_rcv() function as example.

graphics/xafig02.jpg


Figure A-3. Showing information stored for the keyword ip_rcv.

graphics/xafig03.jpg


Consequently, rather than creating static HTML pages, the LXR source-code browser generates the pages anew upon each request. Though this approach is somewhat slower than static pages, it does not modify the source code. In addition, the volume of static pages would probably be too big and take too much memory space.

We will briefly describe the possibilities of the LXR source-code browser below. Readers who want to use the LXR source-code browser can find both the source code of the current kernel versions and the LXR packet for installation at http://lxr.linux.no. You can also easily install the LXR source-code browser on your local computer, if you have a Web server and Perl.

The functionality of LXR is currently under revision. Reference information should no longer be stored in one single file in the future, but in a database (e.g., mySQL). Information about the current development in the beta stage is available at http://lxr.sourceforge.org.

A.1.1 Navigation through the source code

The entry point into the LXR source-code browser is shown in Figure A-1. This is the root directory for source files of the Linux kernel. From this page, you have the following possibilities:

  • Browsing to a specific file of the kernel sources: You can click your way to a desired file by clicking the corresponding directories. If you know the file path, you can abbreviate it by directly typing the path in the URL. The path of the desired file is simply written after /source/ in the URL. Figure A-2 shows this by the example of the file net/ipv4/ip_input.c.

  • Searching for a file: If you don't know the name of the desired file, you can search for it on the file search page.

  • Searching for a keyword: When working with the Linux source code, we are mainly interested in functions and data structures (i.e., what was defined as keywords above).

Keywords are stored in the reference file of the LXR source-code browser. This file also includes all information about the use of a keyword. Clicking a keyword emphasized as hyperlink or explicitly searching for a keyword on the identifier search page causes a Web page similar to the one shown in Figure A-3 to be displayed. For example, the stored information shown in Figure A-3 is output for the ip_rcv() function:

  • Definition of the function: The location (file and line) of the ip_rcv() function, including statements, in the source code.

  • Definition of the function prototype: The location where ip_rcv(), including its header file, was defined as function prototype. This information helps, for example, when searching for a header file to be included when you want to use this function.

  • Calls of the function: All positions where either the ip_rcv() function is invoked or its address is assigned are displayed.

Naturally, this page with stored information varies, depending on the type of keyword. For examples, no prototype definition is shown for variables.

This information can be used to navigate easily through the kernel. Relations and processes can easily be tracked and analyzed.

  • Various architectures: The particularities of various architecture-specific parts of the kernel are considered in the creating of the index. Selection of the desired architecture (top of the Web page) causes the respective source code parts to be displayed.

  • Various source-code versions: You can use the LXR source-code browser to index several kernel versions or several software projects concurrently. Selection of the version or project (top of the Web page) causes the source code of the corresponding project to be displayed.


       


    Linux Network Architecture
    Linux Network Architecture
    ISBN: 131777203
    EAN: N/A
    Year: 2004
    Pages: 187

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net