Debian Code Search (DCS), is a freely available Debian service for searching the complete corpus of source code used to build all of the open source projects included in the Debian package archive (though only the "main" component, not "non-free", "non-free-firmware" or "contrib"). Currently, that numbers about 18,000 packages which are collectively built from 140 GiB of source code, with the index updating roughly every two hours.
The underlying search engine is based on the (Google) Code Search tools designed by Russ Cox and likewise implemented in the Go programming language, using regular expressions as input (according to the RE2 library syntax).
Contents
Search interface keywords
filetype
The filetype:lang keyword filters search results by programming language as determined by file extension. The following values for the lang argument are currently implemented:
- c
- *.c, *.h
- c++
*.cpp, *.cxx, *.hpp, *.hxx, plus results for filetype:c (*.c and *.h)
- go (golang)
- *.go
- java
- *.java
- perl
- *.pl, *.pm, *.t
- python
- *.py
- ruby
- *.rb
- shell
- *.bash, *.sh, *.zsh
package / pkg
The package:name (or pkg:name) keyword restricts a search to only the specified Debian source package(s). The name argument accepts either a valid source package name or a regular expression that defines a set of multiple packages.
For example, to find all calls to xcb_create_window present in the i3 window manager, you could search for
xcb_create_window package:i3-wm
path
The path:pathspec keyword restricts a search to only files that match the pathspec argument, either as a substring or a regular expression.
For example, to find only matches for the string systemctl within Debian packaging files, use the search terms
systemctl path:debian/
…or to find only matches for the string i3Font within the libi3 folder of any version of the i3-wm package, search for
i3Font path:i3-wm_.*/libi3/
Testimonials
I often use Code Search to find examples for specific features that are not very well documented, like DEP-3 patch tags.
— Michael Stapelberg, Debian Developer
Debian Sources allows browsing through the source code of all Debian packages. Having that, it just comes natural to viewers of the website to do searches through that mass of source code. Integrating with Code Search made that trivial to achieve. Thanks for it!
— Stefano Zacchiroli, Debian Developer
I use Code Search to find out whether external kernel modules are using a function and whether an ABI change in the function requires a new kernel module ABI number.
— Ben Hutchings, Debian Developer
I use Debian Code Search to find out how to use under-documented APIs and to see how others are actually using the APIs I provide. It's also quite useful to gauge the adoption of various algorithms, features, libraries, and APIs.
— Nick Mathewson, Tor and Libevent developer
For planning (library) transitions, Code Search has become an invaluable tool to me. I use it regularly to check for users of certain library APIs, D-Bus interfaces or packages calling binaries.
— Michael Biebl, Debian Developer
Code Search and Sources are the tools I have been dreaming of for years! Thank you.
— Ana Guerrero Lopez, Debian Developer
I use Code Search frequently (multiple times per week) at work and also for release work, to find where some specific code is used and how it is used. It's also very helpful to check for dependencies on essential packages very quickly.
— Philipp Kern, Debian Developer
The QA work I am doing both as part of my work/research (see the bug tag [[DebianBug:tag:goto-cc|goto-cc]]) and as a Debian Developer would be a lot less efficient without the combination of codesearch.d.n and sources.d.n. Also, I'm now frequently pointing non-Debian coworkers at either of them to quickly get an idea about certain aspects of software. Thanks you!!
— Michael Tautschnig, Debian Developer
I use Code Search to look for common security vulnerabilities and to find patterns of library misuse. It is a great help in improving the quality of the archive! I also use it to help library upstreams plan API transitions; being able to quickly tell an upstream development team that "If you drop this interface, 15 packages in Debian won't be able to move to your new API without their own changes" or "That interface isn't used by any package in Debian" is a great thing.
— Daniel Kahn Gillmor, Debian Developer
Code Search is becoming an essential part of the Debian infrastructure that allows one to quickly answer questions that would otherwise have needed tedious regular expression searches in the Lintian lab. Another very positive impact is that it structures technical discussions on our mailing lists, where there is no excuse anymore for making statements about our archive's contents without first testing them concretely. It quickly gets people to the facts, which is essential to Debian's goal of technical excellence.
— Charles Plessy, Debian Developer
Debian Code Search is valuable for free software developers, even outside of your community. I use this service as part of OpenBSD's continuous effort to identify buggy or insecure API calls. If we see a function being abused in our tree, DCS lets us quickly see how widespread the problem is and track how quickly projects adopt any safer alternatives we might introduce. I also use it to determine how safe it is to remove legacy API functions from LibreSSL.
I have tried most of the code-indexing sites available, and Debian's provides the most relevant results for us. Thanks for making this service available to non-DDs.
— Doug Hogan, OpenBSD developer
Code Search made so much possible for the Reproducible Builds effort. So much data love!
— Lunar, Debian Developer
I use Code Search frequently – it's an amazing tool when making Debian-wide changes. For example, it provides an easy way to check which packages call a particular M4 macro. The implementation of the Janitor service would have been much harder without DCS.
— Jelmer Vernooij, Debian Developer
When documenting API functions in LibreSSL, I consistently and very frequently use Debian Code Search to find out whether a given function is actually used in any real-world software. Functions that see real-world use should be documented; those that don't should remain undocumented to avoid needless bloat of the manual. DCS is ideal for this purpose due to the vast amount of code indexed, its easy-to-use user interface and its simple and straightforward output format.
— Ingo Schwarze, OpenBSD developer and LibreSSL documentation chief maintainer
I frequently use codesearch.d.o – most notably for the development of licensecheck and related libraries, where the ability to apply regular expression patterns to the whole set of Debian packages' source code is immensely helpful.
— Jonas Smedegaard, Debian Developer
If Debian Code Search is helpful to you, please make others aware of it by posting a short testimonial to this list.
Developer
Michael Stapelberg created and maintains DCS; he also authored his Bachelor of Computer Science thesis (1 MiB PDF) about the service.
Feature requests
Requests for new features are welcome, if reasonable, and can be made at the GitHub Issue Tracker.
Support
For one-on-one support with DCS, please email <stapelberg AT debian DOT org> (include DCS or Debian Code Search in the subject).
See also
