From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 49946 invoked by alias); 12 Feb 2020 03:28:54 -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 49926 invoked by uid 89); 12 Feb 2020 03:28:52 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.8 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: simark.ca Received: from simark.ca (HELO simark.ca) (158.69.221.121) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 12 Feb 2020 03:28:48 +0000 Received: from [10.0.0.11] (unknown [192.222.164.54]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id BC23A1ED42; Tue, 11 Feb 2020 22:28:46 -0500 (EST) Subject: Re: [PATCH 3/8] Change fde table to a vector To: Tom Tromey , gdb-patches@sourceware.org References: <20200208152758.29385-1-tom@tromey.com> <20200208152758.29385-4-tom@tromey.com> From: Simon Marchi Message-ID: Date: Wed, 12 Feb 2020 03:28:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.2 MIME-Version: 1.0 In-Reply-To: <20200208152758.29385-4-tom@tromey.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2020-02/txt/msg00433.txt.bz2 On 2020-02-08 10:27 a.m., Tom Tromey wrote: > diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c > index db8e5cd25f3..6d87e598345 100644 > --- a/gdb/dwarf2/frame.c > +++ b/gdb/dwarf2/frame.c > @@ -129,11 +129,7 @@ struct dwarf2_fde > unsigned char eh_frame_p; > }; > > -struct dwarf2_fde_table > -{ > - int num_entries; > - struct dwarf2_fde **entries; > -}; > +typedef std::vector dwarf2_fde_table; As a further change, I think we could consider make this a vector of objects, rather than a vector of pointers. > /* A minimal decoding of DWARF2 compilation units. We only decode > what's needed to get to the call frame information. */ > @@ -1471,9 +1467,7 @@ dwarf2_frame_cfa (struct frame_info *this_frame) > return get_frame_base (this_frame); > } > > -const struct objfile_key - gdb::noop_deleter> > - dwarf2_frame_objfile_data; > +const struct objfile_key dwarf2_frame_objfile_data; Can you make this static, while at it? > @@ -2215,42 +2198,20 @@ dwarf2_build_frame_info (struct objfile *objfile) > warning (_("skipping .debug_frame info of %s: %s"), > objfile_name (objfile), e.what ()); > > - if (fde_table.num_entries != 0) > - { > - fde_table.num_entries = num_old_fde_entries; > - if (num_old_fde_entries == 0) > - { > - xfree (fde_table.entries); > - fde_table.entries = NULL; > - } > - else > - { > - fde_table.entries > - = XRESIZEVEC (struct dwarf2_fde *, fde_table.entries, > - fde_table.num_entries); > - } > - } > - fde_table.num_entries = num_old_fde_entries; > + fde_table.resize (num_old_fde_entries); > } > } > > /* Copy fde_table to obstack: it is needed at runtime. */ I think that comment is stale. > - fde_table2 = XOBNEW (&objfile->objfile_obstack, struct dwarf2_fde_table); > + fde_table2 = new dwarf2_fde_table; > > - if (fde_table.num_entries == 0) > - { > - fde_table2->entries = NULL; > - fde_table2->num_entries = 0; > - } > - else > + if (!fde_table.empty ()) If you want to simplify the code even further, you could get rid of this check, since the code below should cope well with an empty vector. > @@ -2293,16 +2249,10 @@ dwarf2_build_frame_info (struct objfile *objfile) > && fde_prev->initial_location == fde->initial_location) > continue; > > - obstack_grow (&objfile->objfile_obstack, &fde_table.entries[i], > - sizeof (fde_table.entries[0])); > - ++fde_table2->num_entries; > + fde_table2->push_back (fde); > fde_prev = fde; > } > - fde_table2->entries > - = (struct dwarf2_fde **) obstack_finish (&objfile->objfile_obstack); > - > - /* Discard the original fde_table. */ > - xfree (fde_table.entries); > + fde_table2->shrink_to_fit (); That shrink_to_fit appears to be pointless, as fde_table2 is created empty and we only push_back. Maybe you meant to create it with an initial size? Simon