]>
Commit | Line | Data |
---|---|---|
7566401a | 1 | Index: gdb-6.8.91.20090925/gdb/corelow.c |
3a58abaf | 2 | =================================================================== |
7566401a ER |
3 | --- gdb-6.8.91.20090925.orig/gdb/corelow.c 2009-07-31 17:25:21.000000000 +0200 |
4 | +++ gdb-6.8.91.20090925/gdb/corelow.c 2009-09-25 09:39:09.000000000 +0200 | |
3a58abaf AM |
5 | @@ -45,6 +45,10 @@ |
6 | #include "exceptions.h" | |
7 | #include "solib.h" | |
8 | #include "filenames.h" | |
9 | +#include "auxv.h" | |
10 | +#include "elf/common.h" | |
11 | +#include "objfiles.h" | |
12 | +#include "gdbcmd.h" | |
13 | ||
14 | ||
15 | #ifndef O_LARGEFILE | |
7566401a | 16 | @@ -273,6 +277,52 @@ add_to_thread_list (bfd *abfd, asection |
3a58abaf AM |
17 | inferior_ptid = ptid; /* Yes, make it current */ |
18 | } | |
19 | ||
20 | +static int build_id_core_loads = 1; | |
21 | + | |
22 | +static void | |
23 | +build_id_locate_exec (int from_tty) | |
24 | +{ | |
25 | + CORE_ADDR at_entry; | |
26 | + struct build_id *build_id; | |
27 | + char *exec_filename, *debug_filename; | |
28 | + char *build_id_filename; | |
7566401a | 29 | + struct cleanup *back_to; |
3a58abaf | 30 | + |
7566401a | 31 | + if (exec_bfd != NULL || symfile_objfile != NULL) |
3a58abaf AM |
32 | + return; |
33 | + | |
34 | + if (target_auxv_search (¤t_target, AT_ENTRY, &at_entry) <= 0) | |
35 | + return; | |
36 | + | |
37 | + build_id = build_id_addr_get (at_entry); | |
38 | + if (build_id == NULL) | |
39 | + return; | |
40 | + | |
7566401a ER |
41 | + /* SYMFILE_OBJFILE should refer to the main executable (not only to its |
42 | + separate debug info file). gcc44+ keeps .eh_frame only in the main | |
43 | + executable without its duplicate .debug_frame in the separate debug info | |
44 | + file - such .eh_frame would not be found if SYMFILE_OBJFILE would refer | |
45 | + directly to the separate debug info file. */ | |
46 | + | |
3a58abaf | 47 | + exec_filename = build_id_to_filename (build_id, &build_id_filename, 0); |
7566401a | 48 | + back_to = make_cleanup (xfree, build_id_filename); |
3a58abaf | 49 | + |
7566401a | 50 | + if (exec_filename != NULL) |
3a58abaf | 51 | + { |
7566401a ER |
52 | + make_cleanup (xfree, exec_filename); |
53 | + exec_file_attach (exec_filename, from_tty); | |
54 | + symbol_file_add_main (exec_filename, from_tty); | |
55 | + if (symfile_objfile != NULL) | |
56 | + symfile_objfile->flags |= OBJF_BUILD_ID_CORE_LOADED; | |
3a58abaf AM |
57 | + } |
58 | + else | |
7566401a | 59 | + debug_print_missing (_("the main executable file"), build_id_filename); |
3a58abaf | 60 | + |
7566401a | 61 | + do_cleanups (back_to); |
3a58abaf AM |
62 | + |
63 | + /* No automatic SOLIB_ADD as the libraries would get read twice. */ | |
64 | +} | |
65 | + | |
66 | /* This routine opens and sets up the core file bfd. */ | |
67 | ||
68 | static void | |
7566401a | 69 | @@ -371,6 +421,12 @@ core_open (char *filename, int from_tty) |
3a58abaf AM |
70 | push_target (&core_ops); |
71 | discard_cleanups (old_chain); | |
72 | ||
73 | + /* Find the build_id identifiers. If it gets executed after | |
74 | + POST_CREATE_INFERIOR we would clash with asking to discard the already | |
75 | + loaded VDSO symbols. */ | |
76 | + if (build_id_core_loads != 0) | |
77 | + build_id_locate_exec (from_tty); | |
78 | + | |
79 | add_inferior_silent (corelow_pid); | |
80 | ||
81 | /* Do this before acknowledging the inferior, so if | |
7566401a | 82 | @@ -878,4 +934,11 @@ _initialize_corelow (void) |
3a58abaf AM |
83 | init_core_ops (); |
84 | ||
85 | add_target (&core_ops); | |
86 | + | |
87 | + add_setshow_boolean_cmd ("build-id-core-loads", class_files, | |
88 | + &build_id_core_loads, _("\ | |
89 | +Set whether CORE-FILE loads the build-id associated files automatically."), _("\ | |
90 | +Show whether CORE-FILE loads the build-id associated files automatically.."), | |
91 | + NULL, NULL, NULL, | |
92 | + &setlist, &showlist); | |
93 | } | |
7566401a | 94 | Index: gdb-6.8.91.20090925/gdb/doc/gdb.texinfo |
3a58abaf | 95 | =================================================================== |
7566401a ER |
96 | --- gdb-6.8.91.20090925.orig/gdb/doc/gdb.texinfo 2009-09-25 09:29:58.000000000 +0200 |
97 | +++ gdb-6.8.91.20090925/gdb/doc/gdb.texinfo 2009-09-25 09:29:58.000000000 +0200 | |
98 | @@ -13895,6 +13895,27 @@ information files. | |
3a58abaf AM |
99 | |
100 | @end table | |
101 | ||
102 | +You can also adjust the current verbosity of the @dfn{build id} locating. | |
103 | + | |
104 | +@table @code | |
105 | + | |
106 | +@kindex set build-id-verbose | |
107 | +@item set build-id-verbose 0 | |
108 | +No additional messages are printed. | |
109 | + | |
110 | +@item set build-id-verbose 1 | |
111 | +Missing separate debug filenames are printed. | |
112 | + | |
113 | +@item set build-id-verbose 2 | |
114 | +Missing separate debug filenames are printed and also all the parsing of the | |
115 | +binaries to find their @dfn{build id} content is printed. | |
116 | + | |
117 | +@kindex show build-id-verbose | |
118 | +@item show build-id-verbose | |
119 | +Show the current verbosity value for the @dfn{build id} content locating. | |
120 | + | |
121 | +@end table | |
122 | + | |
123 | @cindex @code{.gnu_debuglink} sections | |
124 | @cindex debug link sections | |
125 | A debug link is a special section of the executable file named | |
7566401a | 126 | Index: gdb-6.8.91.20090925/gdb/solib-svr4.c |
3a58abaf | 127 | =================================================================== |
7566401a ER |
128 | --- gdb-6.8.91.20090925.orig/gdb/solib-svr4.c 2009-09-25 09:29:57.000000000 +0200 |
129 | +++ gdb-6.8.91.20090925/gdb/solib-svr4.c 2009-09-25 09:43:14.000000000 +0200 | |
130 | @@ -1101,9 +1101,49 @@ svr4_current_sos (void) | |
3a58abaf AM |
131 | safe_strerror (errcode)); |
132 | else | |
133 | { | |
134 | - strncpy (new->so_name, buffer, SO_NAME_MAX_PATH_SIZE - 1); | |
135 | - new->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0'; | |
136 | - strcpy (new->so_original_name, new->so_name); | |
137 | + struct build_id *build_id; | |
138 | + | |
139 | + strncpy (new->so_original_name, buffer, SO_NAME_MAX_PATH_SIZE - 1); | |
140 | + new->so_original_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0'; | |
141 | + /* May get overwritten below. */ | |
142 | + strcpy (new->so_name, new->so_original_name); | |
143 | + | |
144 | + build_id = build_id_addr_get (LM_DYNAMIC_FROM_LINK_MAP (new)); | |
145 | + if (build_id != NULL) | |
146 | + { | |
147 | + char *name, *build_id_filename; | |
148 | + | |
149 | + /* Missing the build-id matching separate debug info file | |
150 | + would be handled while SO_NAME gets loaded. */ | |
151 | + name = build_id_to_filename (build_id, &build_id_filename, 0); | |
152 | + if (name != NULL) | |
153 | + { | |
154 | + strncpy (new->so_name, name, SO_NAME_MAX_PATH_SIZE - 1); | |
155 | + new->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0'; | |
156 | + xfree (name); | |
157 | + } | |
158 | + else | |
7566401a ER |
159 | + { |
160 | + debug_print_missing (new->so_name, build_id_filename); | |
161 | + | |
162 | + /* In the case the main executable was found according to | |
163 | + its build-id (from a core file) prevent loading | |
164 | + a different build of a library with accidentally the | |
165 | + same SO_NAME. | |
166 | + | |
167 | + It suppresses bogus backtraces (and prints "??" there | |
168 | + instead) if the on-disk files no longer match the | |
169 | + running program version. */ | |
170 | + | |
171 | + if (symfile_objfile != NULL | |
172 | + && (symfile_objfile->flags | |
173 | + & OBJF_BUILD_ID_CORE_LOADED) != 0) | |
174 | + new->so_name[0] = 0; | |
175 | + } | |
3a58abaf AM |
176 | + |
177 | + xfree (build_id_filename); | |
178 | + xfree (build_id); | |
179 | + } | |
180 | } | |
181 | xfree (buffer); | |
182 | ||
7566401a | 183 | Index: gdb-6.8.91.20090925/gdb/symfile.c |
3a58abaf | 184 | =================================================================== |
7566401a ER |
185 | --- gdb-6.8.91.20090925.orig/gdb/symfile.c 2009-09-25 09:29:57.000000000 +0200 |
186 | +++ gdb-6.8.91.20090925/gdb/symfile.c 2009-09-25 09:29:58.000000000 +0200 | |
187 | @@ -56,6 +56,7 @@ | |
3a58abaf AM |
188 | #include "elf-bfd.h" |
189 | #include "solib.h" | |
190 | #include "remote.h" | |
191 | +#include "libbfd.h" | |
192 | ||
193 | #include <sys/types.h> | |
194 | #include <fcntl.h> | |
7566401a ER |
195 | @@ -1173,16 +1174,65 @@ symbol_file_clear (int from_tty) |
196 | printf_unfiltered (_("No symbol file now.\n")); | |
3a58abaf AM |
197 | } |
198 | ||
199 | +/* Locate NT_GNU_BUILD_ID and return its matching debug filename. | |
200 | + FIXME: NOTE decoding should be unified with the BFD core notes decoding. */ | |
201 | + | |
202 | +#define BUILD_ID_VERBOSE_NONE 0 | |
203 | +#define BUILD_ID_VERBOSE_FILENAMES 1 | |
204 | +#define BUILD_ID_VERBOSE_BINARY_PARSE 2 | |
205 | +static int build_id_verbose = BUILD_ID_VERBOSE_FILENAMES; | |
206 | +static void | |
207 | +show_build_id_verbose (struct ui_file *file, int from_tty, | |
208 | + struct cmd_list_element *c, const char *value) | |
209 | +{ | |
210 | + fprintf_filtered (file, _("Verbosity level of the build-id locator is %s.\n"), | |
211 | + value); | |
212 | +} | |
213 | + | |
214 | struct build_id | |
215 | { | |
216 | size_t size; | |
217 | gdb_byte data[1]; | |
218 | }; | |
219 | ||
220 | -/* Locate NT_GNU_BUILD_ID from ABFD and return its content. */ | |
221 | +struct build_id * | |
222 | +build_id_buf_get (bfd *templ, gdb_byte *buf, bfd_size_type size) | |
223 | +{ | |
224 | + bfd_byte *p; | |
225 | + | |
226 | + p = buf; | |
227 | + while (p < buf + size) | |
228 | + { | |
229 | + /* FIXME: bad alignment assumption. */ | |
230 | + Elf_External_Note *xnp = (Elf_External_Note *) p; | |
231 | + size_t namesz = H_GET_32 (templ, xnp->namesz); | |
232 | + size_t descsz = H_GET_32 (templ, xnp->descsz); | |
233 | + bfd_byte *descdata = xnp->name + BFD_ALIGN (namesz, 4); | |
234 | + | |
235 | + if (H_GET_32 (templ, xnp->type) == NT_GNU_BUILD_ID | |
236 | + && namesz == sizeof "GNU" | |
237 | + && memcmp (xnp->name, "GNU", sizeof "GNU") == 0) | |
238 | + { | |
239 | + size_t size = descsz; | |
240 | + gdb_byte *data = (void *) descdata; | |
241 | + struct build_id *retval; | |
242 | + | |
243 | + retval = xmalloc (sizeof *retval - 1 + size); | |
244 | + retval->size = size; | |
245 | + memcpy (retval->data, data, size); | |
246 | + | |
247 | + return retval; | |
248 | + } | |
249 | + p = descdata + BFD_ALIGN (descsz, 4); | |
250 | + } | |
251 | + return NULL; | |
252 | +} | |
253 | + | |
254 | +/* Separate debuginfo files have corrupted PHDR but SHDR is correct there. | |
255 | + Locate NT_GNU_BUILD_ID from ABFD and return its content. */ | |
256 | ||
257 | static struct build_id * | |
258 | -build_id_bfd_get (bfd *abfd) | |
259 | +build_id_bfd_shdr_get (bfd *abfd) | |
260 | { | |
261 | struct build_id *retval; | |
262 | ||
7566401a | 263 | @@ -1198,6 +1248,348 @@ build_id_bfd_get (bfd *abfd) |
3a58abaf AM |
264 | return retval; |
265 | } | |
266 | ||
267 | +/* Core files may have missing (corrupt) SHDR but PDHR is correct there. | |
268 | + bfd_elf_bfd_from_remote_memory () has too much overhead by | |
269 | + allocating/reading all the available ELF PT_LOADs. */ | |
270 | + | |
271 | +static struct build_id * | |
272 | +build_id_phdr_get (bfd *templ, bfd_vma loadbase, unsigned e_phnum, | |
273 | + Elf_Internal_Phdr *i_phdr) | |
274 | +{ | |
275 | + int i; | |
276 | + struct build_id *retval = NULL; | |
277 | + | |
278 | + for (i = 0; i < e_phnum; i++) | |
279 | + if (i_phdr[i].p_type == PT_NOTE && i_phdr[i].p_filesz > 0) | |
280 | + { | |
281 | + Elf_Internal_Phdr *hdr = &i_phdr[i]; | |
282 | + gdb_byte *buf; | |
283 | + int err; | |
284 | + | |
285 | + buf = xmalloc (hdr->p_filesz); | |
286 | + err = target_read_memory (loadbase + i_phdr[i].p_vaddr, buf, | |
287 | + hdr->p_filesz); | |
288 | + if (err == 0) | |
289 | + retval = build_id_buf_get (templ, buf, hdr->p_filesz); | |
290 | + else | |
291 | + retval = NULL; | |
292 | + xfree (buf); | |
293 | + if (retval != NULL) | |
294 | + break; | |
295 | + } | |
296 | + return retval; | |
297 | +} | |
298 | + | |
299 | +/* First we validate the file by reading in the ELF header and checking | |
300 | + the magic number. */ | |
301 | + | |
302 | +static inline bfd_boolean | |
303 | +elf_file_p (Elf64_External_Ehdr *x_ehdrp64) | |
304 | +{ | |
305 | + gdb_assert (sizeof (Elf64_External_Ehdr) >= sizeof (Elf32_External_Ehdr)); | |
306 | + gdb_assert (offsetof (Elf64_External_Ehdr, e_ident) | |
307 | + == offsetof (Elf32_External_Ehdr, e_ident)); | |
308 | + gdb_assert (sizeof (((Elf64_External_Ehdr *) 0)->e_ident) | |
309 | + == sizeof (((Elf32_External_Ehdr *) 0)->e_ident)); | |
310 | + | |
311 | + return ((x_ehdrp64->e_ident[EI_MAG0] == ELFMAG0) | |
312 | + && (x_ehdrp64->e_ident[EI_MAG1] == ELFMAG1) | |
313 | + && (x_ehdrp64->e_ident[EI_MAG2] == ELFMAG2) | |
314 | + && (x_ehdrp64->e_ident[EI_MAG3] == ELFMAG3)); | |
315 | +} | |
316 | + | |
317 | +/* Translate an ELF file header in external format into an ELF file header in | |
318 | + internal format. */ | |
319 | + | |
320 | +#define H_GET_WORD(bfd, ptr) (is64 ? H_GET_64 (bfd, (ptr)) \ | |
321 | + : H_GET_32 (bfd, (ptr))) | |
322 | +#define H_GET_SIGNED_WORD(bfd, ptr) (is64 ? H_GET_S64 (bfd, (ptr)) \ | |
323 | + : H_GET_S32 (bfd, (ptr))) | |
324 | + | |
325 | +static void | |
326 | +elf_swap_ehdr_in (bfd *abfd, | |
327 | + const Elf64_External_Ehdr *src64, | |
328 | + Elf_Internal_Ehdr *dst) | |
329 | +{ | |
330 | + int is64 = bfd_get_arch_size (abfd) == 64; | |
331 | +#define SRC(field) (is64 ? src64->field \ | |
332 | + : ((const Elf32_External_Ehdr *) src64)->field) | |
333 | + | |
334 | + int signed_vma = get_elf_backend_data (abfd)->sign_extend_vma; | |
335 | + memcpy (dst->e_ident, SRC (e_ident), EI_NIDENT); | |
336 | + dst->e_type = H_GET_16 (abfd, SRC (e_type)); | |
337 | + dst->e_machine = H_GET_16 (abfd, SRC (e_machine)); | |
338 | + dst->e_version = H_GET_32 (abfd, SRC (e_version)); | |
339 | + if (signed_vma) | |
340 | + dst->e_entry = H_GET_SIGNED_WORD (abfd, SRC (e_entry)); | |
341 | + else | |
342 | + dst->e_entry = H_GET_WORD (abfd, SRC (e_entry)); | |
343 | + dst->e_phoff = H_GET_WORD (abfd, SRC (e_phoff)); | |
344 | + dst->e_shoff = H_GET_WORD (abfd, SRC (e_shoff)); | |
345 | + dst->e_flags = H_GET_32 (abfd, SRC (e_flags)); | |
346 | + dst->e_ehsize = H_GET_16 (abfd, SRC (e_ehsize)); | |
347 | + dst->e_phentsize = H_GET_16 (abfd, SRC (e_phentsize)); | |
348 | + dst->e_phnum = H_GET_16 (abfd, SRC (e_phnum)); | |
349 | + dst->e_shentsize = H_GET_16 (abfd, SRC (e_shentsize)); | |
350 | + dst->e_shnum = H_GET_16 (abfd, SRC (e_shnum)); | |
351 | + dst->e_shstrndx = H_GET_16 (abfd, SRC (e_shstrndx)); | |
352 | + | |
353 | +#undef SRC | |
354 | +} | |
355 | + | |
356 | +/* Translate an ELF program header table entry in external format into an | |
357 | + ELF program header table entry in internal format. */ | |
358 | + | |
359 | +void | |
360 | +elf_swap_phdr_in (bfd *abfd, | |
361 | + const Elf64_External_Phdr *src64, | |
362 | + Elf_Internal_Phdr *dst) | |
363 | +{ | |
364 | + int is64 = bfd_get_arch_size (abfd) == 64; | |
365 | +#define SRC(field) (is64 ? src64->field \ | |
366 | + : ((const Elf32_External_Phdr *) src64)->field) | |
367 | + | |
368 | + int signed_vma = get_elf_backend_data (abfd)->sign_extend_vma; | |
369 | + | |
370 | + dst->p_type = H_GET_32 (abfd, SRC (p_type)); | |
371 | + dst->p_flags = H_GET_32 (abfd, SRC (p_flags)); | |
372 | + dst->p_offset = H_GET_WORD (abfd, SRC (p_offset)); | |
373 | + if (signed_vma) | |
374 | + { | |
375 | + dst->p_vaddr = H_GET_SIGNED_WORD (abfd, SRC (p_vaddr)); | |
376 | + dst->p_paddr = H_GET_SIGNED_WORD (abfd, SRC (p_paddr)); | |
377 | + } | |
378 | + else | |
379 | + { | |
380 | + dst->p_vaddr = H_GET_WORD (abfd, SRC (p_vaddr)); | |
381 | + dst->p_paddr = H_GET_WORD (abfd, SRC (p_paddr)); | |
382 | + } | |
383 | + dst->p_filesz = H_GET_WORD (abfd, SRC (p_filesz)); | |
384 | + dst->p_memsz = H_GET_WORD (abfd, SRC (p_memsz)); | |
385 | + dst->p_align = H_GET_WORD (abfd, SRC (p_align)); | |
386 | + | |
387 | +#undef SRC | |
388 | +} | |
389 | + | |
390 | +#undef H_GET_SIGNED_WORD | |
391 | +#undef H_GET_WORD | |
392 | + | |
393 | +static Elf_Internal_Phdr * | |
394 | +elf_get_phdr (bfd *templ, bfd_vma ehdr_vma, unsigned *e_phnum_pointer, | |
395 | + bfd_vma *loadbase_pointer) | |
396 | +{ | |
397 | + /* sizeof (Elf64_External_Ehdr) >= sizeof (Elf32_External_Ehdr) */ | |
398 | + Elf64_External_Ehdr x_ehdr64; /* Elf file header, external form */ | |
399 | + Elf_Internal_Ehdr i_ehdr; /* Elf file header, internal form */ | |
400 | + bfd_size_type x_phdrs_size; | |
401 | + gdb_byte *x_phdrs_ptr; | |
402 | + Elf_Internal_Phdr *i_phdrs; | |
403 | + int err; | |
404 | + unsigned int i; | |
405 | + bfd_vma loadbase; | |
406 | + int loadbase_set; | |
407 | + | |
408 | + gdb_assert (templ != NULL); | |
409 | + gdb_assert (sizeof (Elf64_External_Ehdr) >= sizeof (Elf32_External_Ehdr)); | |
410 | + | |
411 | + /* Read in the ELF header in external format. */ | |
412 | + err = target_read_memory (ehdr_vma, (bfd_byte *) &x_ehdr64, sizeof x_ehdr64); | |
413 | + if (err) | |
414 | + { | |
415 | + if (build_id_verbose >= BUILD_ID_VERBOSE_BINARY_PARSE) | |
416 | + warning (_("build-id: Error reading ELF header at address 0x%lx"), | |
417 | + (unsigned long) ehdr_vma); | |
418 | + return NULL; | |
419 | + } | |
420 | + | |
421 | + /* Now check to see if we have a valid ELF file, and one that BFD can | |
422 | + make use of. The magic number must match, the address size ('class') | |
423 | + and byte-swapping must match our XVEC entry. */ | |
424 | + | |
425 | + if (! elf_file_p (&x_ehdr64) | |
426 | + || x_ehdr64.e_ident[EI_VERSION] != EV_CURRENT | |
427 | + || !((bfd_get_arch_size (templ) == 64 | |
428 | + && x_ehdr64.e_ident[EI_CLASS] == ELFCLASS64) | |
429 | + || (bfd_get_arch_size (templ) == 32 | |
430 | + && x_ehdr64.e_ident[EI_CLASS] == ELFCLASS32))) | |
431 | + { | |
432 | + if (build_id_verbose >= BUILD_ID_VERBOSE_BINARY_PARSE) | |
433 | + warning (_("build-id: Unrecognized ELF header at address 0x%lx"), | |
434 | + (unsigned long) ehdr_vma); | |
435 | + return NULL; | |
436 | + } | |
437 | + | |
438 | + /* Check that file's byte order matches xvec's */ | |
439 | + switch (x_ehdr64.e_ident[EI_DATA]) | |
440 | + { | |
441 | + case ELFDATA2MSB: /* Big-endian */ | |
442 | + if (! bfd_header_big_endian (templ)) | |
443 | + { | |
444 | + if (build_id_verbose >= BUILD_ID_VERBOSE_BINARY_PARSE) | |
445 | + warning (_("build-id: Unrecognized " | |
446 | + "big-endian ELF header at address 0x%lx"), | |
447 | + (unsigned long) ehdr_vma); | |
448 | + return NULL; | |
449 | + } | |
450 | + break; | |
451 | + case ELFDATA2LSB: /* Little-endian */ | |
452 | + if (! bfd_header_little_endian (templ)) | |
453 | + { | |
454 | + if (build_id_verbose >= BUILD_ID_VERBOSE_BINARY_PARSE) | |
455 | + warning (_("build-id: Unrecognized " | |
456 | + "little-endian ELF header at address 0x%lx"), | |
457 | + (unsigned long) ehdr_vma); | |
458 | + return NULL; | |
459 | + } | |
460 | + break; | |
461 | + case ELFDATANONE: /* No data encoding specified */ | |
462 | + default: /* Unknown data encoding specified */ | |
463 | + if (build_id_verbose >= BUILD_ID_VERBOSE_BINARY_PARSE) | |
464 | + warning (_("build-id: Unrecognized " | |
465 | + "ELF header endianity at address 0x%lx"), | |
466 | + (unsigned long) ehdr_vma); | |
467 | + return NULL; | |
468 | + } | |
469 | + | |
470 | + elf_swap_ehdr_in (templ, &x_ehdr64, &i_ehdr); | |
471 | + | |
472 | + /* The file header tells where to find the program headers. | |
473 | + These are what we use to actually choose what to read. */ | |
474 | + | |
475 | + if (i_ehdr.e_phentsize != (bfd_get_arch_size (templ) == 64 | |
476 | + ? sizeof (Elf64_External_Phdr) | |
477 | + : sizeof (Elf32_External_Phdr)) | |
478 | + || i_ehdr.e_phnum == 0) | |
479 | + { | |
480 | + if (build_id_verbose >= BUILD_ID_VERBOSE_BINARY_PARSE) | |
481 | + warning (_("build-id: Invalid ELF program headers from the ELF header " | |
482 | + "at address 0x%lx"), (unsigned long) ehdr_vma); | |
483 | + return NULL; | |
484 | + } | |
485 | + | |
486 | + x_phdrs_size = (bfd_get_arch_size (templ) == 64 ? sizeof (Elf64_External_Phdr) | |
487 | + : sizeof (Elf32_External_Phdr)); | |
488 | + | |
489 | + i_phdrs = xmalloc (i_ehdr.e_phnum * (sizeof *i_phdrs + x_phdrs_size)); | |
490 | + x_phdrs_ptr = (void *) &i_phdrs[i_ehdr.e_phnum]; | |
491 | + err = target_read_memory (ehdr_vma + i_ehdr.e_phoff, (bfd_byte *) x_phdrs_ptr, | |
492 | + i_ehdr.e_phnum * x_phdrs_size); | |
493 | + if (err) | |
494 | + { | |
495 | + free (i_phdrs); | |
496 | + if (build_id_verbose >= BUILD_ID_VERBOSE_BINARY_PARSE) | |
497 | + warning (_("build-id: Error reading " | |
498 | + "ELF program headers at address 0x%lx"), | |
499 | + (unsigned long) (ehdr_vma + i_ehdr.e_phoff)); | |
500 | + return NULL; | |
501 | + } | |
502 | + | |
503 | + loadbase = ehdr_vma; | |
504 | + loadbase_set = 0; | |
505 | + for (i = 0; i < i_ehdr.e_phnum; ++i) | |
506 | + { | |
507 | + elf_swap_phdr_in (templ, (Elf64_External_Phdr *) | |
508 | + (x_phdrs_ptr + i * x_phdrs_size), &i_phdrs[i]); | |
509 | + /* IA-64 vDSO may have two mappings for one segment, where one mapping | |
510 | + is executable only, and one is read only. We must not use the | |
511 | + executable one (PF_R is the first one, PF_X the second one). */ | |
512 | + if (i_phdrs[i].p_type == PT_LOAD && (i_phdrs[i].p_flags & PF_R)) | |
513 | + { | |
514 | + /* Only the first PT_LOAD segment indicates the file bias. | |
515 | + Next segments may have P_VADDR arbitrarily higher. | |
516 | + If the first segment has P_VADDR zero any next segment must not | |
517 | + confuse us, the first one sets LOADBASE certainly enough. */ | |
518 | + if (!loadbase_set && i_phdrs[i].p_offset == 0) | |
519 | + { | |
520 | + loadbase = ehdr_vma - i_phdrs[i].p_vaddr; | |
521 | + loadbase_set = 1; | |
522 | + } | |
523 | + } | |
524 | + } | |
525 | + | |
526 | + if (build_id_verbose >= BUILD_ID_VERBOSE_BINARY_PARSE) | |
527 | + warning (_("build-id: Found ELF header at address 0x%lx, loadbase 0x%lx"), | |
528 | + (unsigned long) ehdr_vma, (unsigned long) loadbase); | |
529 | + | |
530 | + *e_phnum_pointer = i_ehdr.e_phnum; | |
531 | + *loadbase_pointer = loadbase; | |
532 | + return i_phdrs; | |
533 | +} | |
534 | + | |
535 | +/* BUILD_ID_ADDR_GET gets ADDR located somewhere in the object. | |
536 | + Find the first section before ADDR containing an ELF header. | |
537 | + We rely on the fact the sections from multiple files do not mix. | |
538 | + FIXME: We should check ADDR is contained _inside_ the section with possibly | |
539 | + missing content (P_FILESZ < P_MEMSZ). These omitted sections are currently | |
540 | + hidden by _BFD_ELF_MAKE_SECTION_FROM_PHDR. */ | |
541 | + | |
542 | +static CORE_ADDR build_id_addr; | |
543 | +struct build_id_addr_sect | |
544 | + { | |
545 | + struct build_id_addr_sect *next; | |
546 | + asection *sect; | |
547 | + }; | |
548 | +static struct build_id_addr_sect *build_id_addr_sect; | |
549 | + | |
550 | +static void build_id_addr_candidate (bfd *abfd, asection *sect, void *obj) | |
551 | +{ | |
552 | + if (build_id_addr >= bfd_section_vma (abfd, sect)) | |
553 | + { | |
554 | + struct build_id_addr_sect *candidate; | |
555 | + | |
556 | + candidate = xmalloc (sizeof *candidate); | |
557 | + candidate->next = build_id_addr_sect; | |
558 | + build_id_addr_sect = candidate; | |
559 | + candidate->sect = sect; | |
560 | + } | |
561 | +} | |
562 | + | |
563 | +struct build_id * | |
564 | +build_id_addr_get (CORE_ADDR addr) | |
565 | +{ | |
566 | + struct build_id_addr_sect *candidate; | |
567 | + struct build_id *retval = NULL; | |
568 | + Elf_Internal_Phdr *i_phdr = NULL; | |
569 | + bfd_vma loadbase = 0; | |
570 | + unsigned e_phnum = 0; | |
571 | + | |
572 | + if (core_bfd == NULL) | |
573 | + return NULL; | |
574 | + | |
575 | + build_id_addr = addr; | |
576 | + gdb_assert (build_id_addr_sect == NULL); | |
577 | + bfd_map_over_sections (core_bfd, build_id_addr_candidate, NULL); | |
578 | + | |
579 | + /* Sections are sorted in the high-to-low VMAs order. | |
580 | + Stop the search on the first ELF header we find. | |
581 | + Do not continue the search even if it does not contain NT_GNU_BUILD_ID. */ | |
582 | + | |
583 | + for (candidate = build_id_addr_sect; candidate != NULL; | |
584 | + candidate = candidate->next) | |
585 | + { | |
586 | + i_phdr = elf_get_phdr (core_bfd, | |
587 | + bfd_section_vma (core_bfd, candidate->sect), | |
588 | + &e_phnum, &loadbase); | |
589 | + if (i_phdr != NULL) | |
590 | + break; | |
591 | + } | |
592 | + | |
593 | + if (i_phdr != NULL) | |
594 | + { | |
595 | + retval = build_id_phdr_get (core_bfd, loadbase, e_phnum, i_phdr); | |
596 | + xfree (i_phdr); | |
597 | + } | |
598 | + | |
599 | + while (build_id_addr_sect != NULL) | |
600 | + { | |
601 | + candidate = build_id_addr_sect; | |
602 | + build_id_addr_sect = candidate->next; | |
603 | + xfree (candidate); | |
604 | + } | |
605 | + | |
606 | + return retval; | |
607 | +} | |
608 | + | |
609 | /* Return if FILENAME has NT_GNU_BUILD_ID matching the CHECK value. */ | |
610 | ||
611 | static int | |
7566401a | 612 | @@ -1215,7 +1607,7 @@ build_id_verify (const char *filename, s |
3a58abaf AM |
613 | if (abfd == NULL) |
614 | return 0; | |
615 | ||
616 | - found = build_id_bfd_get (abfd); | |
617 | + found = build_id_bfd_shdr_get (abfd); | |
618 | ||
619 | if (found == NULL) | |
620 | warning (_("File \"%s\" has no build-id, file skipped"), filename); | |
7566401a | 621 | @@ -1234,8 +1626,9 @@ build_id_verify (const char *filename, s |
3a58abaf AM |
622 | return retval; |
623 | } | |
624 | ||
625 | -static char * | |
626 | -build_id_to_debug_filename (struct build_id *build_id) | |
627 | +char * | |
628 | +build_id_to_filename (struct build_id *build_id, char **link_return, | |
629 | + int add_debug_suffix) | |
630 | { | |
631 | char *link, *s, *retval = NULL; | |
632 | gdb_byte *data = build_id->data; | |
7566401a | 633 | @@ -1243,7 +1636,9 @@ build_id_to_debug_filename (struct build |
3a58abaf AM |
634 | |
635 | /* DEBUG_FILE_DIRECTORY/.build-id/ab/cdef */ | |
636 | link = xmalloc (strlen (debug_file_directory) + (sizeof "/.build-id/" - 1) + 1 | |
637 | - + 2 * size + (sizeof ".debug" - 1) + 1); | |
638 | + + 2 * size | |
639 | + + (add_debug_suffix ? sizeof ".debug" - 1 : 0) | |
640 | + + 1); | |
641 | s = link + sprintf (link, "%s/.build-id/", debug_file_directory); | |
642 | if (size > 0) | |
643 | { | |
7566401a | 644 | @@ -1254,12 +1649,14 @@ build_id_to_debug_filename (struct build |
3a58abaf AM |
645 | *s++ = '/'; |
646 | while (size-- > 0) | |
647 | s += sprintf (s, "%02x", (unsigned) *data++); | |
648 | - strcpy (s, ".debug"); | |
649 | + if (add_debug_suffix) | |
650 | + strcpy (s, ".debug"); | |
651 | + else | |
652 | + *s = 0; | |
653 | ||
654 | /* lrealpath() is expensive even for the usually non-existent files. */ | |
655 | if (access (link, F_OK) == 0) | |
656 | retval = lrealpath (link); | |
657 | - xfree (link); | |
658 | ||
659 | if (retval != NULL && !build_id_verify (retval, build_id)) | |
660 | { | |
7566401a | 661 | @@ -1267,9 +1664,150 @@ build_id_to_debug_filename (struct build |
3a58abaf AM |
662 | retval = NULL; |
663 | } | |
664 | ||
665 | + if (link_return != NULL) | |
666 | + *link_return = link; | |
667 | + else | |
668 | + xfree (link); | |
669 | + | |
7566401a ER |
670 | return retval; |
671 | } | |
672 | ||
3a58abaf AM |
673 | +/* This MISSING_FILEPAIR_HASH tracker is used only for the duplicite messages |
674 | + Try to install the hash file ... | |
675 | + avoidance. */ | |
676 | + | |
677 | +struct missing_filepair | |
678 | + { | |
679 | + char *binary; | |
680 | + char *debug; | |
681 | + char data[1]; | |
682 | + }; | |
683 | + | |
684 | +static struct htab *missing_filepair_hash; | |
685 | +static struct obstack missing_filepair_obstack; | |
686 | + | |
687 | +static void * | |
688 | +missing_filepair_xcalloc (size_t nmemb, size_t nmemb_size) | |
689 | +{ | |
690 | + void *retval; | |
691 | + size_t size = nmemb * nmemb_size; | |
692 | + | |
693 | + retval = obstack_alloc (&missing_filepair_obstack, size); | |
694 | + memset (retval, 0, size); | |
7566401a ER |
695 | + return retval; |
696 | +} | |
697 | + | |
3a58abaf AM |
698 | +static hashval_t |
699 | +missing_filepair_hash_func (const struct missing_filepair *elem) | |
700 | +{ | |
701 | + hashval_t retval = 0; | |
702 | + | |
703 | + retval ^= htab_hash_string (elem->binary); | |
704 | + if (elem->debug != NULL) | |
705 | + retval ^= htab_hash_string (elem->debug); | |
706 | + | |
707 | + return retval; | |
708 | +} | |
709 | + | |
710 | +static int | |
711 | +missing_filepair_eq (const struct missing_filepair *elem1, | |
712 | + const struct missing_filepair *elem2) | |
713 | +{ | |
714 | + return strcmp (elem1->binary, elem2->binary) == 0 | |
7566401a ER |
715 | + && ((elem1->debug == NULL) == (elem2->debug == NULL)) |
716 | + && (elem1->debug == NULL || strcmp (elem1->debug, elem2->debug) == 0); | |
3a58abaf AM |
717 | +} |
718 | + | |
719 | +static void | |
720 | +missing_filepair_change (void) | |
721 | +{ | |
722 | + if (missing_filepair_hash != NULL) | |
723 | + { | |
724 | + obstack_free (&missing_filepair_obstack, NULL); | |
725 | + /* All their memory came just from missing_filepair_OBSTACK. */ | |
726 | + missing_filepair_hash = NULL; | |
727 | + } | |
728 | +} | |
729 | + | |
730 | +static void | |
731 | +debug_print_executable_changed (void) | |
732 | +{ | |
733 | + missing_filepair_change (); | |
734 | +} | |
735 | + | |
736 | +/* Notify user the file BINARY with (possibly NULL) associated separate debug | |
737 | + information file DEBUG is missing. DEBUG may or may not be the build-id | |
738 | + file such as would be: | |
739 | + /usr/lib/debug/.build-id/dd/b1d2ce632721c47bb9e8679f369e2295ce71be.debug | |
740 | + */ | |
741 | + | |
742 | +void | |
743 | +debug_print_missing (const char *binary, const char *debug) | |
744 | +{ | |
745 | + size_t binary_len0 = strlen (binary) + 1; | |
746 | + size_t debug_len0 = debug ? strlen (debug) + 1 : 0; | |
7566401a | 747 | + struct missing_filepair missing_filepair_find; |
3a58abaf AM |
748 | + struct missing_filepair *missing_filepair; |
749 | + struct missing_filepair **slot; | |
750 | + | |
751 | + if (build_id_verbose < BUILD_ID_VERBOSE_FILENAMES) | |
752 | + return; | |
753 | + | |
754 | + if (missing_filepair_hash == NULL) | |
755 | + { | |
756 | + obstack_init (&missing_filepair_obstack); | |
757 | + missing_filepair_hash = htab_create_alloc (64, | |
758 | + (hashval_t (*) (const void *)) missing_filepair_hash_func, | |
759 | + (int (*) (const void *, const void *)) missing_filepair_eq, NULL, | |
760 | + missing_filepair_xcalloc, NULL); | |
761 | + } | |
762 | + | |
7566401a ER |
763 | + /* Use MISSING_FILEPAIR_FIND first instead of calling obstack_alloc with |
764 | + obstack_free in the case of a (rare) match. The problem is ALLOC_F for | |
765 | + MISSING_FILEPAIR_HASH allocates from MISSING_FILEPAIR_OBSTACK maintenance | |
766 | + structures for MISSING_FILEPAIR_HASH. Calling obstack_free would possibly | |
767 | + not to free only MISSING_FILEPAIR but also some such structures (allocated | |
768 | + during the htab_find_slot call). */ | |
769 | + | |
770 | + missing_filepair_find.binary = (char *) binary; | |
771 | + missing_filepair_find.debug = (char *) debug; | |
772 | + slot = (struct missing_filepair **) htab_find_slot (missing_filepair_hash, | |
773 | + &missing_filepair_find, | |
774 | + INSERT); | |
775 | + | |
776 | + /* While it may be still printed duplicitely with the missing debuginfo file | |
777 | + * it is due to once printing about the binary file build-id link and once | |
778 | + * about the .debug file build-id link as both the build-id symlinks are | |
779 | + * located in the debuginfo package. */ | |
780 | + | |
781 | + if (*slot != NULL) | |
782 | + return; | |
783 | + | |
3a58abaf AM |
784 | + missing_filepair = obstack_alloc (&missing_filepair_obstack, |
785 | + sizeof (*missing_filepair) - 1 | |
786 | + + binary_len0 + debug_len0); | |
787 | + missing_filepair->binary = missing_filepair->data; | |
788 | + memcpy (missing_filepair->binary, binary, binary_len0); | |
789 | + if (debug != NULL) | |
790 | + { | |
791 | + missing_filepair->debug = missing_filepair->binary + binary_len0; | |
792 | + memcpy (missing_filepair->debug, debug, debug_len0); | |
793 | + } | |
794 | + else | |
795 | + missing_filepair->debug = NULL; | |
796 | + | |
3a58abaf AM |
797 | + *slot = missing_filepair; |
798 | + | |
799 | + /* We do not collect and flush these messages as each such message | |
800 | + already requires its own separate lines. */ | |
801 | + | |
802 | + fprintf_unfiltered (gdb_stdlog, | |
803 | + _("Missing separate debuginfo for %s\n"), binary); | |
804 | + if (debug != NULL) | |
805 | + fprintf_unfiltered (gdb_stdlog, _("Try to install the hash file %s\n"), | |
806 | + debug); | |
807 | +} | |
808 | + | |
809 | static char * | |
810 | get_debug_link_info (struct objfile *objfile, unsigned long *crc32_out) | |
811 | { | |
7566401a | 812 | @@ -1352,32 +1890,36 @@ static char * |
3a58abaf AM |
813 | find_separate_debug_file (struct objfile *objfile) |
814 | { | |
815 | asection *sect; | |
816 | - char *basename; | |
817 | - char *dir; | |
818 | - char *debugfile; | |
819 | + char *basename = NULL; | |
820 | + char *dir = NULL; | |
821 | + char *debugfile = NULL; | |
822 | char *name_copy; | |
823 | - char *canon_name; | |
824 | + char *canon_name = NULL; | |
825 | bfd_size_type debuglink_size; | |
826 | unsigned long crc32; | |
827 | int i; | |
828 | struct build_id *build_id; | |
829 | + char *build_id_filename = NULL; | |
830 | ||
831 | - build_id = build_id_bfd_get (objfile->obfd); | |
832 | + build_id = build_id_bfd_shdr_get (objfile->obfd); | |
833 | if (build_id != NULL) | |
834 | { | |
835 | char *build_id_name; | |
836 | ||
837 | - build_id_name = build_id_to_debug_filename (build_id); | |
838 | + build_id_name = build_id_to_filename (build_id, &build_id_filename, 1); | |
839 | xfree (build_id); | |
840 | /* Prevent looping on a stripped .debug file. */ | |
841 | if (build_id_name != NULL && strcmp (build_id_name, objfile->name) == 0) | |
842 | { | |
843 | - warning (_("\"%s\": separate debug info file has no debug info"), | |
844 | + warning (_("\"%s\": The separate debug info file has no debug info"), | |
845 | build_id_name); | |
846 | xfree (build_id_name); | |
847 | } | |
848 | else if (build_id_name != NULL) | |
849 | - return build_id_name; | |
850 | + { | |
851 | + xfree (build_id_filename); | |
852 | + return build_id_name; | |
853 | + } | |
854 | } | |
855 | ||
856 | basename = get_debug_link_info (objfile, &crc32); | |
7566401a | 857 | @@ -1385,7 +1927,7 @@ find_separate_debug_file (struct objfile |
3a58abaf AM |
858 | if (basename == NULL) |
859 | /* There's no separate debug info, hence there's no way we could | |
860 | load it => no warning. */ | |
861 | - return NULL; | |
862 | + goto cleanup_return_debugfile; | |
863 | ||
864 | dir = xstrdup (objfile->name); | |
865 | ||
7566401a ER |
866 | @@ -1407,24 +1949,19 @@ find_separate_debug_file (struct objfile |
867 | if (canon_name && strlen (canon_name) > i) | |
868 | i = strlen (canon_name); | |
3a58abaf AM |
869 | |
870 | - debugfile = alloca (strlen (debug_file_directory) + 1 | |
7566401a | 871 | - + i |
3a58abaf AM |
872 | - + strlen (DEBUG_SUBDIRECTORY) |
873 | - + strlen ("/") | |
874 | - + strlen (basename) | |
875 | - + 1); | |
876 | + debugfile = xmalloc (strlen (debug_file_directory) + 1 | |
7566401a | 877 | + + i |
3a58abaf AM |
878 | + + strlen (DEBUG_SUBDIRECTORY) |
879 | + + strlen ("/") | |
880 | + + strlen (basename) | |
881 | + + 1); | |
882 | ||
883 | /* First try in the same directory as the original file. */ | |
884 | strcpy (debugfile, dir); | |
885 | strcat (debugfile, basename); | |
886 | ||
887 | if (separate_debug_file_exists (debugfile, crc32, objfile->name)) | |
888 | - { | |
889 | - xfree (basename); | |
890 | - xfree (dir); | |
7566401a | 891 | - xfree (canon_name); |
3a58abaf AM |
892 | - return xstrdup (debugfile); |
893 | - } | |
894 | + goto cleanup_return_debugfile; | |
895 | ||
896 | /* Then try in the subdirectory named DEBUG_SUBDIRECTORY. */ | |
897 | strcpy (debugfile, dir); | |
7566401a | 898 | @@ -1433,12 +1970,7 @@ find_separate_debug_file (struct objfile |
3a58abaf AM |
899 | strcat (debugfile, basename); |
900 | ||
901 | if (separate_debug_file_exists (debugfile, crc32, objfile->name)) | |
902 | - { | |
903 | - xfree (basename); | |
904 | - xfree (dir); | |
7566401a | 905 | - xfree (canon_name); |
3a58abaf AM |
906 | - return xstrdup (debugfile); |
907 | - } | |
908 | + goto cleanup_return_debugfile; | |
909 | ||
910 | /* Then try in the global debugfile directory. */ | |
911 | strcpy (debugfile, debug_file_directory); | |
7566401a | 912 | @@ -1447,12 +1979,7 @@ find_separate_debug_file (struct objfile |
3a58abaf AM |
913 | strcat (debugfile, basename); |
914 | ||
915 | if (separate_debug_file_exists (debugfile, crc32, objfile->name)) | |
916 | - { | |
917 | - xfree (basename); | |
918 | - xfree (dir); | |
7566401a | 919 | - xfree (canon_name); |
3a58abaf AM |
920 | - return xstrdup (debugfile); |
921 | - } | |
922 | + goto cleanup_return_debugfile; | |
923 | ||
924 | /* If the file is in the sysroot, try using its base path in the | |
925 | global debugfile directory. */ | |
7566401a | 926 | @@ -1466,20 +1993,18 @@ find_separate_debug_file (struct objfile |
3a58abaf AM |
927 | strcat (debugfile, basename); |
928 | ||
929 | if (separate_debug_file_exists (debugfile, crc32, objfile->name)) | |
930 | - { | |
931 | - xfree (canon_name); | |
932 | - xfree (basename); | |
933 | - xfree (dir); | |
934 | - return xstrdup (debugfile); | |
935 | - } | |
7566401a | 936 | + goto cleanup_return_debugfile; |
3a58abaf | 937 | } |
7566401a | 938 | |
3a58abaf AM |
939 | - if (canon_name) |
940 | - xfree (canon_name); | |
3a58abaf AM |
941 | + debugfile = NULL; |
942 | + debug_print_missing (objfile->name, build_id_filename); | |
7566401a | 943 | |
3a58abaf AM |
944 | +cleanup_return_debugfile: |
945 | + xfree (build_id_filename); | |
946 | + xfree (canon_name); | |
947 | xfree (basename); | |
948 | xfree (dir); | |
949 | - return NULL; | |
950 | + return debugfile; | |
951 | } | |
952 | ||
953 | ||
7566401a ER |
954 | @@ -4229,4 +4754,16 @@ the global debug-file directory prepende |
955 | NULL, | |
956 | show_debug_file_directory, | |
957 | &setlist, &showlist); | |
958 | + | |
959 | + add_setshow_zinteger_cmd ("build-id-verbose", no_class, &build_id_verbose, | |
960 | + _("\ | |
961 | + Set debugging level of the build-id locator."), _("\ | |
962 | + Show debugging level of the build-id locator."), _("\ | |
963 | + Level 1 (default) enables printing the missing debug filenames,\n\ | |
964 | + level 2 also prints the parsing of binaries to find the identificators."), | |
965 | + NULL, | |
966 | + show_build_id_verbose, | |
967 | + &setlist, &showlist); | |
968 | + | |
969 | + observer_attach_executable_changed (debug_print_executable_changed); | |
3a58abaf | 970 | } |
7566401a | 971 | Index: gdb-6.8.91.20090925/gdb/symfile.h |
3a58abaf | 972 | =================================================================== |
7566401a ER |
973 | --- gdb-6.8.91.20090925.orig/gdb/symfile.h 2009-09-25 09:29:57.000000000 +0200 |
974 | +++ gdb-6.8.91.20090925/gdb/symfile.h 2009-09-25 09:29:58.000000000 +0200 | |
975 | @@ -381,6 +381,13 @@ extern int symfile_map_offsets_to_segmen | |
3a58abaf AM |
976 | struct symfile_segment_data *get_symfile_segment_data (bfd *abfd); |
977 | void free_symfile_segment_data (struct symfile_segment_data *data); | |
978 | ||
979 | +/* build-id support. */ | |
980 | +struct build_id; | |
981 | +extern struct build_id *build_id_addr_get (CORE_ADDR addr); | |
982 | +extern char *build_id_to_filename (struct build_id *build_id, | |
983 | + char **link_return, int add_debug_suffix); | |
984 | +extern void debug_print_missing (const char *binary, const char *debug); | |
985 | + | |
986 | /* From dwarf2read.c */ | |
987 | ||
988 | extern int dwarf2_has_info (struct objfile *); | |
7566401a | 989 | Index: gdb-6.8.91.20090925/gdb/testsuite/lib/gdb.exp |
3a58abaf | 990 | =================================================================== |
7566401a ER |
991 | --- gdb-6.8.91.20090925.orig/gdb/testsuite/lib/gdb.exp 2009-09-25 09:29:57.000000000 +0200 |
992 | +++ gdb-6.8.91.20090925/gdb/testsuite/lib/gdb.exp 2009-09-25 09:29:58.000000000 +0200 | |
993 | @@ -1248,6 +1248,16 @@ proc default_gdb_start { } { | |
3a58abaf AM |
994 | warning "Couldn't set the width to 0." |
995 | } | |
996 | } | |
997 | + # Turn off the missing warnings as the testsuite does not expect it. | |
998 | + send_gdb "set build-id-verbose 0\n" | |
999 | + gdb_expect 10 { | |
1000 | + -re "$gdb_prompt $" { | |
1001 | + verbose "Disabled the missing debug infos warnings." 2 | |
1002 | + } | |
1003 | + timeout { | |
1004 | + warning "Could not disable the missing debug infos warnings.." | |
1005 | + } | |
1006 | + } | |
1007 | return 0; | |
1008 | } | |
1009 | ||
7566401a ER |
1010 | Index: gdb-6.8.91.20090925/gdb/testsuite/lib/mi-support.exp |
1011 | =================================================================== | |
1012 | --- gdb-6.8.91.20090925.orig/gdb/testsuite/lib/mi-support.exp 2009-09-15 20:51:26.000000000 +0200 | |
1013 | +++ gdb-6.8.91.20090925/gdb/testsuite/lib/mi-support.exp 2009-09-25 09:29:58.000000000 +0200 | |
d566d21e | 1014 | @@ -221,6 +221,16 @@ proc default_mi_gdb_start { args } { |
1015 | } | |
1016 | } | |
1017 | } | |
1018 | + # Turn off the missing warnings as the testsuite does not expect it. | |
1019 | + send_gdb "190-gdb-set build-id-verbose 0\n" | |
1020 | + gdb_expect 10 { | |
1021 | + -re ".*190-gdb-set build-id-verbose 0\r\n190\\\^done\r\n$mi_gdb_prompt$" { | |
1022 | + verbose "Disabled the missing debug infos warnings." 2 | |
1023 | + } | |
1024 | + timeout { | |
1025 | + warning "Could not disable the missing debug infos warnings.." | |
1026 | + } | |
1027 | + } | |
1028 | ||
1029 | detect_async | |
1030 | ||
7566401a ER |
1031 | Index: gdb-6.8.91.20090925/gdb/objfiles.h |
1032 | =================================================================== | |
1033 | --- gdb-6.8.91.20090925.orig/gdb/objfiles.h 2009-09-25 09:29:57.000000000 +0200 | |
1034 | +++ gdb-6.8.91.20090925/gdb/objfiles.h 2009-09-25 09:38:27.000000000 +0200 | |
1035 | @@ -428,6 +428,10 @@ struct objfile | |
1036 | ||
1037 | #define OBJF_MAIN (1 << 7) | |
1038 | ||
1039 | +/* This file was loaded according to the BUILD_ID_CORE_LOADS rules. */ | |
1040 | + | |
1041 | +#define OBJF_BUILD_ID_CORE_LOADED (1 << 12) | |
1042 | + | |
1043 | /* The object file that the main symbol table was loaded from (e.g. the | |
1044 | argument to the "symbol-file" or "file" command). */ | |
1045 |