Blame doc/debuginfod_find_debuginfo.3

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_FIND_* 3
Packit 032894
.SH NAME
Packit 032894
debuginfod_find_debuginfo \- request debuginfo from debuginfod
Packit 032894
Packit 032894
.SH SYNOPSIS
Packit 032894
.nf
Packit 032894
.B #include <elfutils/debuginfod.h>
Packit 032894
.PP
Packit 032894
.BI "debuginfod_client *debuginfod_begin(void);"
Packit 032894
.BI "void debuginfod_end(debuginfod_client *" client ");"
Packit 032894
Packit 032894
.BI "int debuginfod_find_debuginfo(debuginfod_client *" client ","
Packit 032894
.BI "                              const unsigned char *" build_id ","
Packit 032894
.BI "                              int " build_id_len ","
Packit 032894
.BI "                              char ** " path ");"
Packit 032894
.BI "int debuginfod_find_executable(debuginfod_client *" client ","
Packit 032894
.BI "                               const unsigned char *" build_id ","
Packit 032894
.BI "                               int " build_id_len ","
Packit 032894
.BI "                               char ** " path ");"
Packit 032894
.BI "int debuginfod_find_source(debuginfod_client *" client ","
Packit 032894
.BI "                           const unsigned char *" build_id ","
Packit 032894
.BI "                           int " build_id_len ","
Packit 032894
.BI "                           const char *" filename ","
Packit 032894
.BI "                           char ** " path ");"
Packit 032894
Packit 032894
.BI "typedef int (*debuginfo_progressfn_t)(debuginfod_client *" client ","
Packit 032894
.BI "                                      long a, long b);"
Packit 032894
.BI "void debuginfod_set_progressfn(debuginfod_client *" client ","
Packit 032894
.BI "                               debuginfo_progressfn_t " progressfn ");"
Packit 032894
Packit 032894
Link with \fB-ldebuginfod\fP.
Packit 032894
Packit 032894
.SH DESCRIPTION
Packit 032894
Packit 032894
.BR debuginfod_begin ()
Packit 032894
creates a \fBdebuginfod_client\fP connection handle that should be used
Packit 032894
with all other calls.
Packit 032894
.BR debuginfod_end ()
Packit 032894
should be called on the \fBclient\fP handle to release all state and
Packit 032894
storage when done.
Packit 032894
Packit 032894
.BR debuginfod_find_debuginfo (),
Packit 032894
.BR debuginfod_find_executable (),
Packit 032894
and
Packit 032894
.BR debuginfod_find_source ()
Packit 032894
query the debuginfod server URLs contained in
Packit 032894
.BR $DEBUGINFOD_URLS
Packit 032894
(see below) for the debuginfo, executable or source file with the
Packit 032894
given \fIbuild_id\fP. \fIbuild_id\fP should be a pointer to either
Packit 032894
a null-terminated, lowercase hex string or a binary blob. If
Packit 032894
\fIbuild_id\fP is given as a hex string, \fIbuild_id_len\fP should
Packit 032894
be 0. Otherwise \fIbuild_id_len\fP should be the number of bytes in
Packit 032894
the binary blob.
Packit 032894
Packit 032894
.BR debuginfod_find_source ()
Packit 032894
also requries a \fIfilename\fP in order to specify a particular
Packit 032894
source file. \fIfilename\fP should be an absolute path that includes
Packit 032894
the compilation directory of the CU associated with the source file.
Packit 032894
Relative path names commonly appear in the DWARF file's source directory,
Packit 032894
but these paths are relative to individual compilation unit AT_comp_dir
Packit 032894
paths, and yet an executable is made up of multiple CUs. Therefore, to
Packit 032894
disambiguate, debuginfod expects source queries to prefix relative path
Packit 032894
names with the CU compilation-directory, followed by a mandatory "/".
Packit 032894
Packit 032894
Note: the caller should not elide \fB../\fP or \fB/./\fP or extraneous
Packit 032894
\fB///\fP sorts of path components in the directory names, because if
Packit 032894
this is how those names appear in the DWARF files, that is what
Packit 032894
debuginfod needs to see too.
Packit 032894
Packit 032894
If \fIpath\fP is not NULL and the query is successful, \fIpath\fP is set
Packit 032894
to the path of the file in the cache. The caller must \fBfree\fP() this value.
Packit 032894
Packit 032894
The URLs in \fB$DEBUGINFOD_URLS\fP may be queried in parallel. As soon
Packit 032894
as a debuginfod server begins transferring the target file all of the
Packit 032894
connections to the other servers are closed.
Packit 032894
Packit 032894
A \fBclient\fP handle should be used from only one thread at a time.
Packit 032894
Packit 032894
.SH "RETURN VALUE"
Packit 032894
Packit 032894
\fBdebuginfod_begin\fP returns the \fBdebuginfod_client\fP handle to
Packit 032894
use with all other calls.  On error \fBNULL\fP will be returned and
Packit 032894
\fBerrno\fP will be set.
Packit 032894
Packit 032894
If a find family function is successful, the resulting file is saved
Packit 032894
to the client cache and a file descriptor to that file is returned.
Packit 032894
The caller needs to \fBclose\fP() this descriptor.  Otherwise, a
Packit 032894
negative error code is returned.
Packit 032894
Packit 032894
.SH "PROGRESS CALLBACK"
Packit 032894
Packit 032894
As the \fBdebuginfod_find_*\fP() functions may block for seconds or
Packit 032894
longer, a progress callback function is called periodically, if
Packit 032894
configured with
Packit 032894
.BR debuginfod_set_progressfn ().
Packit 032894
This function sets a new progress callback function (or NULL) for the
Packit 032894
client handle.
Packit 032894
Packit 032894
The given callback function is called from the context of each thread
Packit 032894
that is invoking any of the other lookup functions.  It is given two
Packit 032894
numeric parameters that, if thought of as a numerator \fIa\fP and
Packit 032894
denominator \fIb\fP, together represent a completion fraction
Packit 032894
\fIa/b\fP.  The denominator may be zero initially, until a quantity
Packit 032894
such as an exact download size becomes known.
Packit 032894
Packit 032894
The progress callback function is also the supported way to
Packit 032894
\fIinterrupt\fP the download operation.  (The library does \fInot\fP
Packit 032894
modify or trigger signals.)  The progress callback must return 0 to
Packit 032894
continue the work, or any other value to stop work as soon as
Packit 032894
possible.  Consequently, the \fBdebuginfod_find_*\fP() function will
Packit 032894
likely return with an error, but might still succeed.
Packit 032894
Packit 032894
Packit 032894
.SH "CACHE"
Packit 032894
If the query is successful, the \fBdebuginfod_find_*\fP() functions save
Packit 032894
the target file to a local cache. The location of the cache is controlled
Packit 032894
by the \fB$DEBUGINFOD_CACHE_PATH\fP environment variable (see below).
Packit 032894
Cleaning of the cache is controlled by the \fIcache_clean_interval_s\fP
Packit 032894
and \fImax_unused_age_s\fP files, which are found in the
Packit 032894
\fB$DEBUGINFOD_CACHE_PATH\fP directory. \fIcache_clean_interval_s\fP controls
Packit 032894
how frequently the cache is traversed for cleaning and \fImax_unused_age_s\fP
Packit 032894
controls how long a file can go unused (fstat(2) atime) before it's
Packit 032894
removed from the cache during cleaning. These files should contain only an
Packit 032894
ASCII decimal integer representing the interval or max unused age in seconds.
Packit 032894
The default is one day and one week, respectively.  Values of zero mean "immediately".
Packit 032894
Packit 032894
.SH "SECURITY"
Packit 032894
.BR debuginfod_find_debuginfo (),
Packit 032894
.BR debuginfod_find_executable (),
Packit 032894
and
Packit 032894
.BR debuginfod_find_source ()
Packit 032894
\fBdo not\fP include any particular security
Packit 032894
features.  They trust that the binaries returned by the debuginfod(s)
Packit 032894
are accurate.  Therefore, the list of servers should include only
Packit 032894
trustworthy ones.  If accessed across HTTP rather than HTTPS, the
Packit 032894
network should be trustworthy.  Passing user authentication information
Packit 032894
through the internal \fIlibcurl\fP library is not currently enabled, except
Packit 032894
for the basic plaintext \%\fIhttp[s]://userid:password@hostname/\fP style.
Packit 032894
(The debuginfod server does not perform authentication, but a front-end
Packit 032894
proxy server could.)
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
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 86a02d
.TP 21
Packit 86a02d
.B DEBUGINFOD_PROGRESS
Packit 86a02d
This environment variable governs the default progress function.  If
Packit 86a02d
set, and if a progressfn is not explicitly set, then the library will
Packit 86a02d
configure a default progressfn.  This function will append a simple
Packit 86a02d
progress message periodically to stderr.  The default is no progress
Packit 86a02d
function output.
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
Packit 032894
.SH "ERRORS"
Packit 032894
The following list is not comprehensive. Error codes may also
Packit 032894
originate from calls to various C Library functions.
Packit 032894
Packit 032894
.TP
Packit 032894
.BR EACCESS
Packit 032894
Denied access to resource located at the URL.
Packit 032894
Packit 032894
.TP
Packit 032894
.BR ECONNREFUSED
Packit 032894
Unable to connect to remote host.
Packit 032894
Packit 032894
.TP
Packit 032894
.BR ECONNRESET
Packit 032894
Unable to either send or recieve network data.
Packit 032894
Packit 032894
.TP
Packit 032894
.BR EHOSTUNREACH
Packit 032894
Unable to resolve remote host.
Packit 032894
Packit 032894
.TP
Packit 032894
.BR EINVAL
Packit 032894
One or more arguments are incorrectly formatted. \fIbuild_id\fP may
Packit 032894
be too long (greater than 256 characters), \fIfilename\fP may not
Packit 032894
be an absolute path or a debuginfod URL is malformed.
Packit 032894
Packit 032894
.TP
Packit 032894
.BR EIO
Packit 032894
Unable to write data received from server to local file.
Packit 032894
Packit 032894
.TP
Packit 032894
.BR EMLINK
Packit 032894
Too many HTTP redirects.
Packit 032894
Packit 032894
.TP
Packit 032894
.BR ENETUNREACH
Packit 032894
Unable to initialize network connection.
Packit 032894
Packit 032894
.TP
Packit 032894
.BR ENOENT
Packit 032894
Could not find the resource located at URL. Often this error code
Packit 032894
indicates that a debuginfod server was successfully contacted but
Packit 032894
the server could not find the target file.
Packit 032894
Packit 032894
.TP
Packit 032894
.BR ENOMEM
Packit 032894
System is unable to allocate resources.
Packit 032894
Packit 032894
.TP
Packit 032894
.BR ENOSYS
Packit 032894
\fB$DEBUGINFOD_URLS\fP is not defined.
Packit 032894
Packit 032894
.TP
Packit 032894
.BR ETIME
Packit 032894
Query failed due to timeout. \fB$DEBUGINFOD_TIMEOUT\fP controls
Packit 032894
the timeout duration. See debuginfod(8) for more information.
Packit 032894
Packit 032894
.SH "FILES"
Packit 032894
.LP
Packit 032894
.PD .1v
Packit 032894
.TP 20
Packit 032894
.B $HOME/.debuginfod_client_cache
Packit 032894
Default cache directory.
Packit 032894
.PD
Packit 032894
Packit 032894
.SH "SEE ALSO"
Packit 032894
.I "debuginfod(8)"