Bug 29472 - Support querying the debuginfod-server for metadata
Summary: Support querying the debuginfod-server for metadata
Status: NEW
Alias: None
Product: elfutils
Classification: Unclassified
Component: debuginfod (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2022-08-11 14:43 UTC by Ryan Goldberg
Modified: 2023-02-28 22:21 UTC (History)
3 users (show)

See Also:
Last reconfirmed:

Submit A Patch for 29472 (15.88 KB, patch)
2022-08-22 18:24 UTC, Ryan Goldberg
Details | Diff
Submit A Patch for 29472, bug fix (565 bytes, patch)
2022-08-31 14:52 UTC, Ryan Goldberg
Details | Diff
Submit A Patch for 29472, revised (15.77 KB, patch)
2022-09-02 17:25 UTC, Ryan Goldberg
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ryan Goldberg 2022-08-11 14:43:48 UTC
It would be beneficial to be able to query a debuginfod-server for its metadata matching certain conditions. This would allow for operations like seeing what executable files are available without attempting to download them or seeing which files are larger than a certain size, which could be used to prefetch+cache large required files, before the user needs them.

The proposed format is as follows:
debuginfod-find [OPTION]... metadata CONDITION QUERYFMT

Query all of the metadata matching the given CONDITION and return it as described by QUERYFMT

The supported debuginfod-fields are:
and should be referenced using {...}, noting that field names are case insensitive.

CONDITION is a boolean expression composed of debuginfod-fields, constants (strings and integers)
and the: `( ) = != < > <= >= && ||` operators, following the standard conditional precedence order

QUERYFMT is a modified version of the standard printf(3) formatting.
The format is made up of static strings (which may include standard C character escapes for new‐
lines, tabs, and other special characters (not including \0)) and printf(3) type formatters. In 
place of the type specifier in the format string, use the debuginfod-field you wish to query.

For example:

debuginfod-find metadata "{FILENAME}=/usr/bin/grep && {TYPE}=E" "{FILENAME}({BUILDID})\t{SOURCE_TYPE}\n"
Will query all executables with the name /usr/bin/grep and might return the following

/usr/bin/grep(90e7d8894b94f47ad17722ff8658f833f329b035)    R
/usr/bin/grep(e81e4e6e322030178260ae4f6055f781cd4997e1)    F

debuginfod-find metadata "{FILENAME}=/bin/bash" "{FILENAME}-{TYPE}\n"
Might return
Comment 1 Martin Liska 2022-08-12 09:05:02 UTC
I think it's very similar to PR 28284.
Comment 2 Ryan Goldberg 2022-08-22 18:24:57 UTC
Created attachment 14289 [details]
Submit A Patch for 29472

Here is patch which is simpler than the above proposal. It allows for querying by source path and will return a JSON array of metadata (where the metadata for each file is its own JSON object).

The patch was tested using the elfutils try-buildbots on branch users/rgoldber/try-metadata_query

There is a need for this patch as currently, even with work like PR 28284, a user is unable to check what files are accessible with debuginfod, they can only at most try and query by buildid and see if they can get a result. This feature will be used in systemtap PR 27410
Comment 3 Ryan Goldberg 2022-08-31 14:52:10 UTC
Created attachment 14306 [details]
Submit A Patch for 29472, bug fix

Minor bug fix to be applied to the previous patch
Comment 4 Ryan Goldberg 2022-09-02 17:25:49 UTC
Created attachment 14310 [details]
Submit A Patch for 29472, revised

I've revised the previous patch to include the suggestions from elfutils-devel [debuginfod metadata patch review]