Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Yao Qi <qiyaoltc@gmail.com>
Cc: Jan Kratochvil <jan.kratochvil@redhat.com>,
	GDB Patches <gdb-patches@sourceware.org>,
	Victor Leschuk <vleschuk@accesssoftek.com>
Subject: Re: [PATCH v3 3/5] Code cleanup: dwarf2_initialize_objfile return value
Date: Mon, 11 Dec 2017 14:00:00 -0000	[thread overview]
Message-ID: <27041091-d0fb-95cb-2d88-72859ceac347@redhat.com> (raw)
In-Reply-To: <653fdb35-4d09-283f-a2a2-cb6b0fb6d000@redhat.com>

On 12/11/2017 01:20 PM, Pedro Alves wrote:
> On 12/11/2017 01:03 PM, Yao Qi wrote:
> 
>> This breaks the arm-wince-pe build,
>>
>> 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
>>
>> https://ci.linaro.org/job/tcwg-binutils/4395/
>>
> 
> Eh, looks like the bridge was closer than I realized...  I forgot
> the non-elf ports don't include elfread.c in the build.  So we
> really need to do something else here.  Maybe an enum instead of
> the original boolean.

Something like this.  I had already added a boolean for the index
variant to dwarf2read.c, so this reuses that.

I haven't tried to build for --target=arm-wince-pe yet, but this
probably works.  I'll get back to this in a bit when I have a chance.

From 223c6e730f2f85ca4732335964b616006974e078 Mon Sep 17 00:00:00 2001
From: Pedro Alves <palves@redhat.com>
Date: Mon, 11 Dec 2017 13:24:32 +0000
Subject: [PATCH] Unbreak non-ELF ports

---
 gdb/dwarf2read.c | 32 ++++++++++++++------------------
 gdb/elfread.c    | 29 +++++++++++++++++++++++------
 gdb/symfile.h    | 17 ++++++++++++++++-
 3 files changed, 53 insertions(+), 25 deletions(-)

diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 2aeb506..b4e60a4 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -6451,11 +6451,10 @@ const struct quick_symbol_functions dwarf2_debug_names_functions =
   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
@@ -6483,16 +6482,23 @@ dwarf2_initialize_objfile (struct objfile *objfile)
       /* 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
@@ -26799,16 +26805,6 @@ assert_file_size (FILE *file, const char *filename, size_t expected_size)
   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
diff --git a/gdb/elfread.c b/gdb/elfread.c
index 31288a9..7a41c26 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -48,6 +48,11 @@
 #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.  */
@@ -1211,11 +1216,25 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
 
   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
@@ -1223,8 +1242,6 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
 	     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
diff --git a/gdb/symfile.h b/gdb/symfile.h
index e903c60..93fbe68 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -603,7 +603,22 @@ extern void dwarf2_get_section_info (struct objfile *,
 				     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 *);
 
-- 
2.5.5



  reply	other threads:[~2017-12-11 14:00 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-19 20:55 [PATCH v3 0/5] DWARF-5: .debug_names index Jan Kratochvil
2017-06-19 20:55 ` [PATCH v3 1/5] cc-with-tweaks.sh: Use gdb-add-index.sh Jan Kratochvil
2017-06-29 19:40   ` Simon Marchi
2017-07-01 15:23     ` [PATCH v3.1 " Jan Kratochvil
2017-12-08 23:43       ` Pedro Alves
2017-06-19 20:55 ` [PATCH v3 2/5] DWARF-5: .debug_names index producer Jan Kratochvil
2017-06-20 15:19   ` Eli Zaretskii
2017-06-22 18:35     ` [PATCH v3.1 " Jan Kratochvil
2017-06-22 19:18       ` Eli Zaretskii
2017-06-22 20:03         ` [PATCH v3.2 " Jan Kratochvil
2017-12-08 23:51           ` Pedro Alves
2017-12-12 15:38             ` Jan Kratochvil
2017-12-31  3:52             ` Simon Marchi
2017-06-19 20:56 ` [PATCH v3 4/5] Refactor: Move some generic code out of .gdb_index code Jan Kratochvil
2017-12-08 23:53   ` Pedro Alves
2017-06-19 20:56 ` [PATCH v3 5/5] DWARF-5: .debug_names index consumer Jan Kratochvil
2017-06-28 21:21   ` [PATCH v3.1 " Jan Kratochvil
2017-07-02 14:30     ` [PATCH v3.2 " Jan Kratochvil
2017-12-08 23:59       ` Pedro Alves
2017-12-09  0:07         ` [pushed] Add gdb::hash_enum (Re: [PATCH v3.2 5/5] DWARF-5: .debug_names index consumer) Pedro Alves
2017-12-12 16:52         ` [PATCH v3.2 5/5] DWARF-5: .debug_names index consumer Jan Kratochvil
2017-12-13 21:57           ` [patch] DWARF-5 .debug_names DW_IDX_type_unit fix [Re: [PATCH v3.2 5/5] DWARF-5: .debug_names index consumer] Jan Kratochvil
2017-12-13 22:16             ` Pedro Alves
2017-12-13 23:03               ` Pedro Alves
2017-12-14  9:03                 ` [commit] " Jan Kratochvil
2017-06-19 20:56 ` [PATCH v3 3/5] Code cleanup: dwarf2_initialize_objfile return value Jan Kratochvil
2017-12-08 23:52   ` Pedro Alves
2017-12-11 13:04     ` Yao Qi
2017-12-11 13:20       ` Pedro Alves
2017-12-11 14:00         ` Pedro Alves [this message]
2017-12-11 15:08           ` [pushed] Unbreak build for non-ELF ports (Re: [PATCH v3 3/5] Code cleanup: dwarf2_initialize_objfile return value) Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=27041091-d0fb-95cb-2d88-72859ceac347@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jan.kratochvil@redhat.com \
    --cc=qiyaoltc@gmail.com \
    --cc=vleschuk@accesssoftek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox