Blame doc/debuginfod_find_debuginfo.3

Packit Service 97d2fb
'\"! tbl | nroff \-man
Packit Service 97d2fb
'\" t macro stdmacro
Packit Service 97d2fb
Packit Service 97d2fb
.de SAMPLE
Packit Service 97d2fb
.br
Packit Service 97d2fb
.RS 0
Packit Service 97d2fb
.nf
Packit Service 97d2fb
.nh
Packit Service 97d2fb
..
Packit Service 97d2fb
.de ESAMPLE
Packit Service 97d2fb
.hy
Packit Service 97d2fb
.fi
Packit Service 97d2fb
.RE
Packit Service 97d2fb
..
Packit Service 97d2fb
Packit Service 97d2fb
.TH DEBUGINFOD_FIND_* 3
Packit Service 97d2fb
.SH NAME
Packit Service 97d2fb
debuginfod_find_debuginfo \- request debuginfo from debuginfod
Packit Service 97d2fb
Packit Service 97d2fb
.SH SYNOPSIS
Packit Service 97d2fb
.nf
Packit Service 97d2fb
.B #include <elfutils/debuginfod.h>
Packit Service 97d2fb
.PP
Packit Service 97d2fb
Link with \fB-ldebuginfod\fP.
Packit Service 97d2fb
Packit Service 97d2fb
CONNECTION HANDLE
Packit Service 97d2fb
Packit Service 97d2fb
.BI "debuginfod_client *debuginfod_begin(void);"
Packit Service 97d2fb
.BI "void debuginfod_end(debuginfod_client *" client ");"
Packit Service 97d2fb
Packit Service 97d2fb
LOOKUP FUNCTIONS
Packit Service 97d2fb
Packit Service 97d2fb
.BI "int debuginfod_find_debuginfo(debuginfod_client *" client ","
Packit Service 97d2fb
.BI "                              const unsigned char *" build_id ","
Packit Service 97d2fb
.BI "                              int " build_id_len ","
Packit Service 97d2fb
.BI "                              char ** " path ");"
Packit Service 97d2fb
.BI "int debuginfod_find_executable(debuginfod_client *" client ","
Packit Service 97d2fb
.BI "                               const unsigned char *" build_id ","
Packit Service 97d2fb
.BI "                               int " build_id_len ","
Packit Service 97d2fb
.BI "                               char ** " path ");"
Packit Service 97d2fb
.BI "int debuginfod_find_source(debuginfod_client *" client ","
Packit Service 97d2fb
.BI "                           const unsigned char *" build_id ","
Packit Service 97d2fb
.BI "                           int " build_id_len ","
Packit Service 97d2fb
.BI "                           const char *" filename ","
Packit Service 97d2fb
.BI "                           char ** " path ");"
Packit Service 97d2fb
Packit Service 97d2fb
OPTIONAL FUNCTIONS
Packit Service 97d2fb
Packit Service 97d2fb
.BI "typedef int (*debuginfod_progressfn_t)(debuginfod_client *" client ","
Packit Service 97d2fb
.BI "                                       long a, long b);"
Packit Service 97d2fb
.BI "void debuginfod_set_progressfn(debuginfod_client *" client ","
Packit Service 97d2fb
.BI "                               debuginfod_progressfn_t " progressfn ");"
Packit Service 97d2fb
.BI "void debuginfod_set_user_data(debuginfod_client *" client ","
Packit Service 97d2fb
.BI "                              void *" data ");"
Packit Service 97d2fb
.BI "void* debuginfod_get_user_data(debuginfod_client *" client ");"
Packit Service 97d2fb
.BI "const char* debuginfod_get_url(debuginfod_client *" client ");"
Packit Service 97d2fb
.BI "int debuginfod_add_http_header(debuginfod_client *" client ","
Packit Service 97d2fb
.BI "                               const char* " header ");"
Packit Service 97d2fb
Packit Service 97d2fb
.SH DESCRIPTION
Packit Service 97d2fb
Packit Service 97d2fb
.BR debuginfod_begin ()
Packit Service 97d2fb
creates a \fBdebuginfod_client\fP connection handle that should be used
Packit Service 97d2fb
with all other calls.
Packit Service 97d2fb
.BR debuginfod_end ()
Packit Service 97d2fb
should be called on the \fBclient\fP handle to release all state and
Packit Service 97d2fb
storage when done.
Packit Service 97d2fb
Packit Service 97d2fb
.BR debuginfod_find_debuginfo (),
Packit Service 97d2fb
.BR debuginfod_find_executable (),
Packit Service 97d2fb
and
Packit Service 97d2fb
.BR debuginfod_find_source ()
Packit Service 97d2fb
query the debuginfod server URLs contained in
Packit Service 97d2fb
.BR $DEBUGINFOD_URLS
Packit Service 97d2fb
(see below) for the debuginfo, executable or source file with the
Packit Service 97d2fb
given \fIbuild_id\fP. \fIbuild_id\fP should be a pointer to either
Packit Service 97d2fb
a null-terminated, lowercase hex string or a binary blob. If
Packit Service 97d2fb
\fIbuild_id\fP is given as a hex string, \fIbuild_id_len\fP should
Packit Service 97d2fb
be 0. Otherwise \fIbuild_id_len\fP should be the number of bytes in
Packit Service 97d2fb
the binary blob.
Packit Service 97d2fb
Packit Service 97d2fb
.BR debuginfod_find_source ()
Packit Service 97d2fb
also requries a \fIfilename\fP in order to specify a particular
Packit Service 97d2fb
source file. \fIfilename\fP should be an absolute path that includes
Packit Service 97d2fb
the compilation directory of the CU associated with the source file.
Packit Service 97d2fb
Relative path names commonly appear in the DWARF file's source directory,
Packit Service 97d2fb
but these paths are relative to individual compilation unit AT_comp_dir
Packit Service 97d2fb
paths, and yet an executable is made up of multiple CUs. Therefore, to
Packit Service 97d2fb
disambiguate, debuginfod expects source queries to prefix relative path
Packit Service 97d2fb
names with the CU compilation-directory, followed by a mandatory "/".
Packit Service 97d2fb
Packit Service 97d2fb
Note: the caller may or may not elide \fB../\fP or \fB/./\fP or extraneous
Packit Service 97d2fb
\fB///\fP sorts of path components in the directory names.  debuginfod
Packit Service 97d2fb
accepts both forms.  Specifically, debuginfod canonicalizes path names
Packit Service 97d2fb
according to RFC3986 section 5.2.4 (Remove Dot Segments), plus reducing
Packit Service 97d2fb
any \fB//\fP to \fB/\fP in the path.
Packit Service 97d2fb
Packit Service 97d2fb
If \fIpath\fP is not NULL and the query is successful, \fIpath\fP is set
Packit Service 97d2fb
to the path of the file in the cache. The caller must \fBfree\fP() this value.
Packit Service 97d2fb
Packit Service 97d2fb
The URLs in \fB$DEBUGINFOD_URLS\fP may be queried in parallel. As soon
Packit Service 97d2fb
as a debuginfod server begins transferring the target file all of the
Packit Service 97d2fb
connections to the other servers are closed.
Packit Service 97d2fb
Packit Service 97d2fb
A \fBclient\fP handle should be used from only one thread at a time.
Packit Service 97d2fb
Packit Service 97d2fb
.SH "RETURN VALUE"
Packit Service 97d2fb
Packit Service 97d2fb
\fBdebuginfod_begin\fP returns the \fBdebuginfod_client\fP handle to
Packit Service 97d2fb
use with all other calls.  On error \fBNULL\fP will be returned and
Packit Service 97d2fb
\fBerrno\fP will be set.
Packit Service 97d2fb
Packit Service 97d2fb
If a find family function is successful, the resulting file is saved
Packit Service 97d2fb
to the client cache and a file descriptor to that file is returned.
Packit Service 97d2fb
The caller needs to \fBclose\fP() this descriptor.  Otherwise, a
Packit Service 97d2fb
negative error code is returned.
Packit Service 97d2fb
Packit Service 97d2fb
.SH "OPTIONAL FUNCTIONS"
Packit Service 97d2fb
Packit Service 97d2fb
A small number of optional functions are available to tune or query
Packit Service 97d2fb
the operation of the debuginfod client.
Packit Service 97d2fb
Packit Service 97d2fb
.SS "PROGRESS CALLBACK"
Packit Service 97d2fb
Packit Service 97d2fb
As the \fBdebuginfod_find_*\fP() functions may block for seconds or
Packit Service 97d2fb
longer, a progress callback function is called periodically, if
Packit Service 97d2fb
configured with
Packit Service 97d2fb
.BR debuginfod_set_progressfn ().
Packit Service 97d2fb
This function sets a new progress callback function (or NULL) for the
Packit Service 97d2fb
client handle.
Packit Service 97d2fb
Packit Service 97d2fb
The given callback function is called from the context of each thread
Packit Service 97d2fb
that is invoking any of the other lookup functions.  It is given two
Packit Service 97d2fb
numeric parameters that, if thought of as a numerator \fIa\fP and
Packit Service 97d2fb
denominator \fIb\fP, together represent a completion fraction
Packit Service 97d2fb
\fIa/b\fP.  The denominator may be zero initially, until a quantity
Packit Service 97d2fb
such as an exact download size becomes known.
Packit Service 97d2fb
Packit Service 97d2fb
The progress callback function is also the supported way to
Packit Service 97d2fb
\fIinterrupt\fP the download operation.  (The library does \fInot\fP
Packit Service 97d2fb
modify or trigger signals.)  The progress callback must return 0 to
Packit Service 97d2fb
continue the work, or any other value to stop work as soon as
Packit Service 97d2fb
possible.  Consequently, the \fBdebuginfod_find_*\fP() function will
Packit Service 97d2fb
likely return with an error, but might still succeed.
Packit Service 97d2fb
Packit Service 97d2fb
.SS "USER DATA POINTER"
Packit Service 97d2fb
Packit Service 97d2fb
A single \fIvoid *\fP pointer associated with the connection handle
Packit Service 97d2fb
may be set any time via
Packit Service 97d2fb
.BR \%debuginfod_set_user_data () ,
Packit Service 97d2fb
and retrieved via
Packit Service 97d2fb
.BR \%debuginfod_get_user_data () .
Packit Service 97d2fb
The value is undefined if unset.
Packit Service 97d2fb
Packit Service 97d2fb
.SS "URL"
Packit Service 97d2fb
Packit Service 97d2fb
The URL of the current or most recent outgoing download, if known,
Packit Service 97d2fb
may be retrieved via
Packit Service 97d2fb
.BR \%debuginfod_get_url ()
Packit Service 97d2fb
from the progressfn callback, or afterwards.  It may be NULL.
Packit Service 97d2fb
The resulting string is owned by the library, and must not be modified
Packit Service 97d2fb
or freed.  The caller should copy it if it is needed beyond the release
Packit Service 97d2fb
of the client object.
Packit Service 97d2fb
Packit Service 97d2fb
.SS "HTTP HEADER"
Packit Service 97d2fb
Packit Service 97d2fb
Before a lookup function is initiated, a client application may
Packit Service 97d2fb
add HTTP request headers to future downloads.
Packit Service 97d2fb
.BR \%debuginfod_add_http_header ()
Packit Service 97d2fb
may be called with strings of the form
Packit Service 97d2fb
.BR \%"Header:\~value" .
Packit Service 97d2fb
These strings are copied by the library.  A zero return value
Packit Service 97d2fb
indicates success, but out-of-memory conditions may result in
Packit Service 97d2fb
a non-zero \fI-ENOMEM\fP. If the string is in the wrong form
Packit Service 97d2fb
\fI-EINVAL\fP will be returned.
Packit Service 97d2fb
Packit Service 97d2fb
Note that the current debuginfod-client library implementation uses
Packit Service 97d2fb
libcurl, but you shouldn't rely on that fact. Don't use this function
Packit Service 97d2fb
for replacing any standard headers, except for the User-Agent mentioned
Packit Service 97d2fb
below. The only supported usage of this function is for adding an
Packit Service 97d2fb
optional header which might or might not be passed through to the
Packit Service 97d2fb
server for logging purposes only.
Packit Service 97d2fb
Packit Service 97d2fb
By default, the library adds a descriptive \fIUser-Agent:\fP
Packit Service 97d2fb
header to outgoing requests.  If the client application adds
Packit Service 97d2fb
a header with the same name, this default is suppressed.
Packit Service 97d2fb
Packit Service 97d2fb
.SH "CACHE"
Packit Service 97d2fb
If the query is successful, the \fBdebuginfod_find_*\fP() functions save
Packit Service 97d2fb
the target file to a local cache. The location of the cache is controlled
Packit Service 97d2fb
by the \fB$DEBUGINFOD_CACHE_PATH\fP environment variable (see below).
Packit Service 97d2fb
Cleaning of the cache is controlled by the \fIcache_clean_interval_s\fP
Packit Service 97d2fb
and \fImax_unused_age_s\fP files, which are found in the
Packit Service 97d2fb
\fB$DEBUGINFOD_CACHE_PATH\fP directory. \fIcache_clean_interval_s\fP controls
Packit Service 97d2fb
how frequently the cache is traversed for cleaning and \fImax_unused_age_s\fP
Packit Service 97d2fb
controls how long a file can go unused (fstat(2) atime) before it's
Packit Service 97d2fb
removed from the cache during cleaning. These files should contain only an
Packit Service 97d2fb
ASCII decimal integer representing the interval or max unused age in seconds.
Packit Service 97d2fb
The default is one day and one week, respectively.  Values of zero mean "immediately".
Packit Service 97d2fb
Packit Service 97d2fb
.SH "SECURITY"
Packit Service 97d2fb
.BR debuginfod_find_debuginfo (),
Packit Service 97d2fb
.BR debuginfod_find_executable (),
Packit Service 97d2fb
and
Packit Service 97d2fb
.BR debuginfod_find_source ()
Packit Service 97d2fb
\fBdo not\fP include any particular security
Packit Service 97d2fb
features.  They trust that the binaries returned by the debuginfod(s)
Packit Service 97d2fb
are accurate.  Therefore, the list of servers should include only
Packit Service 97d2fb
trustworthy ones.  If accessed across HTTP rather than HTTPS, the
Packit Service 97d2fb
network should be trustworthy.  Passing user authentication information
Packit Service 97d2fb
through the internal \fIlibcurl\fP library is not currently enabled, except
Packit Service 97d2fb
for the basic plaintext \%\fIhttp[s]://userid:password@hostname/\fP style.
Packit Service 97d2fb
(The debuginfod server does not perform authentication, but a front-end
Packit Service 97d2fb
proxy server could.)
Packit Service 97d2fb
Packit Service 97d2fb
.SH "ENVIRONMENT VARIABLES"
Packit Service 97d2fb
Packit Service 97d2fb
.TP 21
Packit Service 97d2fb
.B DEBUGINFOD_URLS
Packit Service 97d2fb
This environment variable contains a list of URL prefixes for trusted
Packit Service 97d2fb
debuginfod instances.  Alternate URL prefixes are separated by space.
Packit Service 97d2fb
Packit Service 97d2fb
.TP 21
Packit Service 97d2fb
.B DEBUGINFOD_TIMEOUT
Packit Service 97d2fb
This environment variable governs the timeout for each debuginfod HTTP
Packit Service 97d2fb
connection.  A server that fails to provide at least 100K of data
Packit Service 97d2fb
within this many seconds is skipped. The default is 90 seconds.  (Zero
Packit Service 97d2fb
or negative means "no timeout".)
Packit Service 97d2fb
Packit Service 97d2fb
.TP 21
Packit Service 97d2fb
.B DEBUGINFOD_PROGRESS
Packit Service 97d2fb
This environment variable governs the default progress function.  If
Packit Service 97d2fb
set, and if a progressfn is not explicitly set, then the library will
Packit Service 97d2fb
configure a default progressfn.  This function will append a simple
Packit Service 97d2fb
progress message periodically to stderr.  The default is no progress
Packit Service 97d2fb
function output.
Packit Service 97d2fb
Packit Service 97d2fb
.TP 21
Packit Service 97d2fb
.B DEBUGINFOD_CACHE_PATH
Packit Service 97d2fb
This environment variable governs the location of the cache where
Packit Service 97d2fb
downloaded files are kept.  It is cleaned periodically as this
Packit Service 97d2fb
program is reexecuted. If XDG_CACHE_HOME is set then
Packit Service 97d2fb
$XDG_CACHE_HOME/debuginfod_client is the default location, otherwise
Packit Service 97d2fb
$HOME/.cache/debuginfod_client is used.
Packit Service 97d2fb
Packit Service 97d2fb
Packit Service 97d2fb
.SH "ERRORS"
Packit Service 97d2fb
The following list is not comprehensive. Error codes may also
Packit Service 97d2fb
originate from calls to various C Library functions.
Packit Service 97d2fb
Packit Service 97d2fb
.TP
Packit Service 97d2fb
.BR EACCESS
Packit Service 97d2fb
Denied access to resource located at the URL.
Packit Service 97d2fb
Packit Service 97d2fb
.TP
Packit Service 97d2fb
.BR ECONNREFUSED
Packit Service 97d2fb
Unable to connect to remote host. Also returned when an HTTPS connection
Packit Service 97d2fb
couldn't be verified (bad certificate).
Packit Service 97d2fb
Packit Service 97d2fb
.TP
Packit Service 97d2fb
.BR ECONNRESET
Packit Service 97d2fb
Unable to either send or recieve network data.
Packit Service 97d2fb
Packit Service 97d2fb
.TP
Packit Service 97d2fb
.BR EHOSTUNREACH
Packit Service 97d2fb
Unable to resolve remote host.
Packit Service 97d2fb
Packit Service 97d2fb
.TP
Packit Service 97d2fb
.BR EINVAL
Packit Service 97d2fb
One or more arguments are incorrectly formatted. \fIbuild_id\fP may
Packit Service 97d2fb
be too long (greater than 256 characters), \fIfilename\fP may not
Packit Service 97d2fb
be an absolute path or a debuginfod URL is malformed.
Packit Service 97d2fb
Packit Service 97d2fb
.TP
Packit Service 97d2fb
.BR EIO
Packit Service 97d2fb
Unable to write data received from server to local file.
Packit Service 97d2fb
Packit Service 97d2fb
.TP
Packit Service 97d2fb
.BR EMLINK
Packit Service 97d2fb
Too many HTTP redirects.
Packit Service 97d2fb
Packit Service 97d2fb
.TP
Packit Service 97d2fb
.BR ENETUNREACH
Packit Service 97d2fb
Unable to initialize network connection.
Packit Service 97d2fb
Packit Service 97d2fb
.TP
Packit Service 97d2fb
.BR ENOENT
Packit Service 97d2fb
Could not find the resource located at URL. Often this error code
Packit Service 97d2fb
indicates that a debuginfod server was successfully contacted but
Packit Service 97d2fb
the server could not find the target file.
Packit Service 97d2fb
Packit Service 97d2fb
.TP
Packit Service 97d2fb
.BR ENOMEM
Packit Service 97d2fb
System is unable to allocate resources.
Packit Service 97d2fb
Packit Service 97d2fb
.TP
Packit Service 97d2fb
.BR ENOSYS
Packit Service 97d2fb
\fB$DEBUGINFOD_URLS\fP is not defined.
Packit Service 97d2fb
Packit Service 97d2fb
.TP
Packit Service 97d2fb
.BR ETIME
Packit Service 97d2fb
Query failed due to timeout. \fB$DEBUGINFOD_TIMEOUT\fP controls
Packit Service 97d2fb
the timeout duration. See debuginfod(8) for more information.
Packit Service 97d2fb
Packit Service 97d2fb
.SH "FILES"
Packit Service 97d2fb
.LP
Packit Service 97d2fb
.PD .1v
Packit Service 97d2fb
.TP 20
Packit Service 97d2fb
.B $HOME/.debuginfod_client_cache
Packit Service 97d2fb
Default cache directory. If XDG_CACHE_HOME is not set then
Packit Service 97d2fb
\fB$HOME/.cache/debuginfod_client\fP is used.
Packit Service 97d2fb
.PD
Packit Service 97d2fb
Packit Service 97d2fb
.SH "SEE ALSO"
Packit Service 97d2fb
.I "debuginfod(8)"