summaryrefslogtreecommitdiff
path: root/libdwfl/debuginfod-client.c
diff options
context:
space:
mode:
authorMilian Wolff <mail@milianw.de>2022-07-07 19:33:35 +0200
committerAaron Merey <amerey@redhat.com>2022-07-13 14:15:28 -0400
commita4b1839c3c46d461765de894dc4b4b0c5580fc1b (patch)
treeb85695333cfe0e23a5e153bef1691d163ddb9be9 /libdwfl/debuginfod-client.c
parent994c40e485211981ab93b2f6ae399075d8c8a0f3 (diff)
downloadelfutils-a4b1839c3c46d461765de894dc4b4b0c5580fc1b.tar.gz
Introduce public dwfl_get_debuginfod_client API
Dwfl can use debuginfod internally, which was so far totally opaque to the outside. While the functionality is great for users of the dwfl API, the long wait times induced by downloading of data over debuginfod lead to complaints by endusers. To offer them a bit more insight into the internal ongoings, one can now use e.g. `debuginfod_set_progressfn` on the handle returned by `dwfl_get_debuginfod_client` to report download progress. Rename get_client to dwfl_get_debuginfod_client and make it public. Unconditionally compile debuginfod-client.c and stub the new public function and always return NULL when debuginfod integration was disabled. Signed-off-by: Milian Wolff <mail@milianw.de>
Diffstat (limited to 'libdwfl/debuginfod-client.c')
-rw-r--r--libdwfl/debuginfod-client.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/libdwfl/debuginfod-client.c b/libdwfl/debuginfod-client.c
index 153260c3..813043b1 100644
--- a/libdwfl/debuginfod-client.c
+++ b/libdwfl/debuginfod-client.c
@@ -32,6 +32,9 @@
#endif
#include "libdwflP.h"
+
+#ifdef ENABLE_LIBDEBUGINFOD
+
#include <pthread.h>
#include <dlfcn.h>
@@ -46,8 +49,8 @@ static pthread_once_t init_control = PTHREAD_ONCE_INIT;
/* NB: this is slightly thread-unsafe */
-static debuginfod_client *
-get_client (Dwfl *dwfl)
+debuginfod_client *
+dwfl_get_debuginfod_client (Dwfl *dwfl)
{
if (dwfl->debuginfod != NULL)
return dwfl->debuginfod;
@@ -71,7 +74,7 @@ __libdwfl_debuginfod_find_executable (Dwfl *dwfl,
int fd = -1;
if (build_id_len > 0)
{
- debuginfod_client *c = get_client (dwfl);
+ debuginfod_client *c = dwfl_get_debuginfod_client (dwfl);
if (c != NULL)
fd = (*fp_debuginfod_find_executable) (c, build_id_bits,
build_id_len, NULL);
@@ -88,7 +91,7 @@ __libdwfl_debuginfod_find_debuginfo (Dwfl *dwfl,
int fd = -1;
if (build_id_len > 0)
{
- debuginfod_client *c = get_client (dwfl);
+ debuginfod_client *c = dwfl_get_debuginfod_client (dwfl);
if (c != NULL)
fd = (*fp_debuginfod_find_debuginfo) (c, build_id_bits,
build_id_len, NULL);
@@ -105,7 +108,7 @@ __libdwfl_debuginfod_end (debuginfod_client *c)
}
/* Try to get the libdebuginfod library functions.
- Only needs to be called once from get_client. */
+ Only needs to be called once from dwfl_get_debuginfod_client. */
static void
__libdwfl_debuginfod_init (void)
{
@@ -134,3 +137,13 @@ __libdwfl_debuginfod_init (void)
}
}
}
+
+#else // ENABLE_LIBDEBUGINFOD
+
+debuginfod_client *
+dwfl_get_debuginfod_client (Dwfl *)
+{
+ return NULL;
+}
+
+#endif // ENABLE_LIBDEBUGINFOD