24#include "gdbsupport/gdb_vecs.h"
32const struct bfd_build_id *
35 if (!bfd_check_format (abfd, bfd_object)
36 && !bfd_check_format (abfd, bfd_core))
39 if (abfd->build_id != NULL)
40 return abfd->build_id;
51 const struct bfd_build_id *found;
57 warning (_(
"File \"%s\" has no build-id, file skipped"),
58 bfd_get_filename (abfd));
59 else if (found->size != check_len
60 || memcmp (found->data,
check, found->size) != 0)
61 warning (_(
"File \"%s\" has a different build-id, file skipped"),
62 bfd_get_filename (abfd));
75 const bfd_byte *build_id)
84 gdb::unique_xmalloc_ptr<char> filename_holder;
85 const char *filename =
nullptr;
87 filename = link.c_str ();
88 else if (access (link.c_str (), F_OK) == 0)
90 filename_holder.reset (lrealpath (link.c_str ()));
91 filename = filename_holder.get ();
98 _(
" no, unable to compute real path\n"));
106 if (debug_bfd == NULL)
139 std::vector<gdb::unique_xmalloc_ptr<char>> debugdir_vec
142 for (
const gdb::unique_xmalloc_ptr<char> &debugdir : debugdir_vec)
144 const gdb_byte *data = build_id;
145 size_t size = build_id_len;
151 std::string link = debugdir.get ();
152 link +=
"/.build-id/";
157 string_appendf (link,
"%02x/", (
unsigned) *data++);
161 string_appendf (link,
"%02x", (
unsigned) *data++);
167 if (debug_bfd != NULL)
178 if (debug_bfd != NULL)
207 const struct bfd_build_id *build_id;
210 if (build_id != NULL)
214 _(
"\nLooking for separate debug info (build-id) for "
221 && filename_cmp (bfd_get_filename (abfd.get ()),
223 warning (_(
"\"%s\": separate debug info file has no debug info"),
224 bfd_get_filename (abfd.get ()));
225 else if (abfd != NULL)
226 return std::string (bfd_get_filename (abfd.get ()));
229 return std::string ();
static gdb_bfd_ref_ptr build_id_to_debug_bfd_1(const std::string &link, size_t build_id_len, const bfd_byte *build_id)
int build_id_verify(bfd *abfd, size_t check_len, const bfd_byte *check)
gdb_bfd_ref_ptr build_id_to_exec_bfd(size_t build_id_len, const bfd_byte *build_id)
static gdb_bfd_ref_ptr build_id_to_bfd_suffix(size_t build_id_len, const bfd_byte *build_id, const char *suffix)
std::string find_separate_debug_file_by_buildid(struct objfile *objfile)
gdb_bfd_ref_ptr build_id_to_debug_bfd(size_t build_id_len, const bfd_byte *build_id)
const struct bfd_build_id * build_id_bfd_get(bfd *abfd)
std::string debug_file_directory
gdb_bfd_ref_ptr gdb_bfd_open(const char *name, const char *target, int fd, bool warn_if_slow)
#define TARGET_SYSROOT_PREFIX
gdb::ref_ptr< struct bfd, gdb_bfd_ref_policy > gdb_bfd_ref_ptr
const char * objfile_name(const struct objfile *objfile)
bool separate_debug_file_debug
void gdb_printf(struct ui_file *stream, const char *format,...)
void gdb_flush(struct ui_file *stream)
static void check(BOOL ok, const char *file, int line)