24#include "gdbsupport/gdb_vecs.h"
33const struct bfd_build_id *
42 if (!bfd_check_format (abfd, bfd_object)
43 && !bfd_check_format (abfd, bfd_core))
46 if (abfd->build_id != NULL)
47 return abfd->build_id;
58 const struct bfd_build_id *found;
64 warning (_(
"File \"%s\" has no build-id, file skipped"),
65 bfd_get_filename (abfd));
66 else if (found->size != check_len
67 || memcmp (found->data,
check, found->size) != 0)
68 warning (_(
"File \"%s\" has a different build-id, file skipped"),
69 bfd_get_filename (abfd));
82 const bfd_byte *build_id)
91 gdb::unique_xmalloc_ptr<char> filename_holder;
92 const char *filename =
nullptr;
94 filename = link.c_str ();
95 else if (access (link.c_str (), F_OK) == 0)
97 filename_holder.reset (lrealpath (link.c_str ()));
98 filename = filename_holder.get ();
101 if (filename == NULL)
105 _(
" no, unable to compute real path\n"));
113 if (debug_bfd == NULL)
146 std::vector<gdb::unique_xmalloc_ptr<char>> debugdir_vec
149 for (
const gdb::unique_xmalloc_ptr<char> &debugdir : debugdir_vec)
151 const gdb_byte *data = build_id;
152 size_t size = build_id_len;
158 std::string link = debugdir.get ();
159 link +=
"/.build-id/";
164 string_appendf (link,
"%02x/", (
unsigned) *data++);
168 string_appendf (link,
"%02x", (
unsigned) *data++);
174 if (debug_bfd != NULL)
185 if (debug_bfd != NULL)
215 const struct bfd_build_id *build_id;
218 if (build_id != NULL)
222 _(
"\nLooking for separate debug info (build-id) for "
229 && filename_cmp (bfd_get_filename (abfd.get ()),
234 "debug info", bfd_get_filename (abfd.get ()));
235 warnings->
warn (_(
"\"%ps\": separate debug info file has no "
238 bfd_get_filename (abfd.get ())));
240 else if (abfd != NULL)
241 return std::string (bfd_get_filename (abfd.get ()));
244 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)
std::string find_separate_debug_file_by_buildid(struct objfile *objfile, deferred_warnings *warnings)
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)
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)
ui_file_style style() const
cli_style_option file_name_style
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)
void warn(const char *format,...) ATTRIBUTE_PRINTF(2
bool separate_debug_file_debug
static styled_string_s * styled_string(const ui_file_style &style, const char *str, styled_string_s &&tmp={})
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)