From patchwork Mon Dec 11 15:08:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 24855 Received: (qmail 38384 invoked by alias); 11 Dec 2017 15:08:24 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 36350 invoked by uid 89); 11 Dec 2017 15:08:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 11 Dec 2017 15:08:21 +0000 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 44DFFC014190; Mon, 11 Dec 2017 15:08:19 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7ED8B46E8C; Mon, 11 Dec 2017 15:08:13 +0000 (UTC) Subject: [pushed] Unbreak build for non-ELF ports (Re: [PATCH v3 3/5] Code cleanup: dwarf2_initialize_objfile return value) To: Yao Qi References: <149790572259.20186.14601775821404892582.stgit@host1.jankratochvil.net> <149790575186.20186.4091613230201630619.stgit@host1.jankratochvil.net> <83d5d4a6-a137-b680-1af0-33b895bd817d@redhat.com> <653fdb35-4d09-283f-a2a2-cb6b0fb6d000@redhat.com> <27041091-d0fb-95cb-2d88-72859ceac347@redhat.com> Cc: Jan Kratochvil , GDB Patches , Victor Leschuk From: Pedro Alves Message-ID: <16d867d9-ec0c-c94e-b25e-d414b62f3b83@redhat.com> Date: Mon, 11 Dec 2017 15:08:13 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <27041091-d0fb-95cb-2d88-72859ceac347@redhat.com> On 12/11/2017 01:59 PM, Pedro Alves wrote: > 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. > OK, confirmed now that this fixes the build for --target=arm-wince-pe, and confirmed on x86-64 GNU/Linux that both .gdb_index and .debug_names indexes continue working. Below's what I pushed. From 3c0aa29aab3949363f8b23d062c2e0cb1ccf017a Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Mon, 11 Dec 2017 13:24:32 +0000 Subject: [PATCH] Unbreak build for non-ELF ports As reported at , this commit: ~~~~ commit abccd1e7b7a37385159610ca4e0bc2632a547e9a Author: Jan Kratochvil 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 * 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. --- gdb/ChangeLog | 16 ++++++++++++++++ gdb/defs.h | 6 ------ gdb/dwarf2read.c | 32 ++++++++++++++------------------ gdb/elfread.c | 29 +++++++++++++++++++++++------ gdb/symfile.h | 17 ++++++++++++++++- 5 files changed, 69 insertions(+), 31 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index b3c5b97..78fd713 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,19 @@ +2017-12-11 Pedro Alves + + * 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 * target-float.c (mpfr_float_ops::from_target): Use mpfr_set_ui diff --git a/gdb/defs.h b/gdb/defs.h index c2e145e..f76293f 100644 --- a/gdb/defs.h +++ b/gdb/defs.h @@ -679,12 +679,6 @@ extern int (*deprecated_ui_load_progress_hook) (const char *section, 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 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; } @@ -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 *);