From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 81279 invoked by alias); 20 Sep 2019 02:57:47 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 81261 invoked by uid 89); 20 Sep 2019 02:57:47 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-30.8 required=5.0 tests=AWL,BAYES_00,ENV_AND_HDR_SPF_MATCH,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS,USER_IN_DEF_SPF_WL autolearn=ham version=3.3.1 spammy= X-HELO: mail-oi1-f194.google.com Received: from mail-oi1-f194.google.com (HELO mail-oi1-f194.google.com) (209.85.167.194) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 20 Sep 2019 02:57:45 +0000 Received: by mail-oi1-f194.google.com with SMTP id o205so512529oib.12 for ; Thu, 19 Sep 2019 19:57:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=jOL5PqqPtt4s96Altdws+xHPRayIrFJZpcpFpWOE2Bc=; b=aymQnQXze9P87mI8FSwG/zIP0XqiyponpLU6IujzMtr606VyVq9BcKNYIQToHhhrA8 r7WVgV/dRcG93DUwgOhdkohAsi1k0/pKHuvBA7qpSQzmxy3ONAf1rddrK9i+/fxTen0x x3ZcHBUk5VSCEYJo5mvTuegMD585TCrfDalvTBaJFwnHa/pJIkBUDuH43bYWUIJI3Jk+ 2na7zLKEW1Vllo8f9bzxJ2JXM9oTxfZRRGXrwNvZX4SGifWhuBHunJVcOBjdpL36WAOD ASMuJGY6cbn0dvIUDhAZajveRdODr/gkKGcmT0m3zErKk3Jv/RGWgDN4EHRzda2ftIQa Zc/w== MIME-Version: 1.0 References: <20190827213752.204025-1-cbiesinger@google.com> <20190827230330.89757-1-cbiesinger@google.com> <5a2bc785-4ecd-0c21-10b0-ab8f3d17aa02@simark.ca> In-Reply-To: <5a2bc785-4ecd-0c21-10b0-ab8f3d17aa02@simark.ca> From: "Christian Biesinger via gdb-patches" Reply-To: Christian Biesinger Date: Fri, 20 Sep 2019 02:57:00 -0000 Message-ID: Subject: Re: [PATCH v3] Replace solib_global_lookup with gdbarch_iterate_over_objfiles_in_search_order To: Simon Marchi Cc: gdb-patches Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2019-09/txt/msg00394.txt.bz2 On Fri, Sep 20, 2019 at 10:00 AM Simon Marchi wrote: > > On 2019-08-27 7:03 p.m., Christian Biesinger via gdb-patches wrote: > > [Test solib-corrupted.exp is now fixed] > > > > All implementations of either function use it for the same purpose (except > > Darwin, which is a no-op): to prefer a symbol in the current objfile over > > symbols with the same name in other objfiles. There does not seem to be a > > reason to have both mechanisms for that purpose. > > Hi Christian, > > The patch LGTM, I'm also confident that it doesn't change the current > behavior. I just have two very minor comments below. > > Note that SPU support is about to be removed [1]. If you wait until it is > removed, it would simplify a bit this patch, as you wish. > > [1] https://sourceware.org/ml/gdb-patches/2019-09/msg00067.html Will do. > > @@ -3202,32 +3204,41 @@ svr4_lp64_fetch_link_map_offsets (void) > > > > struct target_so_ops svr4_so_ops; > > > > -/* Lookup global symbol for ELF DSOs linked with -Bsymbolic. Those DSOs have a > > +/* Search order for ELF DSOs linked with -Bsymbolic. Those DSOs have a > > different rule for symbol lookup. The lookup begins here in the DSO, not in > > the main executable. */ > > > > -static struct block_symbol > > -elf_lookup_lib_symbol (struct objfile *objfile, > > - const char *name, > > - const domain_enum domain) > > +void > > +svr4_iterate_over_objfiles_in_search_order > > + (struct gdbarch *gdbarch, > > + iterate_over_objfiles_in_search_order_cb_ftype *cb, > > + void *cb_data, struct objfile *current_objfile) > > { > > - bfd *abfd; > > - > > - if (objfile == symfile_objfile) > > - abfd = exec_bfd; > > - else > > + if (current_objfile != nullptr) > > { > > - /* OBJFILE should have been passed as the non-debug one. */ > > - gdb_assert (objfile->separate_debug_objfile_backlink == NULL); > > + bfd *abfd; > > > > - abfd = objfile->obfd; > > - } > > + if (current_objfile->separate_debug_objfile_backlink != nullptr) > > + current_objfile = current_objfile->separate_debug_objfile_backlink; > > > > - if (abfd == NULL || scan_dyntag (DT_SYMBOLIC, abfd, NULL, NULL) != 1) > > - return {}; > > + if (current_objfile == symfile_objfile) > > + abfd = exec_bfd; > > + else > > + abfd = current_objfile->obfd; > > + > > + if (abfd != nullptr && > > + scan_dyntag (DT_SYMBOLIC, abfd, nullptr, nullptr) == 1) > > + { > > + if (cb (current_objfile, cb_data) != 0) > > + return; > > + } > > + } > > > > - return lookup_global_symbol_from_objfile (objfile, GLOBAL_BLOCK, name, > > - domain); > > + for (objfile *objfile : current_program_space->objfiles ()) > > + { > > + if (cb (objfile, cb_data) != 0) > > + return; > > + } > > } > > If we do search the current objfile in the first part of that > function, we could skip it in the second part. Done. > > diff --git a/gdb/solib-svr4.h b/gdb/solib-svr4.h > > index a051e70b79..b99b8e2e3a 100644 > > --- a/gdb/solib-svr4.h > > +++ b/gdb/solib-svr4.h > > @@ -21,6 +21,7 @@ > > #define SOLIB_SVR4_H > > > > #include "solist.h" > > +#include "gdbarch.h" > > Could this be a forward declaration of `struct gdbarch` instead? > > Though if you wait until SPU is removed, the function > svr4_iterate_over_objfiles_in_search_order won't need to be exported, it should > be made static. Done (made static). Will send a new version of the patch and push when SPU is removed. Christian