diff options
| author | Frank Ch. Eigler <fche@redhat.com> | 2020-03-19 20:27:11 -0400 |
|---|---|---|
| committer | Frank Ch. Eigler <fche@redhat.com> | 2020-03-22 16:46:14 -0400 |
| commit | b40e25568333a80b3f1f3cb7dd2e2a2caf880dcb (patch) | |
| tree | 4224c9db7f4a0aa7932e2b7b5727a44e8ca30104 /debuginfod | |
| parent | 2092865a7e589ff805caa47e69ac9630f34d4f2a (diff) | |
| download | platform_external_elfutils-b40e25568333a80b3f1f3cb7dd2e2a2caf880dcb.tar.gz platform_external_elfutils-b40e25568333a80b3f1f3cb7dd2e2a2caf880dcb.tar.bz2 platform_external_elfutils-b40e25568333a80b3f1f3cb7dd2e2a2caf880dcb.zip | |
debuginfod client API: add get/set user_data functions
Add a pair of functions to associate a void* parameter with a client
object. Requested by GDB team as a way to pass file names and such
user-interface data through to a progressfn callback.
Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
Diffstat (limited to 'debuginfod')
| -rw-r--r-- | debuginfod/ChangeLog | 6 | ||||
| -rw-r--r-- | debuginfod/debuginfod-client.c | 16 | ||||
| -rw-r--r-- | debuginfod/debuginfod-find.c | 7 | ||||
| -rw-r--r-- | debuginfod/debuginfod.h | 10 | ||||
| -rw-r--r-- | debuginfod/libdebuginfod.map | 5 |
5 files changed, 40 insertions, 4 deletions
diff --git a/debuginfod/ChangeLog b/debuginfod/ChangeLog index ab32b523..a26f6b27 100644 --- a/debuginfod/ChangeLog +++ b/debuginfod/ChangeLog @@ -1,3 +1,9 @@ +2020-03-22 Frank Ch. Eigler <fche@redhat.com> + + * debuginfod.h, libdebuginfod.map: New functions for _get/set_user(). + * debuginfod-client.c: Implement them. + * debuginfod-find.c: Include a token call just for testing them. + 2020-03-03 Aaron Merey <amerey@redhat.com> * debuginfod-client.c (debuginfod_query_server): Update diff --git a/debuginfod/debuginfod-client.c b/debuginfod/debuginfod-client.c index 8923099f..2730dbf7 100644 --- a/debuginfod/debuginfod-client.c +++ b/debuginfod/debuginfod-client.c @@ -79,6 +79,9 @@ struct debuginfod_client /* Progress/interrupt callback function. */ debuginfod_progressfn_t progressfn; + /* Stores user data. */ + void* user_data; + /* Can contain all other context, like cache_path, server_urls, timeout or other info gotten from environment variables, the handle data, etc. So those don't have to be reparsed and @@ -903,6 +906,19 @@ debuginfod_begin (void) } void +debuginfod_set_user_data(debuginfod_client *client, + void *data) +{ + client->user_data = data; +} + +void * +debuginfod_get_user_data(debuginfod_client *client) +{ + return client->user_data; +} + +void debuginfod_end (debuginfod_client *client) { free (client); diff --git a/debuginfod/debuginfod-find.c b/debuginfod/debuginfod-find.c index 8bd3a3db..0b1ca9cf 100644 --- a/debuginfod/debuginfod-find.c +++ b/debuginfod/debuginfod-find.c @@ -91,6 +91,9 @@ main(int argc, char** argv) return 1; } + /* Exercise user data pointer, to support testing only. */ + debuginfod_set_user_data (client, (void *)"Progress"); + int remaining; (void) argp_parse (&argp, argc, argv, ARGP_IN_ORDER|ARGP_NO_ARGS, &remaining, NULL); @@ -130,6 +133,8 @@ main(int argc, char** argv) return 1; } + debuginfod_end (client); + if (rc < 0) { fprintf(stderr, "Server query failed: %s\n", strerror(-rc)); @@ -137,9 +142,7 @@ main(int argc, char** argv) } printf("%s\n", cache_name); - free (cache_name); - debuginfod_end (client); return 0; } diff --git a/debuginfod/debuginfod.h b/debuginfod/debuginfod.h index b4b6a3d2..fe72f16e 100644 --- a/debuginfod/debuginfod.h +++ b/debuginfod/debuginfod.h @@ -1,5 +1,5 @@ /* External declarations for the libdebuginfod client library. - Copyright (C) 2019 Red Hat, Inc. + Copyright (C) 2019-2020 Red Hat, Inc. This file is part of elfutils. This file is free software; you can redistribute it and/or modify @@ -54,7 +54,7 @@ debuginfod_client *debuginfod_begin (void); 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 (debuginfod_client *client, const unsigned char *build_id, int build_id_len, @@ -75,6 +75,12 @@ typedef int (*debuginfod_progressfn_t)(debuginfod_client *c, long a, long b); void debuginfod_set_progressfn(debuginfod_client *c, debuginfod_progressfn_t fn); +/* Set the user parameter. */ +void debuginfod_set_user_data (debuginfod_client *client, void *value); + +/* Get the user parameter. */ +void* debuginfod_get_user_data (debuginfod_client *client); + /* Release debuginfod client connection context handle. */ void debuginfod_end (debuginfod_client *client); diff --git a/debuginfod/libdebuginfod.map b/debuginfod/libdebuginfod.map index 0d26f93e..a919630d 100644 --- a/debuginfod/libdebuginfod.map +++ b/debuginfod/libdebuginfod.map @@ -8,3 +8,8 @@ ELFUTILS_0.178 { debuginfod_find_source; debuginfod_set_progressfn; } ELFUTILS_0; +ELFUTILS_0.179 { + global: + debuginfod_set_user_data; + debuginfod_get_user_data; +}; |
