1 /* debuginfod utilities for GDB.
2 Copyright (C) 2020-2024 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 #ifndef DEBUGINFOD_SUPPORT_H
20 #define DEBUGINFOD_SUPPORT_H
22 #include "gdbsupport/scoped_fd.h"
24 /* Query debuginfod servers for a source file associated with an
25 executable with BUILD_ID. BUILD_ID can be given as a binary blob or
26 a null-terminated string. If given as a binary blob, BUILD_ID_LEN
27 should be the number of bytes. If given as a null-terminated string,
28 BUILD_ID_LEN should be 0.
30 SRC_PATH should be the source file's absolute path that includes the
31 compilation directory of the CU associated with the source file.
32 For example if a CU's compilation directory is `/my/build` and the
33 source file path is `/my/source/foo.c`, then SRC_PATH should be
34 `/my/build/../source/foo.c`.
36 If the file is successfully retrieved, return a file descriptor and store
37 the file's local path in DESTNAME. If unsuccessful, print an error message
38 and return a negative errno. If GDB is not built with debuginfod, this
39 function returns -ENOSYS. */
42 debuginfod_source_query (const unsigned char *build_id
,
45 gdb::unique_xmalloc_ptr
<char> *destname
);
47 /* Query debuginfod servers for a debug info file with BUILD_ID.
48 BUILD_ID can be given as a binary blob or a null-terminated string.
49 If given as a binary blob, BUILD_ID_LEN should be the number of bytes.
50 If given as a null-terminated string, BUILD_ID_LEN should be 0.
52 FILENAME should be the name or path of the main binary associated with
53 the separate debug info. It is used for printing messages to the user.
55 If the file is successfully retrieved, return a file descriptor and store
56 the file's local path in DESTNAME. If unsuccessful, print an error message
57 and return a negative errno. If GDB is not built with debuginfod, this
58 function returns -ENOSYS. */
61 debuginfod_debuginfo_query (const unsigned char *build_id
,
64 gdb::unique_xmalloc_ptr
<char> *destname
);
66 /* Query debuginfod servers for an executable file with BUILD_ID.
67 BUILD_ID can be given as a binary blob or a null-terminated string.
68 If given as a binary blob, BUILD_ID_LEN should be the number of bytes.
69 If given as a null-terminated string, BUILD_ID_LEN should be 0.
71 FILENAME should be the name or path associated with the executable.
72 It is used for printing messages to the user.
74 If the file is successfully retrieved, return a file descriptor and store
75 the file's local path in DESTNAME. If unsuccessful, print an error message
76 and return a negative errno. If GDB is not built with debuginfod, this
77 function returns -ENOSYS. */
79 extern scoped_fd
debuginfod_exec_query (const unsigned char *build_id
,
82 gdb::unique_xmalloc_ptr
<char>
85 /* Query debuginfod servers for the binary contents of a ELF/DWARF section
86 from a file matching BUILD_ID. BUILD_ID can be given as a binary blob
87 or a null-terminated string. If given as a binary blob, BUILD_ID_LEN
88 should be the number of bytes. If given as a null-terminated string,
89 BUILD_ID_LEN should be 0.
91 FILENAME should be the name or path associated with the file matching
92 BUILD_ID. It is used for printing messages to the user.
94 SECTION_NAME should be the name of an ELF/DWARF section.
96 If the file is successfully retrieved, return a file descriptor and store
97 the file's local path in DESTNAME. If unsuccessful, print an error message
98 and return a negative errno. If GDB is not built with debuginfod or
99 libdebuginfod does not support section queries, this function returns
102 extern scoped_fd
debuginfod_section_query (const unsigned char *build_id
,
104 const char *filename
,
105 const char *section_name
,
106 gdb::unique_xmalloc_ptr
<char>
108 #endif /* DEBUGINFOD_SUPPORT_H */