build-id.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* build-id-related functions.
  2. Copyright (C) 1991-2022 Free Software Foundation, Inc.
  3. This file is part of GDB.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  14. #ifndef BUILD_ID_H
  15. #define BUILD_ID_H
  16. #include "gdb_bfd.h"
  17. #include "gdbsupport/rsp-low.h"
  18. /* Locate NT_GNU_BUILD_ID from ABFD and return its content. */
  19. extern const struct bfd_build_id *build_id_bfd_get (bfd *abfd);
  20. /* Return true if ABFD has NT_GNU_BUILD_ID matching the CHECK value.
  21. Otherwise, issue a warning and return false. */
  22. extern int build_id_verify (bfd *abfd,
  23. size_t check_len, const bfd_byte *check);
  24. /* Find and open a BFD for a debuginfo file given a build-id. If no BFD
  25. can be found, return NULL. */
  26. extern gdb_bfd_ref_ptr build_id_to_debug_bfd (size_t build_id_len,
  27. const bfd_byte *build_id);
  28. /* Find and open a BFD for an executable file given a build-id. If no BFD
  29. can be found, return NULL. The returned reference to the BFD must be
  30. released by the caller. */
  31. extern gdb_bfd_ref_ptr build_id_to_exec_bfd (size_t build_id_len,
  32. const bfd_byte *build_id);
  33. /* Find the separate debug file for OBJFILE, by using the build-id
  34. associated with OBJFILE's BFD. If successful, returns the file name for the
  35. separate debug file, otherwise, return an empty string. */
  36. extern std::string find_separate_debug_file_by_buildid
  37. (struct objfile *objfile);
  38. /* Return an hex-string representation of BUILD_ID. */
  39. static inline std::string
  40. build_id_to_string (const bfd_build_id *build_id)
  41. {
  42. gdb_assert (build_id != NULL);
  43. return bin2hex (build_id->data, build_id->size);
  44. }
  45. #endif /* BUILD_ID_H */