LXR Cross Referencer, usually known as LXR, is a general-purpose source code indexer and cross-referencer for code comprehension that provides web-based browsing of source code, with links to the definition and usage of any identifier.
History
LXR was born from a need for a tool to keep a synthetic eye on the Linux kernel during its development. Such a tool is all the more necessary as documentation is scarce and contributor number is high. Two Norwegian students, Arne Georg Gleditsch and Per Kristian Gjermshus, curious about Linux architecture, began writing a small program displaying its files through a web-browser and showing variables usages after a click on the name. Aware of general interest, they posted it rapidly on SourceForge. Time passing, fans joined the development team to give code more maturity; however their number never exceeded ten. With these characteristics, LXR is a typical SourceForge-hosted project but exhibits an exceptional life duration among small projects. One of the initial creators explored new technologies giving the LXRng spin-off. This experimental development does not contain all features present in the traditional version and departs notably from LXR founding principles. Though no communication was really ever done around the tool, LXR made its way through some paper columns, e.g. Linux Journal. However, when collecting references to LXR on the Internet, there is ambiguity between the tool itself and instances of LXR displaying indexed source code. After adopting LXR to index the source code for the Mozilla Application Suite, Mozilla forked LXR to into MXR. MXR was forked in order to meet the needs of Mozilla development, namely code navigation of a mixed C++ and JavaScript codebase. After years of MXR use, Mozilla began work on a new tool with a focus on better static analysis and a dynamic Ajax UI. The result is . After DXR reached maturity, the MXR instance at mxr.mozilla.org was decommissioned.
Technology
LXR is minimalist and adheres to the least-effort principle. The deliberate bias towards minimalism avoids using too many different technologies. Thus, it limits the dependencies and the software can be supported by many configurations without special adaptation. Least-effort principle forbids tool programming if it already exists. LXR is written in Perl, handy choice for CGI scripts, but not really fit for lexical or syntactic parsing. LXR tries to impose as few constraints as possible:
After software installation, which is not a trivial task but does not require expertise, source code must be pre-processed and LXR configured to display it. Code is indexed during a second phase: identifiers are gathered and their locations entered in a data base. Reindexing is only necessary when source code is modified or a new version added. Afterwards, all is needed is to launch a web browser with an URL corresponding to the source code and navigate across files through the hyperlinks associated to identifiers.
Capabilities and limitations
Source code can be written in any language that Exuberant ctags can handle, but parsers are not equally fine-grained. Two versions of the same file can be compared side by side with differences visually enhanced. Besides hyperlinks under variables, a form allows searching for an identifier typed by the user. To work around the indexing phase limitations, any character sequence may be searched at the cost of an extensive source files traversal. LXR limitations are those of the support tools, mainly Exuberant ctags. But the primary cause of difficulties comes essentially from incorrect access permissions to files. Another limitation comes from the design choice to only do static code analysis, in contrast to which do semantic analysis as a compile step, An advanced user may change LXR layout and rendering through customizing page templates and cascading style sheet.