27 #include "filenames.h"
32 const struct bfd_build_id *
35 if (!bfd_check_format (abfd, bfd_object))
38 if (abfd->build_id != NULL)
39 return abfd->build_id;
50 const struct bfd_build_id *found;
56 warning (
_(
"File \"%s\" has no build-id, file skipped"),
57 bfd_get_filename (abfd));
58 else if (found->size != check_len
59 || memcmp (found->data, check, found->size) != 0)
60 warning (
_(
"File \"%s\" has a different build-id, file skipped"),
61 bfd_get_filename (abfd));
73 char *link, *debugdir;
81 + 2 * build_id_len + (
sizeof ".debug" - 1) + 1);
91 size_t debugdir_len = strlen (debugdir);
93 size_t size = build_id_len;
95 char *filename = NULL;
98 memcpy (link, debugdir, debugdir_len);
99 s = &link[debugdir_len];
100 s += sprintf (s,
"/.build-id/");
104 s += sprintf (s,
"%02x", (
unsigned) *data++);
109 s += sprintf (s,
"%02x", (
unsigned) *data++);
110 strcpy (s,
".debug");
113 if (access (link, F_OK) == 0)
114 filename = lrealpath (link);
116 if (filename == NULL)
143 const struct bfd_build_id *build_id;
146 if (build_id != NULL)
153 && filename_cmp (bfd_get_filename (abfd),
156 warning (
_(
"\"%s\": separate debug info file has no debug info"),
157 bfd_get_filename (abfd));
160 else if (abfd != NULL)
162 char *result = xstrdup (bfd_get_filename (abfd));
char * find_separate_debug_file_by_buildid(struct objfile *objfile)
void warning(const char *fmt,...)
struct bfd * gdb_bfd_open(const char *name, const char *target, int fd)
char * debug_file_directory
#define VEC_iterate(T, V, I, P)
int build_id_verify(bfd *abfd, size_t check_len, const bfd_byte *check)
void gdb_bfd_unref(struct bfd *abfd)
struct cleanup * make_cleanup(make_cleanup_ftype *function, void *arg)
struct cleanup * make_cleanup_free_char_ptr_vec(VEC(char_ptr)*char_ptr_vec)
const char * objfile_name(const struct objfile *objfile)
const struct bfd_build_id * build_id_bfd_get(bfd *abfd)
static void check(BOOL ok, const char *file, int line)
bfd * build_id_to_debug_bfd(size_t build_id_len, const bfd_byte *build_id)
void do_cleanups(struct cleanup *old_chain)