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;
82 + (
sizeof "/.build-id/" - 1) + 1
83 + 2 * build_id_len + (
sizeof ".debug" - 1) + 1);
84 link = (
char *) alloca (alloc_len);
94 size_t debugdir_len = strlen (debugdir);
96 size_t size = build_id_len;
98 char *filename = NULL;
101 memcpy (link, debugdir, debugdir_len);
102 s = &link[debugdir_len];
103 s += sprintf (s,
"/.build-id/");
107 s += sprintf (s,
"%02x", (
unsigned) *data++);
112 s += sprintf (s,
"%02x", (
unsigned) *data++);
113 strcpy (s,
".debug");
119 if (access (link, F_OK) == 0)
120 filename = lrealpath (link);
122 if (filename == NULL)
148 const struct bfd_build_id *build_id;
151 if (build_id != NULL)
161 && filename_cmp (bfd_get_filename (abfd.
get ()),
163 warning (
_(
"\"%s\": separate debug info file has no debug info"),
164 bfd_get_filename (abfd.
get ()));
165 else if (abfd != NULL)
166 return xstrdup (bfd_get_filename (abfd.
get ()));
char * find_separate_debug_file_by_buildid(struct objfile *objfile)
void warning(const char *fmt,...)
char * debug_file_directory
#define VEC_iterate(T, V, I, P)
gdb_bfd_ref_ptr gdb_bfd_open(const char *name, const char *target, int fd)
int build_id_verify(bfd *abfd, size_t check_len, const bfd_byte *check)
struct cleanup * make_cleanup(make_cleanup_ftype *function, void *arg)
void printf_unfiltered(const char *format,...)
const char * objfile_name(const struct objfile *objfile)
int separate_debug_file_debug
const struct bfd_build_id * build_id_bfd_get(bfd *abfd)
static void check(BOOL ok, const char *file, int line)
gdb_bfd_ref_ptr build_id_to_debug_bfd(size_t build_id_len, const bfd_byte *build_id)
struct cleanup * make_cleanup_free_char_ptr_vec(VEC(char_ptr) *char_ptr_vec)
void do_cleanups(struct cleanup *old_chain)