forked from elfutils/elfutils-mirror
Add split DWARF (DWO/DWP) support to debuginfod #3
Loading…
Reference in a new issue
No description provided.
Delete branch "pablogsal/elfutils:dwp-main"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This PR enables debuginfod to serve split DWARF files, solving a long-standing pain point for developers debugging binaries compiled with -gsplit-dwarf. When GCC uses this flag, the bulk of debug information gets stored in separate .dwo files or combined .dwp packages rather than in the executable itself. These files are referenced by a 64-bit DWO ID embedded in the skeleton compilation unit. Until now, if the .dwo files weren't present on the local filesystem: a common situation when debugging binaries from package repositories: debuggers simply couldn't access the full debug information.
Build systems using -gsplit-dwarf produce .dwo files and .dwp packages that contain the bulk of debug information, referenced by 64-bit DWO IDs from skeleton compilation units. These files could not be served by debuginfod because the server only indexed content by build-id, and DWO/DWP files typically lack build-ids entirely since they are not linked into the final executable. This extends the database schema to buildids11, adding tables to track DWO content: _dwoids for interning 64-bit IDs as 16-char hex strings, _f_dwo for file-based DWO content, and _r_dwo for archive-based content. The schema mirrors the existing _f_de/_r_de pattern for consistency. During scanning, dwarf_extract_dwo_ids() identifies files containing DW_UT_split_compile or DW_UT_split_type units and extracts their IDs, distinguishing .dwp packages by the presence of .debug_cu_index. The elf_classify() function was modified to process files without build-ids since this is normal for DWO content. A new /dwoid/{id}/debuginfo endpoint queries the _query_dwo view and returns matching files, using the same handle_buildid_match() infrastructure for cache-friendly responses. Federation is not yet supported for dwoid queries as it would require extending the client protocol. * debuginfod/debuginfod.cxx (BUILDIDS): Bump to buildids11 for schema change. (DEBUGINFOD_SQLITE_DDL): Add _dwoids table for DWO ID interning, _f_dwo and _r_dwo tables for file and archive DWO content with is_dwp flag, _query_dwo view for unified queries, update _stats view with DWO counts. Add DROP statements for buildids10 tables. (handle_dwoid): New function to handle /dwoid/{id}/debuginfo endpoint, validates 16-char hex ID and queries _query_dwo view. (handler_cb): Add /dwoid URL routing with same blocking logic as /buildid endpoint. (dwarf_extract_dwo_ids): New function to extract DWO IDs from split DWARF files, detecting DWP files via .debug_cu_index. (elf_classify): Add dwo_ids and is_dwp output parameters, call dwarf_extract_dwo_ids, handle files without build-ids. (scan_source_file): Pass dwo_ids to elf_classify, insert into _dwoids and _f_dwo/_r_dwo tables. Signed-off-by: Pablo Galindo Salgado <pablogsal@gmail.com>Applications like GDB and libdwfl need to fetch split DWARF files from debuginfod servers, but the existing client API only supports queries by build-id. DWO files are identified by their 64-bit DWO ID from the skeleton compilation unit, not by build-id, so a different query mechanism is required. This adds debuginfod_find_dwo() which queries servers at the /dwoid/{id}/debuginfo endpoint. The function accepts DWO IDs either as a hex string (when dwo_id_len is 0) or as binary bytes in little-endian order matching how libdw stores them internally. Binary input is reversed to produce the canonical big-endian hex representation that the server expects. A convenience wrapper debuginfod_find_dwo_by_id() takes the 64-bit ID directly for simpler integration. The cache uses a dwoid/ subdirectory parallel to the existing buildid/ structure. The debuginfod-find command gains a "dwoid" subcommand for manual testing and shell script integration. Both functions are exported in the ELFUTILS_0.193 symbol version. * debuginfod/debuginfod.h.in: Include stdint.h for uint64_t. (debuginfod_find_dwo): Declare new function taking DWO ID as hex string or binary bytes. (debuginfod_find_dwo_by_id): Declare convenience wrapper taking uint64_t DWO ID directly. * debuginfod/debuginfod-client.c (debuginfod_find_dwo): New function implementing DWO lookup via /dwoid endpoint, handles hex string and binary input, caches in dwoid/ subdirectory. (debuginfod_find_dwo_by_id): New wrapper converting uint64_t to little-endian bytes and calling debuginfod_find_dwo. * debuginfod/debuginfod-find.c (args_doc): Add dwoid usage. (main): Handle "dwoid" subcommand calling debuginfod_find_dwo. * debuginfod/libdebuginfod.map (ELFUTILS_0.193): Add debuginfod_find_dwo and debuginfod_find_dwo_by_id symbols. Signed-off-by: Pablo Galindo Salgado <pablogsal@gmail.com>Tested locally:
b92d4fa3e0to13389c9db9Specific run for the new tests:
13389c9db9to06c3c303f306c3c303f3to2e3940534dI tested also a patched gdb with a server from this PR:
Could you hit the "Update branch by rebase" button (it is under the Update branch by merge button)? The forgejo/workflow files weren't in place yet, so no Actions were triggered. I would like to see how/if that works after a rebase. It might not work, I am new to forgejo. But it would be fun to see if it does.
294c299608toea8dce12fbI clicked the button and saw a message saying:
Then I saw:
Hohum, that didn't work :{
Let me try closing and reopening...
Sorry for "playing" with this instead of properly reviewing it.
Cool that worked! There is now " Some checks are pending".
I had to explicitly Approve the checks. But I guess that is fair. Just means you need some kind of sponsor to run Actions on merge requests from forks.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.