From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 69985 invoked by alias); 11 Feb 2020 10:45:40 -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 69839 invoked by uid 89); 11 Feb 2020 10:45:25 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mail-wm1-f66.google.com Received: from mail-wm1-f66.google.com (HELO mail-wm1-f66.google.com) (209.85.128.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 11 Feb 2020 10:45:21 +0000 Received: by mail-wm1-f66.google.com with SMTP id b17so2895641wmb.0 for ; Tue, 11 Feb 2020 02:45:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=cOr30peC2JmwIOr0gEfDbIM9BQSmraDl7QKBwz+8ehE=; b=qDjWpPUeqhI0Ny0jx78aQPmHpQkf1K6yvUA2R0+rllnNmfURg8jQdhx+nAGP/LhhyT H5AWSWifWN7kRhCtOA4wIvhWcGiPZdh+eJ6yrhRoua5TJFDO3/GkVsZBs1PXy6SaaMQH o1nqdFT9FbeKJZ+3T9x9lKe3KPBRHT2ihZNfakBz+Sz2D19Sw0P1ljPG2R5X7NXC5qsl PNBm7tn2eS3B42hiNfH8DyBx/LHCi7TDOe0bVKH++KS0CbNb467hKCfILx0pGUGEmZUf Usmx8TxTSPRPzAxJ1+lA652NOVl+yhO8K5UMn8QP21z2jjgrWjAlt5Ykxc1ZswIdM/rR fLLQ== Return-Path: Received: from [172.29.6.113] (26.124.146.82.ipv4.evonet.be. [82.146.124.26]) by smtp.gmail.com with ESMTPSA id g21sm3127410wmh.17.2020.02.11.02.45.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 11 Feb 2020 02:45:18 -0800 (PST) Subject: Re: [PATCH 8/8] Move the frame data to the BFD when possible To: Tom Tromey , gdb-patches@sourceware.org References: <20200208152758.29385-1-tom@tromey.com> <20200208152758.29385-9-tom@tromey.com> From: Luis Machado Message-ID: Date: Tue, 11 Feb 2020 10:45:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <20200208152758.29385-9-tom@tromey.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2020-02/txt/msg00377.txt.bz2 On 2/8/20 12:27 PM, Tom Tromey wrote: > Now that comp_unit and the remaining frame data are all independent of > the objfile, it can all be stored on the BFD and shared across > inferiors. > > As with other code doing this same thing, care must be taken to not > share the data when the objfile requires relocations. So, two keys > are used: one for the BFD and one for the objfile, and > gdb_bfd_requires_relocations is used to differentiate between the two > cases. > > gdb/ChangeLog > 2020-02-08 Tom Tromey > > * dwarf2/frame.c (dwarf2_frame_bfd_data): New global. > (dwarf2_frame_objfile_data): Add comment. > (find_comp_unit, set_comp_unit): New functions. > (dwarf2_frame_find_fde): Use find_comp_unit. > (dwarf2_build_frame_info): Use set_comp_unit. > > Change-Id: I50f5e1220c3f6b2992a15d5112fe474fb2904511 > --- > gdb/ChangeLog | 8 ++++++++ > gdb/dwarf2/frame.c | 37 +++++++++++++++++++++++++++++++++---- > 2 files changed, 41 insertions(+), 4 deletions(-) > > diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c > index 2c35016e2d9..25dddb7b1ae 100644 > --- a/gdb/dwarf2/frame.c > +++ b/gdb/dwarf2/frame.c > @@ -1475,8 +1475,14 @@ dwarf2_frame_cfa (struct frame_info *this_frame) > return get_frame_base (this_frame); > } > > -const struct objfile_key dwarf2_frame_objfile_data; > +/* We store the frame data on the BFD, when it is independent of the when -> where? > + address space and so can be shared. */ > +const struct bfd_key dwarf2_frame_bfd_data; > > +/* If any BFD sections require relocations (note; really should be if > + any debug info requires relocations), then we store the frame data > + on the objfile instead, and do not share it. */ > +const struct objfile_key dwarf2_frame_objfile_data; > > > /* Pointer encoding helper functions. */ > @@ -1630,6 +1636,29 @@ bsearch_fde_cmp (const dwarf2_fde *fde, CORE_ADDR seek_pc) > return 1; > } > > +/* Find an existing comp_unit for an objfile, if any. */ > + > +static comp_unit * > +find_comp_unit (struct objfile *objfile) > +{ > + bfd *abfd = objfile->obfd; > + if (gdb_bfd_requires_relocations (abfd)) > + return dwarf2_frame_bfd_data.get (abfd); > + return dwarf2_frame_objfile_data.get (objfile); > +} > + > +/* Store the comp_unit on OBJFILE, or the corresponding BFD, as > + appropriate. */ > + > +static void > +set_comp_unit (struct objfile *objfile, struct comp_unit *unit) > +{ > + bfd *abfd = objfile->obfd; > + if (gdb_bfd_requires_relocations (abfd)) > + return dwarf2_frame_bfd_data.set (abfd, unit); > + return dwarf2_frame_objfile_data.set (objfile, unit); > +} > + > /* Find the FDE for *PC. Return a pointer to the FDE, and store the > initial location associated with it into *PC. */ > > @@ -1641,11 +1670,11 @@ dwarf2_frame_find_fde (CORE_ADDR *pc, CORE_ADDR *out_offset) > CORE_ADDR offset; > CORE_ADDR seek_pc; > > - comp_unit *unit = dwarf2_frame_objfile_data.get (objfile); > + comp_unit *unit = find_comp_unit (objfile); > if (unit == NULL) > { > dwarf2_build_frame_info (objfile); > - unit = dwarf2_frame_objfile_data.get (objfile); > + unit = find_comp_unit (objfile); > } > gdb_assert (unit != NULL); > > @@ -2261,7 +2290,7 @@ dwarf2_build_frame_info (struct objfile *objfile) > unit->fde_table.shrink_to_fit (); > } > > - dwarf2_frame_objfile_data.set (objfile, unit); > + set_comp_unit (objfile, unit); > } > > /* Handle 'maintenance show dwarf unwinders'. */ > Otherwise LGTM.