binutils-gdb/gdb/debuginfod-support.h

63 lines
2.5 KiB
C
Raw Normal View History

Add debuginfod support to GDB debuginfod is a lightweight web service that indexes ELF/DWARF debugging resources by build-id and serves them over HTTP. This patch enables GDB to query debuginfod servers for separate debug files and source code when it is otherwise not able to find them. GDB can be built with debuginfod using the --with-debuginfod configure option. This requires that libdebuginfod be installed and found at configure time. debuginfod is packaged with elfutils, starting with version 0.178. For more information see https://sourceware.org/elfutils/. Tested on x86_64 Fedora 31. gdb/ChangeLog: 2020-02-26 Aaron Merey <amerey@redhat.com> * Makefile.in: Handle optional debuginfod support. * NEWS: Update. * README: Add --with-debuginfod summary. * config.in: Regenerate. * configure: Regenerate. * configure.ac: Handle optional debuginfod support. * debuginfod-support.c: debuginfod helper functions. * debuginfod-support.h: Ditto. * doc/gdb.texinfo: Add --with-debuginfod to configure options summary. * dwarf2/read.c (dwarf2_get_dwz_file): Query debuginfod servers when a dwz file cannot be found. * elfread.c (elf_symfile_read): Query debuginfod servers when a debuginfo file cannot be found. * source.c (open_source_file): Query debuginfod servers when a source file cannot be found. * top.c (print_gdb_configuration): Include --{with,without}-debuginfod in the output. gdb/testsuite/ChangeLog: 2020-02-26 Aaron Merey <amerey@redhat.com> * gdb.debuginfod: New directory for debuginfod tests. * gdb.debuginfod/main.c: New test file. * gdb.debuginfod/fetch_src_and_symbols.exp: New tests.
2020-02-27 06:40:49 +08:00
/* debuginfod utilities for GDB.
Copyright (C) 2020-2021 Free Software Foundation, Inc.
Add debuginfod support to GDB debuginfod is a lightweight web service that indexes ELF/DWARF debugging resources by build-id and serves them over HTTP. This patch enables GDB to query debuginfod servers for separate debug files and source code when it is otherwise not able to find them. GDB can be built with debuginfod using the --with-debuginfod configure option. This requires that libdebuginfod be installed and found at configure time. debuginfod is packaged with elfutils, starting with version 0.178. For more information see https://sourceware.org/elfutils/. Tested on x86_64 Fedora 31. gdb/ChangeLog: 2020-02-26 Aaron Merey <amerey@redhat.com> * Makefile.in: Handle optional debuginfod support. * NEWS: Update. * README: Add --with-debuginfod summary. * config.in: Regenerate. * configure: Regenerate. * configure.ac: Handle optional debuginfod support. * debuginfod-support.c: debuginfod helper functions. * debuginfod-support.h: Ditto. * doc/gdb.texinfo: Add --with-debuginfod to configure options summary. * dwarf2/read.c (dwarf2_get_dwz_file): Query debuginfod servers when a dwz file cannot be found. * elfread.c (elf_symfile_read): Query debuginfod servers when a debuginfo file cannot be found. * source.c (open_source_file): Query debuginfod servers when a source file cannot be found. * top.c (print_gdb_configuration): Include --{with,without}-debuginfod in the output. gdb/testsuite/ChangeLog: 2020-02-26 Aaron Merey <amerey@redhat.com> * gdb.debuginfod: New directory for debuginfod tests. * gdb.debuginfod/main.c: New test file. * gdb.debuginfod/fetch_src_and_symbols.exp: New tests.
2020-02-27 06:40:49 +08:00
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program 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 a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef DEBUGINFOD_SUPPORT_H
#define DEBUGINFOD_SUPPORT_H
/* Query debuginfod servers for a source file associated with an
executable with BUILD_ID. BUILD_ID can be given as a binary blob or
a null-terminated string. If given as a binary blob, BUILD_ID_LEN
should be the number of bytes. If given as a null-terminated string,
BUILD_ID_LEN should be 0.
SRC_PATH should be the source file's absolute path that includes the
compilation directory of the CU associated with the source file.
For example if a CU's compilation directory is `/my/build` and the
source file path is `/my/source/foo.c`, then SRC_PATH should be
`/my/build/../source/foo.c`.
If the file is successfully retrieved, its path on the local machine
is stored in DESTNAME. If GDB is not built with debuginfod, this
function returns -ENOSYS. */
extern scoped_fd
debuginfod_source_query (const unsigned char *build_id,
int build_id_len,
const char *src_path,
gdb::unique_xmalloc_ptr<char> *destname);
/* Query debuginfod servers for a debug info file with BUILD_ID.
BUILD_ID can be given as a binary blob or a null-terminated string.
If given as a binary blob, BUILD_ID_LEN should be the number of bytes.
If given as a null-terminated string, BUILD_ID_LEN should be 0.
FILENAME should be the name or path of the main binary associated with
the separate debug info. It is used for printing messages to the user.
If the file is successfully retrieved, its path on the local machine
is stored in DESTNAME. If GDB is not built with debuginfod, this
function returns -ENOSYS. */
extern scoped_fd
debuginfod_debuginfo_query (const unsigned char *build_id,
int build_id_len,
const char *filename,
gdb::unique_xmalloc_ptr<char> *destname);
#endif /* DEBUGINFOD_SUPPORT_H */