xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/debuginfod-support.h (revision 6881a4007f077b54e5f51159c52b9b25f57deb0d)
17d62b00eSchristos /* debuginfod utilities for GDB.
2*6881a400Schristos    Copyright (C) 2020-2023 Free Software Foundation, Inc.
37d62b00eSchristos 
47d62b00eSchristos    This file is part of GDB.
57d62b00eSchristos 
67d62b00eSchristos    This program is free software; you can redistribute it and/or modify
77d62b00eSchristos    it under the terms of the GNU General Public License as published by
87d62b00eSchristos    the Free Software Foundation; either version 3 of the License, or
97d62b00eSchristos    (at your option) any later version.
107d62b00eSchristos 
117d62b00eSchristos    This program is distributed in the hope that it will be useful,
127d62b00eSchristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
137d62b00eSchristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
147d62b00eSchristos    GNU General Public License for more details.
157d62b00eSchristos 
167d62b00eSchristos    You should have received a copy of the GNU General Public License
177d62b00eSchristos    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
187d62b00eSchristos 
197d62b00eSchristos #ifndef DEBUGINFOD_SUPPORT_H
207d62b00eSchristos #define DEBUGINFOD_SUPPORT_H
217d62b00eSchristos 
22*6881a400Schristos #include "gdbsupport/scoped_fd.h"
23*6881a400Schristos 
247d62b00eSchristos /* Query debuginfod servers for a source file associated with an
257d62b00eSchristos    executable with BUILD_ID.  BUILD_ID can be given as a binary blob or
267d62b00eSchristos    a null-terminated string.  If given as a binary blob, BUILD_ID_LEN
277d62b00eSchristos    should be the number of bytes.  If given as a null-terminated string,
287d62b00eSchristos    BUILD_ID_LEN should be 0.
297d62b00eSchristos 
307d62b00eSchristos    SRC_PATH should be the source file's absolute path that includes the
317d62b00eSchristos    compilation directory of the CU associated with the source file.
327d62b00eSchristos    For example if a CU's compilation directory is `/my/build` and the
337d62b00eSchristos    source file path is `/my/source/foo.c`, then SRC_PATH should be
347d62b00eSchristos    `/my/build/../source/foo.c`.
357d62b00eSchristos 
367d62b00eSchristos    If the file is successfully retrieved, its path on the local machine
377d62b00eSchristos    is stored in DESTNAME.  If GDB is not built with debuginfod, this
387d62b00eSchristos    function returns -ENOSYS.  */
397d62b00eSchristos 
407d62b00eSchristos extern scoped_fd
417d62b00eSchristos debuginfod_source_query (const unsigned char *build_id,
427d62b00eSchristos 			 int build_id_len,
437d62b00eSchristos 			 const char *src_path,
447d62b00eSchristos 			 gdb::unique_xmalloc_ptr<char> *destname);
457d62b00eSchristos 
467d62b00eSchristos /* Query debuginfod servers for a debug info file with BUILD_ID.
477d62b00eSchristos    BUILD_ID can be given as a binary blob or a null-terminated string.
487d62b00eSchristos    If given as a binary blob, BUILD_ID_LEN should be the number of bytes.
497d62b00eSchristos    If given as a null-terminated string, BUILD_ID_LEN should be 0.
507d62b00eSchristos 
517d62b00eSchristos    FILENAME should be the name or path of the main binary associated with
527d62b00eSchristos    the separate debug info.  It is used for printing messages to the user.
537d62b00eSchristos 
547d62b00eSchristos    If the file is successfully retrieved, its path on the local machine
557d62b00eSchristos    is stored in DESTNAME.  If GDB is not built with debuginfod, this
567d62b00eSchristos    function returns -ENOSYS.  */
577d62b00eSchristos 
587d62b00eSchristos extern scoped_fd
597d62b00eSchristos debuginfod_debuginfo_query (const unsigned char *build_id,
607d62b00eSchristos 			    int build_id_len,
617d62b00eSchristos 			    const char *filename,
627d62b00eSchristos 			    gdb::unique_xmalloc_ptr<char> *destname);
637d62b00eSchristos 
64*6881a400Schristos /* Query debuginfod servers for an executable file with BUILD_ID.
65*6881a400Schristos    BUILD_ID can be given as a binary blob or a null-terminated string.
66*6881a400Schristos    If given as a binary blob, BUILD_ID_LEN should be the number of bytes.
67*6881a400Schristos    If given as a null-terminated string, BUILD_ID_LEN should be 0.
68*6881a400Schristos 
69*6881a400Schristos    FILENAME should be the name or path associated with the executable.
70*6881a400Schristos    It is used for printing messages to the user.
71*6881a400Schristos 
72*6881a400Schristos    If the file is successfully retrieved, its path on the local machine
73*6881a400Schristos    is stored in DESTNAME.  If GDB is not built with debuginfod, this
74*6881a400Schristos    function returns -ENOSYS.  */
75*6881a400Schristos 
76*6881a400Schristos extern scoped_fd debuginfod_exec_query (const unsigned char *build_id,
77*6881a400Schristos 					int build_id_len,
78*6881a400Schristos 					const char *filename,
79*6881a400Schristos 					gdb::unique_xmalloc_ptr<char>
80*6881a400Schristos 					  *destname);
817d62b00eSchristos #endif /* DEBUGINFOD_SUPPORT_H */
82