Source code browsers
Abandoned SourceWeb
SourceWeb [13] is another example of a Clang-based technology. Again, you'd probably want to build it yourself. You'll need GCC, Clang, and Qt development headers, which should be readily available in your package manager.
Indexing a project with SourceWeb is a two-stage process. First, you create the JSON compilation database. For projects not using CMake, SourceWeb provides its own btrace
tool. It works reasonably well and relies on the same mechanisms as Bear. Choosing one over another is mainly a matter of taste. However, btrace
doesn't build compile_commands.json
directly: it generates a logfile you'll need to postprocess with the sw-btrace-to-compiledb
command. You might prefer Bear to skip this extra step.
Then, you run
sw-lang-indexer --index-project
in the project's build directory to generate an index file. The latter is a binary database that the SourceWeb GUI uses to do lookups, much like tags
or cscope.out
. This will take some time. For a large codebase, you might want to add --incremental
to retain per-file indexes and speed up future index rebuilds.
When you have an index, run sourceweb index
to launch SourceWeb navigator's Qt-based GUI. You see the project outline in the left pane; files are opened in the right (Figure 4). You can browse for files, global definitions, and symbols. To this end, SourceWeb supports regular expressions. Right-click on any symbol in the source code viewer and choose Cross-references. You'll learn how the symbol is used. This is a feature set you'd expect from a code browser, yet it's pretty basic. Moreover, the application misbehaved once and crashed during startup another time on an Ubuntu 16.04 LTS box.
SourceWeb feels interesting but somewhat incomplete, especially if you think about its GUI. And it's a pity because the project never saw official release and now seems to be unmaintained. It is about 15K source lines of code (SLOC) and BSD-licensed, so if you are looking for a pet project, please give it a chance.
Here you are. The four options I just covered aren't the only ones available in Linux. Yet, I think they are the most promising. Personally, I use Cscope and Woboq Code Browser most often, but your mileage may vary. To help you decide, I summarized the tools in Table 1, so you can compare them side by side. Shall you decide to join the Universal Ctags team, or pick up SourceWeb? Please let us know!
Table 1
Source Code Navigators
Name | Version (last release) | Active | License | Parser(s) | Interface | Language support | References [a] |
---|---|---|---|---|---|---|---|
Exuberant Ctags/Universal Ctags |
58 (7 Sep 2009)/? [b] |
No/Yes |
GPLv2 |
Custom, regex-based |
Command line [c] |
Various |
No/Yes |
Cscope |
15.8a (4 Apr 2015) |
Yes |
BSD |
Custom |
Curses [d] |
C/C++/Java [e] |
Yes |
Woboq Code Browser |
2.0.1 (10 Aug 2016) |
Yes |
Dual |
Clang |
Command line/Web |
C/C++ |
Yes |
SourceWeb |
? [b] |
No |
BSD 2-clause |
Clang |
Command line/Qt |
C/C++ |
Yes |
a. The tool not only jumps to definitions but also shows where (and how) they are used. |
|||||||
b. No official release at the time of writing. |
|||||||
c. Generator. Different front ends are available for browsing. |
|||||||
d. Third-party GUIs are available. |
|||||||
e. C++/Java support is limited. |
Infos
- "Code compilation" by Valentine Sinitsyn, Linux Voice, issue 22, January 2016, pg. 94, https://www.linuxvoice.com/download-linux-voice-issue-22/
- ctags(1) man page: https://linux.die.net/man/1/ctags
- Exuberant Ctags: http://ctags.sourceforge.net/
- Universal Ctags: http://ctags.io
- Cscope: http://cscope.sourceforge.net
- "System Calls," Linux Voice, issue 29, August 2016, pg. 20
- Ack: http://http://beyondgrep.com
- LV forums: http://forums.linuxvoice.com
- cscope(1) man page: https://linux.die.net/man/1/cscope
- Woboq: https://code.woboq.org
- Bear: https://github.com/rizsotto/Bear
- CC BY-NC-SA 3.0: https://creativecommons.org/licenses/by-nc-sa/3.0/
- SourceWeb: http://rprichard.github.io/sourceweb/
« Previous 1 2
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Canonical Releases Ubuntu 24.04
After a brief pause because of the XZ vulnerability, Ubuntu 24.04 is now available for install.
-
Linux Servers Targeted by Akira Ransomware
A group of bad actors who have already extorted $42 million have their sights set on the Linux platform.
-
TUXEDO Computers Unveils Linux Laptop Featuring AMD Ryzen CPU
This latest release is the first laptop to include the new CPU from Ryzen and Linux preinstalled.
-
XZ Gets the All-Clear
The back door xz vulnerability has been officially reverted for Fedora 40 and versions 38 and 39 were never affected.
-
Canonical Collaborates with Qualcomm on New Venture
This new joint effort is geared toward bringing Ubuntu and Ubuntu Core to Qualcomm-powered devices.
-
Kodi 21.0 Open-Source Entertainment Hub Released
After a year of development, the award-winning Kodi cross-platform, media center software is now available with many new additions and improvements.
-
Linux Usage Increases in Two Key Areas
If market share is your thing, you'll be happy to know that Linux is on the rise in two areas that, if they keep climbing, could have serious meaning for Linux's future.
-
Vulnerability Discovered in xz Libraries
An urgent alert for Fedora 40 has been posted and users should pay attention.
-
Canonical Bumps LTS Support to 12 years
If you're worried that your Ubuntu LTS release won't be supported long enough to last, Canonical has a surprise for you in the form of 12 years of security coverage.
-
Fedora 40 Beta Released Soon
With the official release of Fedora 40 coming in April, it's almost time to download the beta and see what's new.