From 288f6b199a8b1a60d4fb1f54ca7b883cdd5afca2 Mon Sep 17 00:00:00 2001 From: Aaron Merey Date: Mon, 28 Oct 2019 13:29:26 -0400 Subject: debuginfod 1/2: client side Introduce the debuginfod/ subdirectory, containing the client for a new debuginfo-over-http service, in shared-library and command-line forms. Two functions in libdwfl make calls into the client library to fetch elf/dwarf files by buildid, as a fallback. Instead of normal dynamic linking (thus pulling in a variety of curl dependencies), the libdwfl hooks use dlopen/dlsym. Server & tests coming in patch 2. Signed-off-by: Aaron Merey Signed-off-by: Frank Ch. Eigler --- debuginfod/debuginfod.h | 69 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 debuginfod/debuginfod.h (limited to 'debuginfod/debuginfod.h') diff --git a/debuginfod/debuginfod.h b/debuginfod/debuginfod.h new file mode 100644 index 00000000..d2bb0c94 --- /dev/null +++ b/debuginfod/debuginfod.h @@ -0,0 +1,69 @@ +/* External declarations for the libdebuginfod client library. + Copyright (C) 2019 Red Hat, Inc. + This file is part of elfutils. + + This file is free software; you can redistribute it and/or modify + it under the terms of either + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at + your option) any later version + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at + your option) any later version + + or both in parallel, as here. + + elfutils is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see . */ + +#ifndef _DEBUGINFOD_CLIENT_H +#define _DEBUGINFOD_CLIENT_H 1 + +/* Names of environment variables that control the client logic. */ +#define DEBUGINFOD_URLS_ENV_VAR "DEBUGINFOD_URLS" +#define DEBUGINFOD_CACHE_PATH_ENV_VAR "DEBUGINFOD_CACHE_PATH" +#define DEBUGINFOD_TIMEOUT_ENV_VAR "DEBUGINFOD_TIMEOUT" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Query the urls contained in $DEBUGINFOD_URLS for a file with + the specified type and build id. If build_id_len == 0, the + build_id is supplied as a lowercase hexadecimal string; otherwise + it is a binary blob of given legnth. + + If successful, return a file descriptor to the target, otherwise + return a posix error code. If successful, set *path to a + strdup'd copy of the name of the same file in the cache. + Caller must free() it later. */ + +int debuginfod_find_debuginfo (const unsigned char *build_id, + int build_id_len, + char **path); + +int debuginfod_find_executable (const unsigned char *build_id, + int build_id_len, + char **path); + +int debuginfod_find_source (const unsigned char *build_id, + int build_id_len, + const char *filename, + char **path); + +#ifdef __cplusplus +} +#endif + + +#endif /* _DEBUGINFOD_CLIENT_H */ -- cgit v1.2.3 From 3d7a08d5d37c3e96151d1be6e6e6eb0556c079c9 Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Mon, 4 Nov 2019 16:33:09 -0500 Subject: debuginfod 3/3: client interruptability For interactive clients such as gdb, interruptibility is important for usability during longer downloads. This patchset adds a download-progress callback function to the debuginfod client library, with which a caller app can interrupt a download as well as be notified of its quantitative progress. --- debuginfod/debuginfod.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'debuginfod/debuginfod.h') diff --git a/debuginfod/debuginfod.h b/debuginfod/debuginfod.h index d2bb0c94..0620f02a 100644 --- a/debuginfod/debuginfod.h +++ b/debuginfod/debuginfod.h @@ -49,17 +49,20 @@ extern "C" { Caller must free() it later. */ int debuginfod_find_debuginfo (const unsigned char *build_id, - int build_id_len, - char **path); - -int debuginfod_find_executable (const unsigned char *build_id, int build_id_len, char **path); +int debuginfod_find_executable (const unsigned char *build_id, + int build_id_len, + char **path); + int debuginfod_find_source (const unsigned char *build_id, - int build_id_len, - const char *filename, - char **path); + int build_id_len, + const char *filename, + char **path); + +typedef int (*debuginfod_progressfn_t)(long a, long b); +debuginfod_progressfn_t debuginfod_set_progressfn(debuginfod_progressfn_t fn); #ifdef __cplusplus } -- cgit v1.2.3 From fa0226a78a101d26fd80c7e9e70a5f0aa6f9d1cc Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Sun, 17 Nov 2019 22:17:26 +0100 Subject: debuginfod: add client context Add a mandatory debuginfod_begin()/_end() call pair to manage a client object that represents persistent but non-global state. From libdwfl, dlopen the debuginfod.so client library early on. This hopefully makes sure that the code (and the libcurl.so dependency) is loaded before the program goes into multi-threaded mode. Signed-off-by: Mark Wielaard --- debuginfod/debuginfod.h | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'debuginfod/debuginfod.h') diff --git a/debuginfod/debuginfod.h b/debuginfod/debuginfod.h index 0620f02a..6b1b1cc3 100644 --- a/debuginfod/debuginfod.h +++ b/debuginfod/debuginfod.h @@ -34,10 +34,16 @@ #define DEBUGINFOD_CACHE_PATH_ENV_VAR "DEBUGINFOD_CACHE_PATH" #define DEBUGINFOD_TIMEOUT_ENV_VAR "DEBUGINFOD_TIMEOUT" +/* Handle for debuginfod-client connection. */ +typedef struct debuginfod_client debuginfod_client; + #ifdef __cplusplus extern "C" { #endif +/* Create a handle for a new debuginfod-client session. */ +debuginfod_client *debuginfod_begin (void); + /* Query the urls contained in $DEBUGINFOD_URLS for a file with the specified type and build id. If build_id_len == 0, the build_id is supplied as a lowercase hexadecimal string; otherwise @@ -48,21 +54,28 @@ extern "C" { strdup'd copy of the name of the same file in the cache. Caller must free() it later. */ -int debuginfod_find_debuginfo (const unsigned char *build_id, +int debuginfod_find_debuginfo (debuginfod_client *client, + const unsigned char *build_id, int build_id_len, char **path); -int debuginfod_find_executable (const unsigned char *build_id, +int debuginfod_find_executable (debuginfod_client *client, + const unsigned char *build_id, int build_id_len, char **path); -int debuginfod_find_source (const unsigned char *build_id, +int debuginfod_find_source (debuginfod_client *client, + const unsigned char *build_id, int build_id_len, const char *filename, char **path); -typedef int (*debuginfod_progressfn_t)(long a, long b); -debuginfod_progressfn_t debuginfod_set_progressfn(debuginfod_progressfn_t fn); +typedef int (*debuginfod_progressfn_t)(debuginfod_client *c, long a, long b); +void debuginfod_set_progressfn(debuginfod_client *c, + debuginfod_progressfn_t fn); + +/* Release debuginfod client connection context handle. */ +void debuginfod_end (debuginfod_client *client); #ifdef __cplusplus } -- cgit v1.2.3