From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 105953 invoked by alias); 6 Jul 2018 17:30: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 104729 invoked by uid 89); 6 Jul 2018 17:30:52 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=reminder, dare, gentle, rebasing 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; Fri, 06 Jul 2018 17:30:50 +0000 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 830E6308FB8C; Fri, 6 Jul 2018 17:30:49 +0000 (UTC) Received: from theo.uglyboxes.com (ovpn04.gateway.prod.ext.phx2.redhat.com [10.5.9.4]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3CBEA452B; Fri, 6 Jul 2018 17:30:49 +0000 (UTC) Subject: Re: [RFA 21/42] Move the context stack to buildsym_compunit To: Tom Tromey , gdb-patches@sourceware.org References: <20180523045851.11660-1-tom@tromey.com> <20180523045851.11660-22-tom@tromey.com> From: Keith Seitz Message-ID: <8337949d-a26d-4e3f-e75d-eccda88d74f6@redhat.com> Date: Fri, 06 Jul 2018 17:30:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <20180523045851.11660-22-tom@tromey.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2018-07/txt/msg00149.txt.bz2 On 05/22/2018 09:58 PM, Tom Tromey wrote: > diff --git a/gdb/buildsym.c b/gdb/buildsym.c > index 4e3ca5e4b1..54592b7795 100644 > --- a/gdb/buildsym.c > +++ b/gdb/buildsym.c > @@ -213,6 +213,9 @@ struct buildsym_compunit > /* global "using" directives. */ > > struct using_direct *m_global_using_directives = nullptr; > + > + std::vector m_context_stack; > + struct context_stack m_popped_context {}; > }; Explanatory comments -- especially for m_popped_context? Had I not read the commit log, I would not have (as easily) understood why this was necessary. > /* The work-in-progress of the compunit we are building. > @@ -1583,12 +1579,9 @@ augment_type_symtab (void) > struct compunit_symtab *cust = buildsym_compunit->compunit_symtab; > const struct blockvector *blockvector = COMPUNIT_BLOCKVECTOR (cust); > > - if (context_stack_depth > 0) > - { > - complaint (&symfile_complaints, > - _("Context stack not empty in augment_type_symtab")); > - context_stack_depth = 0; > - } > + if (!buildsym_compunit->m_context_stack.empty ()) > + complaint (&symfile_complaints, > + _("Context stack not empty in augment_type_symtab")); > if (pending_blocks != NULL) > complaint (&symfile_complaints, _("Blocks in a type symtab")); > if (buildsym_compunit->m_pending_macros != NULL) Warning: This patch (and one or two others) need rebasing. symfile_complaints was removed in May. > @@ -1745,6 +1736,35 @@ get_global_using_directives () > return &buildsym_compunit->m_global_using_directives; > } > > +/* See buildsym.h. */ > + > +bool > +outermost_context_p () > +{ > + gdb_assert (buildsym_compunit != nullptr); > + return buildsym_compunit->m_context_stack.empty (); > +} > + > +/* See buildsym.h. */ > + > +struct context_stack * > +get_current_context_stack () > +{ > + gdb_assert (buildsym_compunit != nullptr); > + if (buildsym_compunit->m_context_stack.empty ()) > + return nullptr; > + return &buildsym_compunit->m_context_stack.back (); > +} > + > +/* See buildsym.h. */ > + > +int > +get_context_stack_depth () > +{ > + gdb_assert (buildsym_compunit != nullptr); > + return buildsym_compunit->m_context_stack.size (); > +} > + I can't help but think these function names, which could appear in several source files, seem a little vague or collision-prone (conceptually)... Would it be worth it for these (and perhaps all similar buildsym.h get_* functions) to be namespaced or further prefixed, e.g., buildsym_[get_]current_context_stack or buildsym::get_current_context_stack? I'm not going to suggest [Dare I say, "require?"] any changes -- I'm just wondering "aloud." > /* Initialize anything that needs initializing when starting to read a > diff --git a/gdb/buildsym.h b/gdb/buildsym.h > index efb35c907b..fe158d183c 100644 > --- a/gdb/buildsym.h > +++ b/gdb/buildsym.h > @@ -270,6 +261,19 @@ extern void set_local_using_directives (struct using_direct *new_local); > > extern struct using_direct **get_global_using_directives (); > > +/* Non-zero if the context stack is empty. */ ^^^^^^^^ > + > +extern bool outermost_context_p (); Since this (now) returns bool, please use boolean in comment. [I realize that's a cut-n-paste-o.] > + > +/* Return the top of the context stack, or nullptr if there is > + entry. */ > + > +extern struct context_stack *get_current_context_stack (); > + Typo in "if there is entry." > +/* Return the context stack depth. */ > + > +extern int get_context_stack_depth (); > + > #undef EXTERN > > #endif /* defined (BUILDSYM_H) */ Thank you! [Just a gentle reminder: IANAM.] Keith