Blame doc/debuginfod.8

Packit 032894
'\"! tbl | nroff \-man
Packit 032894
'\" t macro stdmacro
Packit 032894
Packit 032894
.de SAMPLE
Packit 032894
.br
Packit 032894
.RS 0
Packit 032894
.nf
Packit 032894
.nh
Packit 032894
..
Packit 032894
.de ESAMPLE
Packit 032894
.hy
Packit 032894
.fi
Packit 032894
.RE
Packit 032894
..
Packit 032894
Packit 032894
.TH DEBUGINFOD 8
Packit 032894
.SH NAME
Packit 032894
debuginfod \- debuginfo-related http file-server daemon
Packit 032894
Packit 032894
.SH SYNOPSIS
Packit 032894
.B debuginfod
Packit 032894
[\fIOPTION\fP]... [\fIPATH\fP]...
Packit 032894
Packit 032894
.SH DESCRIPTION
Packit 032894
\fBdebuginfod\fP serves debuginfo-related artifacts over HTTP.  It
Packit 032894
periodically scans a set of directories for ELF/DWARF files and their
Packit 032894
associated source code, as well as RPM files containing the above, to
Packit 032894
build an index by their buildid.  This index is used when remote
Packit 032894
clients use the HTTP webapi, to fetch these files by the same buildid.
Packit 032894
Packit 032894
If a debuginfod cannot service a given buildid artifact request
Packit 032894
itself, and it is configured with information about upstream
Packit 032894
debuginfod servers, it queries them for the same information, just as
Packit 032894
\fBdebuginfod-find\fP would.  If successful, it locally caches then
Packit 032894
relays the file content to the original requester.
Packit 032894
Packit 032894
If the \fB\-F\fP option is given, each listed PATH creates a thread to
Packit 032894
scan for matching ELF/DWARF/source files under the given physical
Packit 032894
directory.  Source files are matched with DWARF files based on the
Packit 032894
AT_comp_dir (compilation directory) attributes inside it.  Duplicate
Packit 032894
directories are ignored.  You may use a file name for a PATH, but
Packit 032894
source code indexing may be incomplete; prefer using a directory that
Packit 032894
contains the binaries.  Caution: source files listed in the DWARF may
Packit 032894
be a path \fIanywhere\fP in the file system, and debuginfod will
Packit 032894
readily serve their content on demand.  (Imagine a doctored DWARF file
Packit 032894
that lists \fI/etc/passwd\fP as a source file.)  If this is a concern,
Packit 032894
audit your binaries with tools such as:
Packit 032894
Packit 032894
.SAMPLE
Packit 032894
% eu-readelf -wline BINARY | sed -n '/^Directory.table/,/^File.name.table/p'
Packit 032894
or
Packit 032894
% eu-readelf -wline BINARY | sed -n '/^Directory.table/,/^Line.number/p'
Packit 032894
or even use debuginfod itself:
Packit 032894
% debuginfod -vvv -d :memory: -F BINARY 2>&1 | grep 'recorded.*source'
Packit 032894
^C
Packit 032894
.ESAMPLE
Packit 032894
Packit 032894
If the \fB\-R\fP option is given each listed PATH creates a thread to
Packit 032894
scan for ELF/DWARF/source files contained in matching RPMs under the
Packit 032894
given physical directory.  Duplicate directories are ignored.  You may
Packit 032894
use a file name for a PATH, but source code indexing may be
Packit 032894
incomplete; prefer using a directory that contains normal RPMs
Packit 032894
alongside debuginfo/debugsource RPMs.  Because of complications such
Packit 032894
as DWZ-compressed debuginfo, may require \fItwo\fP scan passes to
Packit 032894
identify all source code.  Source files for RPMs are only served
Packit 032894
from other RPMs, so the caution for \-F does not apply.
Packit 032894
Packit 032894
If no PATH is listed, or neither \-F nor \-R option is given, then
Packit 032894
\fBdebuginfod\fP will simply serve content that it scanned into its
Packit 032894
index in previous runs: the data is cumulative.
Packit 032894
Packit 032894
File names must match extended regular expressions given by the \-I
Packit 032894
option and not the \-X option (if any) in order to be considered.
Packit 032894
Packit 032894
Packit 032894
.SH OPTIONS
Packit 032894
Packit 032894
.TP
Packit 032894
.B "\-F"
Packit 032894
Activate ELF/DWARF file scanning threads.  The default is off.
Packit 032894
Packit 032894
.TP
Packit 032894
.B "\-R"
Packit 032894
Activate RPM file scanning threads.  The default is off.
Packit 032894
Packit 032894
.TP
Packit 032894
.B "\-d FILE" "\-\-database=FILE"
Packit 032894
Set the path of the sqlite database used to store the index.  This
Packit 032894
file is disposable in the sense that a later rescan will repopulate
Packit 032894
data.  It will contain absolute file path names, so it may not be
Packit 032894
portable across machines.  It may be frequently read/written, so it
Packit 032894
should be on a fast filesytem.  It should not be shared across
Packit 032894
machines or users, to maximize sqlite locking performance.  The
Packit 032894
default database file is $HOME/.debuginfod.sqlite.
Packit 032894
Packit 032894
.TP
Packit 032894
.B "\-D SQL" "\-\-ddl=SQL"
Packit 032894
Execute given sqlite statement after the database is opened and
Packit 032894
initialized as extra DDL (SQL data definition language).  This may be
Packit 032894
useful to tune performance-related pragmas or indexes.  May be
Packit 032894
repeated.  The default is nothing extra.
Packit 032894
Packit 032894
.TP
Packit 032894
.B "\-p NUM" "\-\-port=NUM"
Packit 032894
Set the TCP port number on which debuginfod should listen, to service
Packit 032894
HTTP requests.  Both IPv4 and IPV6 sockets are opened, if possible.
Packit 032894
The webapi is documented below.  The default port number is 8002.
Packit 032894
Packit 032894
.TP
Packit 032894
.B "\-I REGEX"  "\-\-include=REGEX"  "\-X REGEX"  "\-\-exclude=REGEX"
Packit 032894
Govern the inclusion and exclusion of file names under the search
Packit 032894
paths.  The regular expressions are interpreted as unanchored POSIX
Packit 032894
extended REs, thus may include alternation.  They are evaluated
Packit 032894
against the full path of each file, based on its \fBrealpath(3)\fP
Packit 032894
canonicalization.  By default, all files are included and none are
Packit 032894
excluded.  A file that matches both include and exclude REGEX is
Packit 032894
excluded.  (The \fIcontents\fP of RPM files are not subject to
Packit 032894
inclusion or exclusion filtering: they are all processed.)
Packit 032894
Packit 032894
.TP
Packit 032894
.B "\-t SECONDS"  "\-\-rescan\-time=SECONDS"
Packit 032894
Set the rescan time for the file and RPM directories.  This is the
Packit 032894
amount of time the scanning threads will wait after finishing a scan,
Packit 032894
before doing it again.  A rescan for unchanged files is fast (because
Packit 032894
the index also stores the file mtimes).  A time of zero is acceptable,
Packit 032894
and means that only one initial scan should performed.  The default
Packit 032894
rescan time is 300 seconds.  Receiving a SIGUSR1 signal triggers a new
Packit 032894
scan, independent of the rescan time (including if it was zero).
Packit 032894
Packit 032894
.TP
Packit 032894
.B "\-g SECONDS" "\-\-groom\-time=SECONDS"
Packit 032894
Set the groom time for the index database.  This is the amount of time
Packit 032894
the grooming thread will wait after finishing a grooming pass before
Packit 032894
doing it again.  A groom operation quickly rescans all previously
Packit 032894
scanned files, only to see if they are still present and current, so
Packit 032894
it can deindex obsolete files.  See also the \fIDATA MANAGEMENT\fP
Packit 032894
section.  The default groom time is 86400 seconds (1 day).  A time of
Packit 032894
zero is acceptable, and means that only one initial groom should be
Packit 032894
performed.  Receiving a SIGUSR2 signal triggers a new grooming pass,
Packit 032894
independent of the groom time (including if it was zero).
Packit 032894
Packit 032894
.TP
Packit 032894
.B "\-G"
Packit 032894
Run an extraordinary maximal-grooming pass at debuginfod startup.
Packit 032894
This pass can take considerable time, because it tries to remove any
Packit 032894
debuginfo-unrelated content from the RPM-related parts of the index.
Packit 032894
It should not be run if any recent RPM-related indexing operations
Packit 032894
were aborted early.  It can take considerable space, because it
Packit 032894
finishes up with an sqlite "vacuum" operation, which repacks the
Packit 032894
database file by triplicating it temporarily.  The default is not to
Packit 032894
do maximal-grooming.  See also the \fIDATA MANAGEMENT\fP section.
Packit 032894
Packit 032894
.TP
Packit 032894
.B "\-c NUM"  "\-\-concurrency=NUM"
Packit 032894
Set the concurrency limit for all the scanning threads.  While many
Packit 032894
threads may be spawned to cover all the given PATHs, only NUM may
Packit 032894
concurrently do CPU-intensive operations like parsing an ELF file
Packit 032894
or an RPM.  The default is the number of processors on the system;
Packit 032894
the minimum is 1.
Packit 032894
Packit 032894
.TP
Packit 032894
.B "\-L"
Packit 032894
Traverse symbolic links encountered during traversal of the PATHs,
Packit 032894
including across devices - as in \fIfind\ -L\fP.  The default is to
Packit 032894
traverse the physical directory structure only, stay on the same
Packit 032894
device, and ignore symlinks - as in \fIfind\ -P\ -xdev\fP.  Caution: a
Packit 032894
loops in the symbolic directory tree might lead to \fIinfinite
Packit 032894
traversal\fP.
Packit 032894
Packit 032894
.TP
Packit 032894
.B "\-v"
Packit 032894
Increase verbosity of logging to the standard error file descriptor.
Packit 032894
May be repeated to increase details.  The default verbosity is 0.
Packit 032894
Packit 032894
.SH WEBAPI
Packit 032894
Packit 032894
.\" Much of the following text is duplicated with debuginfod-find.1
Packit 032894
Packit 032894
debuginfod's webapi resembles ordinary file service, where a GET
Packit 032894
request with a path containing a known buildid results in a file.
Packit 032894
Unknown buildid / request combinations result in HTTP error codes.
Packit 032894
This file service resemblance is intentional, so that an installation
Packit 032894
can take advantage of standard HTTP management infrastructure.
Packit 032894
Packit 032894
There are three requests.  In each case, the buildid is encoded as a
Packit 032894
lowercase hexadecimal string.  For example, for a program \fI/bin/ls\fP,
Packit 032894
look at the ELF note GNU_BUILD_ID:
Packit 032894
Packit 032894
.SAMPLE
Packit 032894
% readelf -n /bin/ls | grep -A4 build.id
Packit 032894
Note section [ 4] '.note.gnu.buildid' of 36 bytes at offset 0x340:
Packit 032894
Owner          Data size  Type
Packit 032894
GNU                   20  GNU_BUILD_ID
Packit 032894
Build ID: 8713b9c3fb8a720137a4a08b325905c7aaf8429d
Packit 032894
.ESAMPLE
Packit 032894
Packit 032894
Then the hexadecimal BUILDID is simply:
Packit 032894
Packit 032894
.SAMPLE
Packit 032894
8713b9c3fb8a720137a4a08b325905c7aaf8429d
Packit 032894
.ESAMPLE
Packit 032894
Packit 032894
.SS /buildid/\fIBUILDID\fP/debuginfo
Packit 032894
Packit 032894
If the given buildid is known to the server, this request will result
Packit 032894
in a binary object that contains the customary \fB.*debug_*\fP
Packit 032894
sections.  This may be a split debuginfo file as created by
Packit 032894
\fBstrip\fP, or it may be an original unstripped executable.
Packit 032894
Packit 032894
.SS /buildid/\fIBUILDID\fP/executable
Packit 032894
Packit 032894
If the given buildid is known to the server, this request will result
Packit 032894
in a binary object that contains the normal executable segments.  This
Packit 032894
may be a executable stripped by \fBstrip\fP, or it may be an original
Packit 032894
unstripped executable.  \fBET_DYN\fP shared libraries are considered
Packit 032894
to be a type of executable.
Packit 032894
Packit 032894
.SS /buildid/\fIBUILDID\fP/source\fI/SOURCE/FILE\fP
Packit 032894
Packit 032894
If the given buildid is known to the server, this request will result
Packit 032894
in a binary object that contains the source file mentioned.  The path
Packit 032894
should be absolute.  Relative path names commonly appear in the DWARF
Packit 032894
file's source directory, but these paths are relative to
Packit 032894
individual compilation unit AT_comp_dir paths, and yet an executable
Packit 032894
is made up of multiple CUs.  Therefore, to disambiguate, debuginfod
Packit 032894
expects source queries to prefix relative path names with the CU
Packit 032894
compilation-directory, followed by a mandatory "/".
Packit 032894
Packit 032894
Note: contrary to RFC 3986, the client should not elide \fB../\fP or
Packit 032894
\fB/./\fP or extraneous \fB///\fP sorts of path components in the
Packit 032894
directory names, because if this is how those names appear in the
Packit 032894
DWARF files, that is what debuginfod needs to see too.
Packit 032894
Packit 032894
For example:
Packit 032894
.TS
Packit 032894
l l.
Packit 032894
#include <stdio.h>	/buildid/BUILDID/source/usr/include/stdio.h
Packit 032894
/path/to/foo.c	/buildid/BUILDID/source/path/to/foo.c
Packit 032894
\../bar/foo.c AT_comp_dir=/zoo/	/buildid/BUILDID/source/zoo//../bar/foo.c
Packit 032894
.TE
Packit 032894
Packit 032894
.SS /metrics
Packit 032894
Packit 032894
This endpoint returns a Prometheus formatted text/plain dump of a
Packit 032894
variety of statistics about the operation of the debuginfod server.
Packit 032894
The exact set of metrics and their meanings may change in future
Packit 032894
versions.  Caution: configuration information (path names, versions)
Packit 032894
may be disclosed.
Packit 032894
Packit 032894
.SH DATA MANAGEMENT
Packit 032894
Packit 032894
debuginfod stores its index in an sqlite database in a densely packed
Packit 032894
set of interlinked tables.  While the representation is as efficient
Packit 032894
as we have been able to make it, it still takes a considerable amount
Packit 032894
of data to record all debuginfo-related data of potentially a great
Packit 032894
many files.  This section offers some advice about the implications.
Packit 032894
Packit 032894
As a general explanation for size, consider that debuginfod indexes
Packit 032894
ELF/DWARF files, it stores their names and referenced source file
Packit 032894
names, and buildids will be stored.  When indexing RPMs, it stores
Packit 032894
every file name \fIof or in\fP an RPM, every buildid, plus every
Packit 032894
source file name referenced from a DWARF file.  (Indexing RPMs takes
Packit 032894
more space because the source files often reside in separate
Packit 032894
subpackages that may not be indexed at the same pass, so extra
Packit 032894
metadata has to be kept.)
Packit 032894
Packit 032894
Getting down to numbers, in the case of Fedora RPMs (essentially,
Packit 032894
gzip-compressed cpio files), the sqlite index database tends to be
Packit 032894
from 0.5% to 3% of their size.  It's larger for binaries that are
Packit 032894
assembled out of a great many source files, or packages that carry
Packit 032894
much debuginfo-unrelated content.  It may be even larger during the
Packit 032894
indexing phase due to temporary sqlite write-ahead-logging files;
Packit 032894
these are checkpointed (cleaned out and removed) at shutdown.  It may
Packit 032894
be helpful to apply tight \-I or \-X regular-expression constraints to
Packit 032894
exclude files from scanning that you know have no debuginfo-relevant
Packit 032894
content.
Packit 032894
Packit 032894
As debuginfod runs, it periodically rescans its target directories,
Packit 032894
and any new content found is added to the database.  Old content, such
Packit 032894
as data for files that have disappeared or that have been replaced
Packit 032894
with newer versions is removed at a periodic \fIgrooming\fP pass.
Packit 032894
This means that the sqlite files grow fast during initial indexing,
Packit 032894
slowly during index rescans, and periodically shrink during grooming.
Packit 032894
There is also an optional one-shot \fImaximal grooming\fP pass is
Packit 032894
available.  It removes information debuginfo-unrelated data from the
Packit 032894
RPM content index such as file names found in RPMs ("rpm sdef"
Packit 032894
records) that are not referred to as source files from any binaries
Packit 032894
find in RPMs ("rpm sref" records).  This can save considerable disk
Packit 032894
space.  However, it is slow and temporarily requires up to twice the
Packit 032894
database size as free space.  Worse: it may result in missing
Packit 032894
source-code info if the RPM traversals were interrupted, so the not
Packit 032894
all source file references were known.  Use it rarely to polish a
Packit 032894
complete index.
Packit 032894
Packit 032894
You should ensure that ample disk space remains available.  (The flood
Packit 032894
of error messages on -ENOSPC is ugly and nagging.  But, like for most
Packit 032894
other errors, debuginfod will resume when resources permit.)  If
Packit 032894
necessary, debuginfod can be stopped, the database file moved or
Packit 032894
removed, and debuginfod restarted.
Packit 032894
Packit 032894
sqlite offers several performance-related options in the form of
Packit 032894
pragmas.  Some may be useful to fine-tune the defaults plus the
Packit 032894
debuginfod extras.  The \-D option may be useful to tell debuginfod to
Packit 032894
execute the given bits of SQL after the basic schema creation
Packit 032894
commands.  For example, the "synchronous", "cache_size",
Packit 032894
"auto_vacuum", "threads", "journal_mode" pragmas may be fun to tweak
Packit 032894
via \-D, if you're searching for peak performance.  The "optimize",
Packit 032894
"wal_checkpoint" pragmas may be useful to run periodically, outside
Packit 032894
debuginfod.  The default settings are performance- rather than
Packit 032894
reliability-oriented, so a hardware crash might corrupt the database.
Packit 032894
In these cases, it may be necessary to manually delete the sqlite
Packit 032894
database and start over.
Packit 032894
Packit 032894
As debuginfod changes in the future, we may have no choice but to
Packit 032894
change the database schema in an incompatible manner.  If this
Packit 032894
happens, new versions of debuginfod will issue SQL statements to
Packit 032894
\fIdrop\fP all prior schema & data, and start over.  So, disk space
Packit 032894
will not be wasted for retaining a no-longer-useable dataset.
Packit 032894
Packit 032894
In summary, if your system can bear a 0.5%-3% index-to-RPM-dataset
Packit 032894
size ratio, and slow growth afterwards, you should not need to
Packit 032894
worry about disk space.  If a system crash corrupts the database,
Packit 032894
or you want to force debuginfod to reset and start over, simply
Packit 032894
erase the sqlite file before restarting debuginfod.
Packit 032894
Packit 032894
Packit 032894
.SH SECURITY
Packit 032894
Packit 032894
debuginfod \fBdoes not\fP include any particular security features.
Packit 032894
While it is robust with respect to inputs, some abuse is possible.  It
Packit 032894
forks a new thread for each incoming HTTP request, which could lead to
Packit 032894
a denial-of-service in terms of RAM, CPU, disk I/O, or network I/O.
Packit 032894
If this is a problem, users are advised to install debuginfod with a
Packit 032894
HTTPS reverse-proxy front-end that enforces site policies for
Packit 032894
firewalling, authentication, integrity, authorization, and load
Packit 032894
control.  The \fI/metrics\fP webapi endpoint is probably not
Packit 032894
appropriate for disclosure to the public.
Packit 032894
Packit 032894
When relaying queries to upstream debuginfods, debuginfod \fBdoes not\fP
Packit 032894
include any particular security features.  It trusts that the binaries
Packit 032894
returned by the debuginfods are accurate.  Therefore, the list of
Packit 032894
servers should include only trustworthy ones.  If accessed across HTTP
Packit 032894
rather than HTTPS, the network should be trustworthy.  Authentication
Packit 032894
information through the internal \fIlibcurl\fP library is not currently
Packit 032894
enabled.
Packit 032894
Packit 032894
Packit 032894
.SH "ENVIRONMENT VARIABLES"
Packit 032894
Packit 032894
.TP 21
Packit 032894
.B DEBUGINFOD_URLS
Packit 032894
This environment variable contains a list of URL prefixes for trusted
Packit 032894
debuginfod instances.  Alternate URL prefixes are separated by space.
Packit 032894
Avoid referential loops that cause a server to contact itself, directly
Packit 032894
or indirectly - the results would be hilarious.
Packit 032894
Packit 032894
.TP 21
Packit 032894
.B DEBUGINFOD_TIMEOUT
Packit 032894
This environment variable governs the timeout for each debuginfod HTTP
Packit 86a02d
connection.  A server that fails to provide at least 100K of data
Packit 86a02d
within this many seconds is skipped. The default is 90 seconds.  (Zero
Packit 86a02d
or negative means "no timeout".)
Packit 86a02d
Packit 032894
Packit 032894
.TP 21
Packit 032894
.B DEBUGINFOD_CACHE_PATH
Packit 032894
This environment variable governs the location of the cache where
Packit 032894
downloaded files are kept.  It is cleaned periodically as this
Packit 032894
program is reexecuted.  The default is $HOME/.debuginfod_client_cache.
Packit 032894
.\" XXX describe cache eviction policy
Packit 032894
Packit 032894
.SH FILES
Packit 032894
.LP
Packit 032894
.PD .1v
Packit 032894
.TP 20
Packit 032894
.B $HOME/.debuginfod.sqlite
Packit 032894
Default database file.
Packit 032894
.PD
Packit 032894
Packit 032894
.TP 20
Packit 032894
.B $HOME/.debuginfod_client_cache
Packit 032894
Default cache directory for content from upstream debuginfods.
Packit 032894
.PD
Packit 032894
Packit 032894
Packit 032894
.SH "SEE ALSO"
Packit 032894
.I "debuginfod-find(1)"
Packit 032894
.I "sqlite3(1)"
Packit 032894
.I \%https://prometheus.io/docs/instrumenting/exporters/