As reported at
<https://sourceware.org/ml/gdb-patches/2017-12/msg00229.html>, this
commit:
~~~~
commit
abccd1e7b7a37385159610ca4e0bc2632a547e9a
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
AuthorDate: Fri Dec 8 22:44:11 2017 +0000
Change dwarf2_initialize_objfile's return value
dwarf2_initialize_objfile was returning boolean whether it is psymtabs
or .gdb_index while now it needs to return also whether it is
.debug_names.
~~~~
breaks non-ELF-target builds:
dwarf2read.o: In function `dwarf2_initialize_objfile(objfile*)':
/home/yao.qi/SourceCode/gnu/binutils-gdb/gdb/dwarf2read.c:6486:
undefined reference to `elf_sym_fns_gdb_index'
/home/yao.qi/SourceCode/gnu/binutils-gdb/gdb/dwarf2read.c:6490:
undefined reference to `elf_sym_fns_debug_names'
/home/yao.qi/SourceCode/gnu/binutils-gdb/gdb/dwarf2read.c:6495:
undefined reference to `elf_sym_fns_lazy_psyms'
collect2: error: ld returned 1 exit status
Makefile:1920: recipe for target 'gdb' failed
because gdb/elfread.c is not included in the gdb build unless bfd also
includes elf support.
Fix this by reverting the patch mentioned above and at the same time
re-adding .debug_names support by adding a new output parameter to
dwarf2_initialize_objfile to indicate the index variant in use. We
can reuse the new dw_index_kind enum in dwarf2read.c for that.
gdb/ChangeLog:
2017-12-11 Pedro Alves <palves@redhat.com>
* defs.h (elf_sym_fns_lazy_psyms, elf_sym_fns_gdb_index)
(elf_sym_fns_debug_names): Move to elfread.c.
* dwarf2read.c (dwarf2_initialize_objfile): Return a boolean
instead of a sym_fns and add 'index_kind' output parameter. Fill
the latter in with the index variant kind if using an index.
(enum dw_index_kind): Moved to symfile.h.
* elfread.c (elf_sym_fns_gdb_index, elf_sym_fns_debug_names)
(elf_sym_fns_lazy_psyms): Move from defs.h.
(elf_symfile_read): Adjust to new dwarf2_initialize_objfile
interface.
* symfile.h (enum class dw_index_kind): New, moved from
dwarf2read.c.
(dwarf2_initialize_objfile): Change prototype.
+2017-12-11 Pedro Alves <palves@redhat.com>
+
+ * defs.h (elf_sym_fns_lazy_psyms, elf_sym_fns_gdb_index)
+ (elf_sym_fns_debug_names): Move to elfread.c.
+ * dwarf2read.c (dwarf2_initialize_objfile): Return a boolean
+ instead of a sym_fns and add 'index_kind' output parameter. Fill
+ the latter in with the index variant kind if using an index.
+ (enum dw_index_kind): Moved to symfile.h.
+ * elfread.c (elf_sym_fns_gdb_index, elf_sym_fns_debug_names)
+ (elf_sym_fns_lazy_psyms): Move from defs.h.
+ (elf_symfile_read): Adjust to new dwarf2_initialize_objfile
+ interface.
+ * symfile.h (enum class dw_index_kind): New, moved from
+ dwarf2read.c.
+ (dwarf2_initialize_objfile): Change prototype.
+
2017-12-11 Ulrich Weigand <uweigand@de.ibm.com>
* target-float.c (mpfr_float_ops::from_target): Use mpfr_set_ui
extern void initialize_progspace (void);
extern void initialize_inferiors (void);
-/* From elfread.c */
-
-extern const struct sym_fns elf_sym_fns_lazy_psyms;
-extern const struct sym_fns elf_sym_fns_gdb_index;
-extern const struct sym_fns elf_sym_fns_debug_names;
-
/* * Special block numbers */
enum block_enum
dw2_map_symbol_filenames
};
-/* Initialize for reading DWARF for this objfile. Return 0 if this
- file will use psymtabs, or 1 if using the GNU index. */
+/* See symfile.h. */
-const sym_fns &
-dwarf2_initialize_objfile (struct objfile *objfile)
+bool
+dwarf2_initialize_objfile (struct objfile *objfile, dw_index_kind *index_kind)
{
/* If we're about to read full symbols, don't bother with the
indices. In this case we also don't care if some other debug
/* Return 1 so that gdb sees the "quick" functions. However,
these functions will be no-ops because we will have expanded
all symtabs. */
- return elf_sym_fns_gdb_index;
+ *index_kind = dw_index_kind::GDB_INDEX;
+ return true;
}
if (dwarf2_read_debug_names (objfile))
- return elf_sym_fns_debug_names;
+ {
+ *index_kind = dw_index_kind::DEBUG_NAMES;
+ return true;
+ }
if (dwarf2_read_index (objfile))
- return elf_sym_fns_gdb_index;
+ {
+ *index_kind = dw_index_kind::GDB_INDEX;
+ return true;
+ }
- return elf_sym_fns_lazy_psyms;
+ return false;
}
\f
gdb_assert (file_size == expected_size);
}
-/* An index variant. */
-enum dw_index_kind
-{
- /* GDB's own .gdb_index format. */
- GDB_INDEX,
-
- /* DWARF5 .debug_names. */
- DEBUG_NAMES,
-};
-
/* Create an index file for OBJFILE in the directory DIR. */
static void
#include "location.h"
#include "auxv.h"
+/* Forward declarations. */
+extern const struct sym_fns elf_sym_fns_gdb_index;
+extern const struct sym_fns elf_sym_fns_debug_names;
+extern const struct sym_fns elf_sym_fns_lazy_psyms;
+
/* The struct elfinfo is available only during ELF symbol table and
psymtab reading. It is destroyed at the completion of psymtab-reading.
It's local to elf_symfile_read. */
if (dwarf2_has_info (objfile, NULL))
{
- /* elf_sym_fns_gdb_index cannot handle simultaneous non-DWARF debug
- information present in OBJFILE. If there is such debug info present
- never use .gdb_index. */
+ dw_index_kind index_kind;
- if (objfile_has_partial_symbols (objfile))
+ /* elf_sym_fns_gdb_index cannot handle simultaneous non-DWARF
+ debug information present in OBJFILE. If there is such debug
+ info present never use an index. */
+ if (!objfile_has_partial_symbols (objfile)
+ && dwarf2_initialize_objfile (objfile, &index_kind))
+ {
+ switch (index_kind)
+ {
+ case dw_index_kind::GDB_INDEX:
+ objfile_set_sym_fns (objfile, &elf_sym_fns_gdb_index);
+ break;
+ case dw_index_kind::DEBUG_NAMES:
+ objfile_set_sym_fns (objfile, &elf_sym_fns_debug_names);
+ break;
+ }
+ }
+ else
{
/* It is ok to do this even if the stabs reader made some
partial symbols, because OBJF_PSYMTABS_READ has not been
when needed. */
objfile_set_sym_fns (objfile, &elf_sym_fns_lazy_psyms);
}
- else
- objfile_set_sym_fns (objfile, &dwarf2_initialize_objfile (objfile));
}
/* If the file has its own symbol tables it has no separate debug
info. `.dynsym'/`.symtab' go to MSYMBOLS, `.debug_info' goes to
asection **, const gdb_byte **,
bfd_size_type *);
-extern const sym_fns &dwarf2_initialize_objfile (struct objfile *);
+/* A DWARF names index variant. */
+enum class dw_index_kind
+{
+ /* GDB's own .gdb_index format. */
+ GDB_INDEX,
+
+ /* DWARF5 .debug_names. */
+ DEBUG_NAMES,
+};
+
+/* Initialize for reading DWARF for OBJFILE. Return false if this
+ file will use psymtabs, or true if using an index, in which case
+ *INDEX_KIND is set to the index variant in use. */
+extern bool dwarf2_initialize_objfile (struct objfile *objfile,
+ dw_index_kind *index_kind);
+
extern void dwarf2_build_psymtabs (struct objfile *);
extern void dwarf2_build_frame_info (struct objfile *);