On Fri, 24 Aug 2007 20:20:28 +0200, Daniel Jacobowitz wrote: > On Fri, Aug 24, 2007 at 08:04:50PM +0200, Jan Kratochvil wrote: ... > > This part may be questionable: > > - debugfile = find_separate_debug_file (objfile); > > + /* If the file has its own symbol tables it has no separate debug info. */ > > + if (objfile->psymtabs == NULL) > > + debugfile = find_separate_debug_file (objfile); ... > > Not sure if `PSYMTABS == NULL' is the right condition. According to my > > experiments on GNU/Linux it should be correct. > > In some cases a library will be left with .symtab but not .debug_info; > sometimes elfutils does this, also sometimes it is done deliberately > for ld.so / libpthread.so so that the separate debug file is not > necessary for minimal debugging to work. You are right about the content of `/lib64/ld-linux-x86-64.so.2'. Still in such case both `.dynsym' and `.symtab' gets read into MSYMBOLS but PSYMTABS and SYMTABS are left forever NULL for the main executable (as there is no .debug_info). While I would still expect the former patch was right I changed it according to your advice. It is definitely the safe way but with a tiny performance hit: The reason of my check was that build-id (contrary to the debug-link) is always present there, even for locally built unsplit files. With the patch attached below GDB will try to open a separate debug file in /usr/lib/debug/.debug-id/ even for the unsplit files. This step did not happen with my former patch. > We should either pass a flag down so that we know we're already > looking at the separate debug file (more efficient, saves us the > second search, more work to implement) Chose this way as the intention of the whole patch is performance. (Aware OBJF_DEBUG_FILE is not an OBJFILE flag - just an additional SYMBOL_FILE_ADD_WITH_ADDRS_OR_OFFSETS parameter - but it may get one day useful for later retrieval from OBJFILE.) > > +/* Locate NT_GNU_BUILD_ID and return its content. > > + Separate debuginfo files have corrupted PHDR but SHDR is correct there. */ > > + > > +static struct build_id * > > +build_id_bfd_shdr_get (bfd *abfd) > > +{ > > + struct build_id *retval; > > + > > + if (!bfd_check_format (abfd, bfd_object) > > + || bfd_get_flavour (abfd) != bfd_target_elf_flavour > > + || elf_tdata (abfd)->build_id == NULL) > > + return NULL; > > + > > + retval = xmalloc (sizeof *retval - 1 + elf_tdata (abfd)->build_id_size); > > + retval->size = elf_tdata (abfd)->build_id_size; > > + memcpy (retval->data, elf_tdata (abfd)->build_id, retval->size); > > + > > + return retval; > > +} > > This function isn't doing anything with program headers or section > headers now, maybe it should be renamed (and the comment doesn't need > to talk about corrupted phdrs in that case). Not agreed as the PHDR<->SHDR difference is important (there are issues about it for readelf/eu-readelf - whether PHDR or SHDR should be chosen there). But changed according to your advice. > I believe the manual needs an update to mention the new search path. I see now, sorry, implemented. Thanks, Jan